diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index 258a2c0..54ee934 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -90,3 +90,7 @@ function RemoveSpecialCharPlus($str) // Returning the result return $res; } + +function toDmy($date){ + return date("d-m-Y", strtotime($date)); +} \ No newline at end of file diff --git a/app/Http/Controllers/Admins/Pengeluaran/PengeluaranController.php b/app/Http/Controllers/Admins/Pengeluaran/PengeluaranController.php new file mode 100644 index 0000000..aea18cf --- /dev/null +++ b/app/Http/Controllers/Admins/Pengeluaran/PengeluaranController.php @@ -0,0 +1,120 @@ +get(); + $rekeningCoaTf = RekeningCoa::where('kode_coa', 1)->where('sub_kode_coa', 200)->get(); + + return view('pages.admin.pengeluaran.index', compact('coaBiaya', 'rekeningCoaTf')); + } + + public function simpan(Request $request){ + try { + DB::beginTransaction(); + + $user = request()->user(); + + Pengeluaran::create([ + 'faktur' => "PG-".date('YmdHis'), + 'tanggal' => $request->tanggal, + 'jenis_transaksi' => $request->jenis_transaksi, + 'nominal' => $request->nominal, + 'keterangan' => $request->keterangan, + 'user_id' => $user->id + ]); + if ($request->jenis_transaksi == "1") { + BukuBesar::create([ + 'faktur' => "PG-".date('YmdHis'), + 'tanggal' => $request->tanggal, + 'rekening_coa_id' => "2", + 'kode_rekening_coa' => "1.100.01", + 'keterangan_coa' => "Kas Kasir", + 'keterangan' => $request->keterangan, + 'debet' => 0, + 'kredit' => $request->nominal + ]); + BukuBesar::create([ + 'faktur' => "PG-".date('YmdHis'), + 'tanggal' => $request->tanggal, + 'rekening_coa_id' => $request->id_rekening_coa, + 'kode_rekening_coa' => $request->kode_coa, + 'keterangan_coa' => $request->keterangan_coa, + 'keterangan' => $request->keterangan, + 'debet' => $request->nominal, + 'kredit' => 0, + ]); + }else{ + BukuBesar::create([ + 'faktur' => "PG-".date('YmdHis'), + 'tanggal' => $request->tanggal, + 'rekening_coa_id' => $request->id_rekening_coa_transfer, + 'kode_rekening_coa' => $request->kode_coa_transfer, + 'keterangan_coa' => $request->keterangan_coa_transfer, + 'keterangan' => $request->keterangan, + 'debet' => 0, + 'kredit' => $request->nominal + ]); + BukuBesar::create([ + 'faktur' => "PG-".date('YmdHis'), + 'tanggal' => $request->tanggal, + 'rekening_coa_id' => $request->id_rekening_coa, + 'kode_rekening_coa' => $request->kode_coa, + 'keterangan_coa' => $request->keterangan_coa, + 'keterangan' => $request->keterangan, + 'debet' => $request->nominal, + 'kredit' => 0, + ]); + } + + DB::commit(); + + return response()->json(['status' => true, 'message' => 'Data berhasil tersimpan']); + } catch (\Throwable $th) { + DB::rollBack(); + + dd($th->getMessage()); + return response()->json(['status' => false, 'message' => 'Kesalahan menyimpan data']); + } + } + + public function laporan(Request $request){ + $mpdf = new \Mpdf\Mpdf([ + 'mode' => 'utf-8', + 'format' => 'A4', + 'orientation' => 'portrait', + 'margin_left' => 15, + 'margin_right' => 15, + 'margin_top' => 10, + 'margin_bottom' => 10, + 'default_font_size' => 9, + 'default_font' => 'arial', + ]); + $mpdf->AddPage(); + $mpdf->setFooter('{PAGENO}'); + + $data = Pengeluaran::with('user')->whereDate('tanggal', '>=', $request->filter_tanggal_1) + ->whereDate('tanggal', '<=', $request->filter_tanggal_2) + ->get(); + $html = view('pages.admin.pengeluaran.laporan', [ + 'data' => $data, + 'filter_tanggal_1' => $request->filter_tanggal_1, + 'filter_tanggal_2' => $request->filter_tanggal_2, + ]); + $mpdf->writeHTML($html); + $mpdf->Output('Laporan_Pengeluaran.pdf', 'I'); + return response()->header('Content-Type', 'application/pdf'); + } +} diff --git a/app/Http/Controllers/Auths/AuthController.php b/app/Http/Controllers/Auths/AuthController.php index 71a0cee..55aae3e 100644 --- a/app/Http/Controllers/Auths/AuthController.php +++ b/app/Http/Controllers/Auths/AuthController.php @@ -102,6 +102,9 @@ class AuthController extends Controller try { if (Auth::attempt($validator->validated(), $request->has('remember_me') ? true : false)) { + $user = auth()->user(); + session()->put('id', $user->id); + session()->put('name', $user->name); Session::flash('login-message', [ 'type' => 'success', 'msg' => 'Anda berhasil melakukan Login!' diff --git a/app/Models/Pengeluaran.php b/app/Models/Pengeluaran.php new file mode 100644 index 0000000..8d31211 --- /dev/null +++ b/app/Models/Pengeluaran.php @@ -0,0 +1,18 @@ +belongsTo(User::class, 'user_id'); + } +} diff --git a/composer.json b/composer.json index d06ead0..24d9779 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "laravel/framework": "^10.10", "laravel/sanctum": "^3.3", "laravel/tinker": "^2.8", + "mpdf/mpdf": "^8.2", "realrashid/sweet-alert": "^6.0", "spatie/laravel-permission": "^6.3", "yajra/laravel-datatables": "^10.1" diff --git a/composer.lock b/composer.lock index 1b0357e..1917c2b 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "c2a087156cf7cdb5fbd03918562d593c", + "content-hash": "622a1b44adad65bf17c6308f5e4f8fe0", "packages": [ { "name": "brick/math", @@ -2387,6 +2387,238 @@ ], "time": "2023-10-27T15:32:31+00:00" }, + { + "name": "mpdf/mpdf", + "version": "v8.2.2", + "source": { + "type": "git", + "url": "https://github.com/mpdf/mpdf.git", + "reference": "596a87b876d7793be7be060a8ac13424de120dd5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/596a87b876d7793be7be060a8ac13424de120dd5", + "reference": "596a87b876d7793be7be060a8ac13424de120dd5", + "shasum": "" + }, + "require": { + "ext-gd": "*", + "ext-mbstring": "*", + "mpdf/psr-http-message-shim": "^1.0 || ^2.0", + "mpdf/psr-log-aware-trait": "^2.0 || ^3.0", + "myclabs/deep-copy": "^1.7", + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "psr/http-message": "^1.0 || ^2.0", + "psr/log": "^1.0 || ^2.0 || ^3.0", + "setasign/fpdi": "^2.1" + }, + "require-dev": { + "mockery/mockery": "^1.3.0", + "mpdf/qrcode": "^1.1.0", + "squizlabs/php_codesniffer": "^3.5.0", + "tracy/tracy": "~2.5", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "ext-bcmath": "Needed for generation of some types of barcodes", + "ext-xml": "Needed mainly for SVG manipulation", + "ext-zlib": "Needed for compression of embedded resources, such as fonts" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Mpdf\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-only" + ], + "authors": [ + { + "name": "Matěj Humpál", + "role": "Developer, maintainer" + }, + { + "name": "Ian Back", + "role": "Developer (retired)" + } + ], + "description": "PHP library generating PDF files from UTF-8 encoded HTML", + "homepage": "https://mpdf.github.io", + "keywords": [ + "pdf", + "php", + "utf-8" + ], + "support": { + "docs": "http://mpdf.github.io", + "issues": "https://github.com/mpdf/mpdf/issues", + "source": "https://github.com/mpdf/mpdf" + }, + "funding": [ + { + "url": "https://www.paypal.me/mpdf", + "type": "custom" + } + ], + "time": "2023-11-07T13:52:14+00:00" + }, + { + "name": "mpdf/psr-http-message-shim", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/mpdf/psr-http-message-shim.git", + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/psr-http-message-shim/zipball/f25a0153d645e234f9db42e5433b16d9b113920f", + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f", + "shasum": "" + }, + "require": { + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpdf\\PsrHttpMessageShim\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Dorison", + "email": "mark@chromatichq.com" + }, + { + "name": "Kristofer Widholm", + "email": "kristofer@chromatichq.com" + }, + { + "name": "Nigel Cunningham", + "email": "nigel.cunningham@technocrat.com.au" + } + ], + "description": "Shim to allow support of different psr/message versions.", + "support": { + "issues": "https://github.com/mpdf/psr-http-message-shim/issues", + "source": "https://github.com/mpdf/psr-http-message-shim/tree/v2.0.1" + }, + "time": "2023-10-02T14:34:03+00:00" + }, + { + "name": "mpdf/psr-log-aware-trait", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/mpdf/psr-log-aware-trait.git", + "reference": "a633da6065e946cc491e1c962850344bb0bf3e78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/psr-log-aware-trait/zipball/a633da6065e946cc491e1c962850344bb0bf3e78", + "reference": "a633da6065e946cc491e1c962850344bb0bf3e78", + "shasum": "" + }, + "require": { + "psr/log": "^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpdf\\PsrLogAwareTrait\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Dorison", + "email": "mark@chromatichq.com" + }, + { + "name": "Kristofer Widholm", + "email": "kristofer@chromatichq.com" + } + ], + "description": "Trait to allow support of different psr/log versions.", + "support": { + "issues": "https://github.com/mpdf/psr-log-aware-trait/issues", + "source": "https://github.com/mpdf/psr-log-aware-trait/tree/v3.0.0" + }, + "time": "2023-05-03T06:19:36+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.11.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2023-03-08T13:26:56+00:00" + }, { "name": "nesbot/carbon", "version": "2.72.1", @@ -2879,6 +3111,56 @@ ], "time": "2024-01-09T09:30:37+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, { "name": "phpoffice/phpspreadsheet", "version": "1.29.0", @@ -3865,6 +4147,78 @@ ], "time": "2023-02-15T07:13:11+00:00" }, + { + "name": "setasign/fpdi", + "version": "v2.6.0", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDI.git", + "reference": "a6db878129ec6c7e141316ee71872923e7f1b7ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/a6db878129ec6c7e141316ee71872923e7f1b7ad", + "reference": "a6db878129ec6c7e141316ee71872923e7f1b7ad", + "shasum": "" + }, + "require": { + "ext-zlib": "*", + "php": "^5.6 || ^7.0 || ^8.0" + }, + "conflict": { + "setasign/tfpdf": "<1.31" + }, + "require-dev": { + "phpunit/phpunit": "~5.7", + "setasign/fpdf": "~1.8.6", + "setasign/tfpdf": "~1.33", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "~6.2" + }, + "suggest": { + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured." + }, + "type": "library", + "autoload": { + "psr-4": { + "setasign\\Fpdi\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" + }, + { + "name": "Maximilian Kresse", + "email": "maximilian.kresse@setasign.com", + "homepage": "https://www.setasign.com" + } + ], + "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", + "homepage": "https://www.setasign.com/fpdi", + "keywords": [ + "fpdf", + "fpdi", + "pdf" + ], + "support": { + "issues": "https://github.com/Setasign/FPDI/issues", + "source": "https://github.com/Setasign/FPDI/tree/v2.6.0" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/setasign/fpdi", + "type": "tidelift" + } + ], + "time": "2023-12-11T16:03:32+00:00" + }, { "name": "spatie/laravel-permission", "version": "6.3.0", @@ -7388,65 +7742,6 @@ }, "time": "2023-12-10T02:24:34+00:00" }, - { - "name": "myclabs/deep-copy", - "version": "1.11.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "conflict": { - "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" - }, - "require-dev": { - "doctrine/collections": "^1.6.8", - "doctrine/common": "^2.13.3 || ^3.2.2", - "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" - }, - "type": "library", - "autoload": { - "files": [ - "src/DeepCopy/deep_copy.php" - ], - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" - }, - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" - } - ], - "time": "2023-03-08T13:26:56+00:00" - }, { "name": "nunomaduro/collision", "version": "v7.10.0", diff --git a/database/migrations/2024_01_26_133430_create_pengeluarans_table.php b/database/migrations/2024_01_26_133430_create_pengeluarans_table.php new file mode 100644 index 0000000..cc73607 --- /dev/null +++ b/database/migrations/2024_01_26_133430_create_pengeluarans_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('faktur')->nullable(); + $table->date('tanggal')->nullable(); + $table->integer('jenis_transaksi')->nullable()->comment('1 = Tunai, 2 = Transfer'); + $table->integer('nominal')->nullable(); + $table->string('keterangan')->nullable(); + $table->foreignId('user_id')->nullable()->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('pengeluaran'); + } +}; diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 8c6b8b5..33b7f71 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -15,11 +15,11 @@ @endcan