export ok | import ok

pull/2/head
ajikamaludin 2 years ago
parent c6c9ab2dc3
commit 72714ff66d
Signed by: ajikamaludin
GPG Key ID: 476C9A2B4B794EBB

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Imports\DocumentImport;
use App\Models\Category;
use App\Models\Company;
use App\Models\Document;
@ -9,6 +10,7 @@ use App\Models\Type;
use App\Models\User;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
use OpenSpout\Writer\Common\Creator\Style\StyleBuilder;
use Rap2hpoutre\FastExcel\FastExcel;
@ -44,8 +46,6 @@ class DocumentController extends Controller
return inertia('Document/Index', [
'docs' => $query->paginate(10),
'now' => now()->timezone('UTC'),
'now2' => now()->toDateTimeString(),
]);
}
@ -209,9 +209,13 @@ class DocumentController extends Controller
$doc->delete();
}
public function import()
public function import(Request $request)
{
//
$request->validate([
'file' => 'required|file'
]);
Excel::import(new DocumentImport, $request->file);
}
@ -246,11 +250,17 @@ class DocumentController extends Controller
if($request->type == 'excel') {
return $this->exportAsExcel($collections);
}
return $this->print($collections);
}
private function print($collections) {
return view('exports.documents', ['collections' => $collections->toArray()]);
}
private function exportAsPdf($collections)
{
$pdf = Pdf::loadView('exports.documents', ['collections' => $collections->toArray()]);
$pdf = Pdf::setPaper('legal', 'landscape');
$pdf->loadView('exports.documents', ['collections' => $collections->toArray()]);
$date = now()->format('d-m-Y');
return $pdf->download("documents-$date.pdf");

@ -0,0 +1,71 @@
<?php
namespace App\Imports;
use App\Models\Category;
use App\Models\Company;
use App\Models\Document;
use App\Models\Type;
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class DocumentImport implements ToCollection, WithHeadingRow
{
/**
* @param Collection $collection
*/
public function collection(Collection $rows)
{
$no = Document::count();
$documents = collect();
foreach($rows as $row) {
$company = Company::where('name', 'like', $row['nama_perusahaan'])->first();
$type = Type::where('name', 'like', $row['jenis'])->first();
$cat = Category::where('name', 'like', $row['kategori'])->first();
if ($company == null) {
$company = Company::first();
}
if ($type == null) {
$type = Type::first();
}
if ($cat == null) {
$cat = Category::first();
}
$no += 1;
$documents->add([
"no" => $no,
"no_doc" => $row['no'],
"name" => $row['nama'],
"publisher" => $row['penerbit'],
"description" => $row['keterangan'],
"publish_date" => Carbon::createFromFormat('d-m-Y',$row['tanggal_terbit']),
"due_date" => Carbon::createFromFormat('d-m-Y',$row['tanggal_jatuh_tempo']),
"status" => $row['status'] == 'Ya' ? Document::STATUS_YES : Document::STATUS_NO,
"type" => $row['tipe'] == 'Tetap' ? Document::TYPE_TETAP : Document::TYPE_TIDAK_TETAP,
"document" => '',
"company_id" => $company->id,
"type_id" => $type->id,
"category_id" => $cat->id,
"user_id" => auth()->user()->id
]);
}
if ($documents->count() > 0) {
Document::insert($documents->toArray());
}
}
public function chunkSize(): int
{
return 1000;
}
}

@ -12,6 +12,7 @@
"laravel/framework": "^9.48",
"laravel/sanctum": "^2.8",
"laravel/tinker": "^2.7",
"maatwebsite/excel": "^3.1",
"rap2hpoutre/fast-excel": "^4.1",
"shiftonelabs/laravel-cascade-deletes": "^1.0",
"tightenco/ziggy": "^1.0"

577
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "776f6b59288b5ff0657e18a74e116064",
"content-hash": "77f0da3db5141596d003970e3c1fe8cf",
"packages": [
{
"name": "barryvdh/laravel-dompdf",
@ -139,6 +139,87 @@
],
"time": "2022-08-10T22:54:19+00:00"
},
{
"name": "composer/semver",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9",
"reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.4",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2022-04-01T19:23:25+00:00"
},
{
"name": "dflydev/dot-access-data",
"version": "v3.0.2",
@ -572,6 +653,67 @@
],
"time": "2023-01-14T14:17:03+00:00"
},
{
"name": "ezyang/htmlpurifier",
"version": "v4.16.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/523407fb06eb9e5f3d59889b3978d5bfe94299c8",
"reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8",
"shasum": ""
},
"require": {
"php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0"
},
"require-dev": {
"cerdic/css-tidy": "^1.7 || ^2.0",
"simpletest/simpletest": "dev-master"
},
"suggest": {
"cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.",
"ext-bcmath": "Used for unit conversion and imagecrash protection",
"ext-iconv": "Converts text to and from non-UTF-8 encodings",
"ext-tidy": "Used for pretty-printing HTML"
},
"type": "library",
"autoload": {
"files": [
"library/HTMLPurifier.composer.php"
],
"psr-0": {
"HTMLPurifier": "library/"
},
"exclude-from-classmap": [
"/library/HTMLPurifier/Language/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com"
}
],
"description": "Standards compliant HTML filter written in PHP",
"homepage": "http://htmlpurifier.org/",
"keywords": [
"html"
],
"support": {
"issues": "https://github.com/ezyang/htmlpurifier/issues",
"source": "https://github.com/ezyang/htmlpurifier/tree/v4.16.0"
},
"time": "2022-09-18T07:06:19+00:00"
},
{
"name": "fruitcake/php-cors",
"version": "v1.2.0",
@ -1825,6 +1967,271 @@
],
"time": "2022-04-17T13:12:02+00:00"
},
{
"name": "maatwebsite/excel",
"version": "3.1.46",
"source": {
"type": "git",
"url": "https://github.com/SpartnerNL/Laravel-Excel.git",
"reference": "ba0b9b9305d5b603c3938d4d1d4a13025c92c241"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SpartnerNL/Laravel-Excel/zipball/ba0b9b9305d5b603c3938d4d1d4a13025c92c241",
"reference": "ba0b9b9305d5b603c3938d4d1d4a13025c92c241",
"shasum": ""
},
"require": {
"composer/semver": "^3.3",
"ext-json": "*",
"illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0",
"php": "^7.0|^8.0",
"phpoffice/phpspreadsheet": "^1.18",
"psr/simple-cache": "^1.0|^2.0|^3.0"
},
"require-dev": {
"orchestra/testbench": "^6.0|^7.0|^8.0",
"predis/predis": "^1.1"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Maatwebsite\\Excel\\ExcelServiceProvider"
],
"aliases": {
"Excel": "Maatwebsite\\Excel\\Facades\\Excel"
}
}
},
"autoload": {
"psr-4": {
"Maatwebsite\\Excel\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Patrick Brouwers",
"email": "patrick@spartner.nl"
}
],
"description": "Supercharged Excel exports and imports in Laravel",
"keywords": [
"PHPExcel",
"batch",
"csv",
"excel",
"export",
"import",
"laravel",
"php",
"phpspreadsheet"
],
"support": {
"issues": "https://github.com/SpartnerNL/Laravel-Excel/issues",
"source": "https://github.com/SpartnerNL/Laravel-Excel/tree/3.1.46"
},
"funding": [
{
"url": "https://laravel-excel.com/commercial-support",
"type": "custom"
},
{
"url": "https://github.com/patrickbrouwers",
"type": "github"
}
],
"time": "2023-01-26T20:40:09+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3",
"reference": "3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"myclabs/php-enum": "^1.5",
"php": "^8.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.9",
"guzzlehttp/guzzle": "^6.5.3 || ^7.2.0",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.4",
"phpunit/phpunit": "^8.5.8 || ^9.4.2",
"vimeo/psalm": "^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/v2.4.0"
},
"funding": [
{
"url": "https://github.com/maennchen",
"type": "github"
},
{
"url": "https://opencollective.com/zipstream",
"type": "open_collective"
}
],
"time": "2022-12-08T12:29:14+00:00"
},
{
"name": "markbaker/complex",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
},
"time": "2022-12-06T16:21:08+00:00"
},
{
"name": "markbaker/matrix",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "^4.0",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"sebastian/phpcpd": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@demon-angel.eu"
}
],
"description": "PHP Class for working with matrices",
"homepage": "https://github.com/MarkBaker/PHPMatrix",
"keywords": [
"mathematics",
"matrix",
"vector"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
},
"time": "2022-12-02T22:17:43+00:00"
},
{
"name": "masterminds/html5",
"version": "2.7.6",
@ -1996,6 +2403,69 @@
],
"time": "2022-07-24T11:55:47+00:00"
},
{
"name": "myclabs/php-enum",
"version": "1.8.4",
"source": {
"type": "git",
"url": "https://github.com/myclabs/php-enum.git",
"reference": "a867478eae49c9f59ece437ae7f9506bfaa27483"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/a867478eae49c9f59ece437ae7f9506bfaa27483",
"reference": "a867478eae49c9f59ece437ae7f9506bfaa27483",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.3 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "1.*",
"vimeo/psalm": "^4.6.2"
},
"type": "library",
"autoload": {
"psr-4": {
"MyCLabs\\Enum\\": "src/"
},
"classmap": [
"stubs/Stringable.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP Enum contributors",
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
}
],
"description": "PHP Enum implementation",
"homepage": "http://github.com/myclabs/php-enum",
"keywords": [
"enum"
],
"support": {
"issues": "https://github.com/myclabs/php-enum/issues",
"source": "https://github.com/myclabs/php-enum/tree/1.8.4"
},
"funding": [
{
"url": "https://github.com/mnapoli",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
"type": "tidelift"
}
],
"time": "2022-08-04T09:53:51+00:00"
},
{
"name": "nesbot/carbon",
"version": "2.65.0",
@ -2567,6 +3037,111 @@
},
"time": "2022-09-06T12:16:56+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "1.27.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "eeb8582f9cabf5a7f4ef78015691163233a1834f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/eeb8582f9cabf5a7f4ef78015691163233a1834f",
"reference": "eeb8582f9cabf5a7f4ef78015691163233a1834f",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"ezyang/htmlpurifier": "^4.15",
"maennchen/zipstream-php": "^2.1",
"markbaker/complex": "^3.0",
"markbaker/matrix": "^3.0",
"php": "^7.4 || ^8.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"dompdf/dompdf": "^1.0 || ^2.0",
"friendsofphp/php-cs-fixer": "^3.2",
"mitoteam/jpgraph": "^10.2.4",
"mpdf/mpdf": "^8.1.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^8.5 || ^9.0",
"squizlabs/php_codesniffer": "^3.7",
"tecnickcom/tcpdf": "^6.5"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"ext-intl": "PHP Internationalization Functions",
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
},
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.27.0"
},
"time": "2023-01-24T20:07:45+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.0",

@ -0,0 +1,3 @@
nama_perusahaan, jenis, kategori, no, nama, penerbit, tipe, tanggal_terbit,tanggal_jatuh_tempo, keterangan, file, status
P1,J1,K1,0001,DOCAA,DIS,Tetap,30-01-2023,30-02-2023,-,-,Ya
P1,J1,K1,0001,DOCAA,DIS,"Tidak Tetap",30-01-2023,30-02-2023,-,-,Tidak
1 nama_perusahaan jenis kategori no nama penerbit tipe tanggal_terbit tanggal_jatuh_tempo keterangan file status
2 P1 J1 K1 0001 DOCAA DIS Tetap 30-01-2023 30-02-2023 - - Ya
3 P1 J1 K1 0001 DOCAA DIS Tidak Tetap 30-01-2023 30-02-2023 - - Tidak

@ -10,6 +10,7 @@ import Pagination from '@/Components/Pagination'
import ModalConfirm from '@/Components/ModalConfirm'
import { IconMenu } from '@/Icons'
import { formatDate, hasPermission } from '@/utils'
import ModalImport from './ModalImport'
export default function Document(props) {
const { data: docs, links } = props.docs
@ -17,6 +18,8 @@ export default function Document(props) {
const [search, setSearch] = useState({q: '', status: 0})
const preValue = usePrevious(search)
const importModal = useModalState(false)
const confirmModal = useModalState(false)
const handleDelete = (doc) => {
confirmModal.setData(doc)
@ -88,7 +91,7 @@ export default function Document(props) {
</Link>
)}
{canImport && (
<div className='btn btn-outline'>
<div className='btn btn-outline' onClick={importModal.toggle}>
Import
</div>
)}
@ -120,6 +123,7 @@ export default function Document(props) {
<ul tabIndex={0} className="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52">
<li><a href={route('docs.export', {type: 'excel'})} target='_blank'>XLSX</a></li>
<li><a href={route('docs.export', {type: 'pdf'})} target='_blank'>PDF</a></li>
<li><a href={route('docs.export', {type: ''})} target='_blank'>Print</a></li>
</ul>
</div>
)}
@ -174,7 +178,9 @@ export default function Document(props) {
))}
</tbody>
</table>
<Pagination links={links} params={search}/>
<div className='w-full flex justify-center'>
<Pagination links={links} params={search}/>
</div>
</div>
</div>
@ -186,6 +192,9 @@ export default function Document(props) {
toggle={confirmModal.toggle}
onConfirm={onDelete}
/>
<ModalImport
modalState={importModal}
/>
</AuthenticatedLayout>
)
}

@ -0,0 +1,98 @@
import React, { useRef } from 'react'
import { useForm } from '@inertiajs/react'
export default function ModalImport(props) {
const { modalState } = props
const { data, setData, post, progress, errors, clearErrors } = useForm({
file: null,
});
const inputFileImport = useRef();
console.log(data)
console.log(inputFileImport)
const handleReset = () => {
setData({file: null});
inputFileImport.current.value = ""
clearErrors();
};
const handleCancel = () => {
modalState.toggle()
handleReset();
};
function handleSubmit(e) {
e.preventDefault();
post(route("docs.import"), {
forceFormData: false,
onSuccess: () => Promise.all([handleReset(), modalState.toggle()]),
});
return;
}
return (
<div
className="modal modal-bottom sm:modal-middle pb-10"
style={
modalState.isOpen
? {
opacity: 1,
pointerEvents: 'auto',
visibility: 'visible',
}
: {}
}
>
<div className="modal-box">
<h1 className="font-bold text-2xl pb-8">Import</h1>
<div className='flex flex-row items-center gap-2'>
<div
className={`btn ${
errors.photo && 'input-error'
}`}
onClick={() => {
console.log(inputFileImport.current.click())
}}
>Pilih File: </div>
<div>
{data.file ? data.file.name : 'Pilih File'}
</div>
</div>
<input
ref={inputFileImport}
type="file"
className="hidden"
onChange={(e) =>
setData("file", e.target.files[0])
}
/>
{progress && (
<progress className='progress' value={progress.percentage} max="100">
{progress.percentage}%
</progress>
)}
<div>
{errors.file}
</div>
<p>
Unduh format file import{" "}
<a
className="underline text-blue-500"
href="/sample-import.csv"
>
disini
</a>
</p>
<div className='flex justify-between mt-4 space-x-4'>
<div className='btn' onClick={handleSubmit}>Upload</div>
<div className='btn btn-outline' onClick={handleCancel}>Batal</div>
</div>
</div>
</div>
)
}

@ -1,42 +1,66 @@
<style>
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid;
}
th, td {
padding: 5px;
}
.header {
width: 100%;
margin: auto;
text-align: center;
}
</style>
<div class="header">
<h1>Dokumen Monitoring</h1>
</div>
<table>
<thead>
<tr>
<th>group</th>
<th>region</th>
<th>nama perusahaan</th>
<th>jenis</th>
<th>kategori</th>
<th>no</th>
<th>nama</th>
<th>penerbit</th>
<th>tipe</th>
<th>tanggal terbit</th>
<th>tanggal jatuh tempo</th>
<th>keterangan</th>
<th>file</th>
<th>status</th>
<th>catatan</th>
<th >group</th>
<th >region</th>
<th >nama perusahaan</th>
<th >jenis</th>
<th >kategori</th>
<th >no</th>
<th >nama</th>
<th >penerbit</th>
<th >tipe</th>
<th >tanggal terbit</th>
<th >tanggal jatuh tempo</th>
<th >keterangan</th>
<th >file</th>
<th >status</th>
<th >catatan</th>
</tr>
</thead>
<tbody>
@foreach($collections as $collec)
<tr>
@foreach($collections as $collec)
<td>{{ $collec["group"] }}</td>
<td>{{ $collec["region"] }}</td>
<td>{{ $collec["nama perusahaan"] }}</td>
<td>{{ $collec["jenis"] }}</td>
<td>{{ $collec["kategori"] }}</td>
<td>{{ $collec["no"] }}</td>
<td>{{ $collec["nama"] }}</td>
<td>{{ $collec["penerbit"] }}</td>
<td>{{ $collec["tipe"] }}</td>
<td>{{ $collec["tanggal terbit"] }}</td>
<td>{{ $collec["tanggal jatuh tempo"] }}</td>
<td>{{ $collec["keterangan"] }}</td>
<td>{{ $collec["file"] }}</td>
<td>{{ $collec["status"] }}</td>
<td>{{ $collec["catatan"] }}</td>
@endforeach
<td >{{ $collec["group"] }}</td>
<td >{{ $collec["region"] }}</td>
<td >{{ $collec["nama perusahaan"] }}</td>
<td >{{ $collec["jenis"] }}</td>
<td >{{ $collec["kategori"] }}</td>
<td >{{ $collec["no"] }}</td>
<td >{{ $collec["nama"] }}</td>
<td >{{ $collec["penerbit"] }}</td>
<td >{{ $collec["tipe"] }}</td>
<td style="width: 7%;">{{ $collec["tanggal terbit"] }}</td>
<td style="width: 7%;">{{ $collec["tanggal jatuh tempo"] }}</td>
<td >{{ $collec["keterangan"] }}</td>
<td >
<a href='{{ $collec["file"] }}'>Download</a>
</td>
<td >{{ $collec["status"] }}</td>
<td >{{ $collec["catatan"] }}</td>
</tr>
@endforeach
</tbody>
</table>
</table>
<script>
window.print()
</script>

@ -69,6 +69,7 @@ Route::middleware(['auth'])->group(function () {
Route::put('/categories/{category}', [CategoryController::class, 'update'])->name('categories.update');
Route::delete('/categories/{category}', [CategoryController::class, 'destroy'])->name('categories.destroy');
Route::post("/docs/import", [DocumentController::class, 'import'])->name('docs.import');
Route::get('/docs', [DocumentController::class, 'index'])->name('docs.index');
Route::get('/docs/create', [DocumentController::class, 'create'])->name('docs.create');
Route::post('/docs', [DocumentController::class, 'store'])->name('docs.store');

Loading…
Cancel
Save