diff --git a/app/Http/Controllers/Admin/AdminRefundController.php b/app/Http/Controllers/Admin/AdminRefundController.php
index f3a3cc1..1d6c459 100644
--- a/app/Http/Controllers/Admin/AdminRefundController.php
+++ b/app/Http/Controllers/Admin/AdminRefundController.php
@@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Controller;
use App\Models\TransactionDescription;
use Carbon\Carbon;
+use Illuminate\Support\Facades\Http;
class AdminRefundController extends Controller
{
@@ -50,45 +51,64 @@ class AdminRefundController extends Controller
'reason' => $refund->complaint,
];
- // $refundMidtrans = Trans::refund($request->id, $params);
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
- try {
- Transaction::where('id', $refund->transaction_id)->update([
- 'status_transaksi' => 'refund',
- 'status_pembayaran' => 'refund',
- ]);
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->post('https://api.sandbox.midtrans.com/v2/'.$request->id.'/refund', $params);
- Refund::where('id', $request->id)->update([
- 'status' => 'refund',
- ]);
+ $result = json_decode($response->body(), true);
+ $code = $result['status_code'];
- TransactionDescription::create([
- 'transaction_id' => $refund->transaction_id,
- 'status' => 'refund',
- 'user' => auth()->user()->email,
- 'judul' => 'fas fa-long-arrow-alt-left',
- 'background' => 'bg-primary',
- 'deskripsi' => 'Admin telah menyetujui refund.',
- ]);
+ if($code == '200'){
+ try {
+ Transaction::where('id', $refund->transaction_id)->update([
+ 'status_transaksi' => 'refund',
+ 'status_pembayaran' => 'refund',
+ ]);
- DB::commit();
+ Refund::where('id', $request->id)->update([
+ 'status' => 'refund',
+ ]);
- return response()->json([
- 'status' => true,
- 'message' => 'Refund berhasil dilakukan. Uang akan dikembalikan ke pembeli.',
- // 'refundMidtrans' => $refundMidtrans,
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
+ TransactionDescription::create([
+ 'transaction_id' => $refund->transaction_id,
+ 'status' => 'refund',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fas fa-long-arrow-alt-left',
+ 'background' => 'bg-primary',
+ 'deskripsi' => 'Admin telah menyetujui refund.',
+ ]);
- Log::error($e->getMessage());
+ DB::commit();
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Refund berhasil dilakukan. Uang akan dikembalikan ke pembeli.',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Refund gagal dilakukan',
+ ]);
+ }
+ }else{
return response()->json([
'status' => false,
'message' => 'Refund gagal dilakukan',
- // 'refundMidtrans' => $refundMidtrans
]);
}
+
+
}
public function denyRefund(Request $request)
@@ -144,12 +164,12 @@ class AdminRefundController extends Controller
if ($request->has('search') && !empty($request->search['value'])) {
$searchRefund = $request->search['value'];
if (!is_numeric($searchRefund)) {
- $subQuery->where(function ($a) use ($searchRefund) {
- $a->whereRaw("LOWER(CONCAT(b.nama_depan,' ',b.nama_belakang)) LIKE ?", ['%' . strtolower($searchRefund) . '%'])
- ->orWhereRaw("LOWER(CONCAT(s.nama_depan,' ',s.nama_belakang)) LIKE ?", ['%' . strtolower($searchRefund) . '%'])
- ->orWhereRaw('LOWER(transactions.nama_barang) LIKE ?', ['%' . strtolower($searchRefund) . '%'])
- ->orWhereRaw('LOWER(refunds.status) LIKE ?', ['%' . strtolower($searchRefund) . '%']);
- });
+ $subQuery->where(function ($a) use ($searchRefund) {
+ $a->whereRaw("LOWER(CONCAT(b.nama_depan,' ',b.nama_belakang)) LIKE ?", ['%' . strtolower($searchRefund) . '%'])
+ ->orWhereRaw("LOWER(CONCAT(s.nama_depan,' ',s.nama_belakang)) LIKE ?", ['%' . strtolower($searchRefund) . '%'])
+ ->orWhereRaw('LOWER(transactions.nama_barang) LIKE ?', ['%' . strtolower($searchRefund) . '%'])
+ ->orWhereRaw('LOWER(refunds.status) LIKE ?', ['%' . strtolower($searchRefund) . '%']);
+ });
} else {
$subQuery->where(function ($a) use ($searchRefund) {
$a->whereDay('refunds.created_at', '=', $searchRefund)
diff --git a/app/Http/Controllers/Admin/AdminTransactionController.php b/app/Http/Controllers/Admin/AdminTransactionController.php
index 433c502..d147234 100644
--- a/app/Http/Controllers/Admin/AdminTransactionController.php
+++ b/app/Http/Controllers/Admin/AdminTransactionController.php
@@ -8,6 +8,7 @@ use App\Models\TransactionDescription;
use App\Models\TransactionUser;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Throwable;
use Yajra\DataTables\DataTables;
@@ -19,9 +20,7 @@ class AdminTransactionController extends Controller
*/
public function index()
{
- return view('admin.transaction.index', [
- 'transactions' => Transaction::latest()->get(),
- ]);
+ return view('admin.transaction.index');
}
/**
@@ -39,35 +38,56 @@ class AdminTransactionController extends Controller
public function approveTransaction(Request $request)
{
- try {
- DB::beginTransaction();
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
- Transaction::where('id', $request->id)->update([
- 'status_transaksi' => 'success',
- 'status_pembayaran' => 'settlement',
- 'fraud_status' => 'accept'
- ]);
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->post('https://api.sandbox.midtrans.com/v2/'.$request->id.'/approve');
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'success',
- 'user' => auth()->user()->email,
- 'judul' => 'fa fa-check',
- 'background' => 'bg-primary',
- 'deskripsi' => 'Admin telah menerima pembayaran transaksi dan dilanjutkan ke penjual.',
- ]);
+ $result = json_decode($response->body(), true);
+ $code = $result['status_code'];
- DB::commit();
+ if($code == '200'){
+ try {
+ DB::beginTransaction();
- return response()->json([
- 'status' => true,
- 'message' => 'Transaksi telah diterima.'
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
+ Transaction::where('id', $request->id)->update([
+ 'status_transaksi' => 'success',
+ 'status_pembayaran' => 'settlement',
+ 'fraud_status' => 'accept'
+ ]);
- Log::error($e->getMessage());
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'success',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fa fa-check',
+ 'background' => 'bg-primary',
+ 'deskripsi' => 'Admin telah menerima pembayaran transaksi dan dilanjutkan ke penjual.',
+ ]);
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Transaksi telah diterima.'
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi kesalahan di bagian server.',
+ ]);
+ }
+ }else{
return response()->json([
'status' => false,
'message' => 'Terjadi kesalahan di bagian server.',
@@ -77,35 +97,56 @@ class AdminTransactionController extends Controller
public function denyTransaction(Request $request)
{
- try {
- DB::beginTransaction();
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
- Transaction::where('id', $request->id)->update([
- 'status_transaksi' => 'failure',
- 'status_pembayaran' => 'failure',
- 'fraud_status' => 'deny'
- ]);
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->post('https://api.sandbox.midtrans.com/v2/'.$request->id.'/deny');
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'failure',
- 'user' => auth()->user()->email,
- 'judul' => 'fa fa-times',
- 'background' => 'bg-primary',
- 'deskripsi' => 'Admin telah menolak pembayaran karena terindikasi penipuan.',
- ]);
+ $result = json_decode($response->body(), true);
+ $code = $result['status_code'];
- DB::commit();
+ if($code == '200'){
+ try {
+ DB::beginTransaction();
- return response()->json([
- 'status' => true,
- 'message' => 'Transaksi telah ditolak.'
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
+ Transaction::where('id', $request->id)->update([
+ 'status_transaksi' => 'failure',
+ 'status_pembayaran' => 'failure',
+ 'fraud_status' => 'deny'
+ ]);
- Log::error($e->getMessage());
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'failure',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fa fa-times',
+ 'background' => 'bg-primary',
+ 'deskripsi' => 'Admin telah menolak pembayaran karena terindikasi penipuan.',
+ ]);
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Transaksi telah ditolak.'
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi kesalahan di bagian server.',
+ ]);
+ }
+ }else{
return response()->json([
'status' => false,
'message' => 'Terjadi kesalahan di bagian server.',
diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php
index 0ace408..142cef9 100644
--- a/app/Http/Controllers/Admin/AdminUserController.php
+++ b/app/Http/Controllers/Admin/AdminUserController.php
@@ -52,37 +52,46 @@ class AdminUserController extends Controller
public function approveUser(Request $request)
{
- $user = User::findOrFail($request->id);
- $user->status = 'Finished';
- $result = $user->save();
- if ($result) {
+ try{
+ DB::beginTransaction();
+
+ User::where('id', $request->id)->update([
+ 'status' => 'Finished'
+ ]);
+
+ DB::commit();
+
return response()->json([
'message' => 'Akun telah disetujui dan dapat digunakan',
'status' => true,
]);
- } else {
- return response()->json([
- 'message' => 'Akun gagal disetujui karena ' + $result,
- 'status' => false,
- ]);
+ }catch(Throwable $e){
+ Log::error($e->getMessage());
+
+ return response()->json(['success' => false, 'message' => 'Terjadi Kesalahan pada sisi server']);
}
}
public function denyUser(Request $request)
{
- $user = User::findOrFail($request->id);
- $user->status = 'Rejected';
- $result = $user->save();
- if ($result) {
+ try{
+ DB::beginTransaction();
+
+ User::where('id', $request->id)->update([
+ 'status' => 'Rejected'
+ ]);
+
+ DB::commit();
+
return response()->json([
'message' => 'Akun telah ditolak dan tidak dapat digunakan',
'status' => true,
]);
- } else {
- return response()->json([
- 'message' => 'Akun gagal ditolak karena ' + $result,
- 'status' => false,
- ]);
+
+ }catch(Throwable $e){
+ Log::error($e->getMessage());
+
+ return response()->json(['success' => false, 'message' => 'Terjadi Kesalahan pada sisi server']);
}
}
diff --git a/app/Http/Controllers/Invoice/InvoiceController.php b/app/Http/Controllers/Invoice/InvoiceController.php
index 8089179..77ca40e 100644
--- a/app/Http/Controllers/Invoice/InvoiceController.php
+++ b/app/Http/Controllers/Invoice/InvoiceController.php
@@ -4,8 +4,7 @@ namespace App\Http\Controllers\Invoice;
use App\Http\Controllers\Controller;
use App\Models\Transaction;
-use App\Models\TransactionDescription;
-use App\Models\TransactionUser;
+use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Http\Request;
class InvoiceController extends Controller
@@ -13,12 +12,17 @@ class InvoiceController extends Controller
public function getInvoice($id)
{
return view('invoice.invoice-transaction', [
- 'TransactionUser' => TransactionUser::HistoryTransaction(),
- // 'transaction' => Transaction::findOrFail($id),
+ 'transaction' => Transaction::findOrFail($id),
]);
}
public function exportInvoice(Request $request)
{
+ // $transaction = Transaction::findOrFail($request->id);
+ // $pdf = Pdf::loadView('invoice.export-invoice',compact('transaction'))->setPaper('A4','Portrait');
+ // return $pdf->download("invoice-$request->id.pdf");
+ return view('invoice.export-invoice', [
+ 'transaction' => Transaction::findOrFail($request->id),
+ ]);
}
}
diff --git a/app/Http/Controllers/Login/LoginController.php b/app/Http/Controllers/Login/LoginController.php
index d27975c..f25ef0c 100644
--- a/app/Http/Controllers/Login/LoginController.php
+++ b/app/Http/Controllers/Login/LoginController.php
@@ -240,7 +240,7 @@ class LoginController extends Controller
$password = Hash::make($new_password);
- $result = User::create([
+ User::create([
'nama_depan' => $nama_depan,
'nama_belakang' => $nama_belakang,
'tanggal_lahir' => $tanggal_lahir,
diff --git a/app/Http/Controllers/User/UserRefundController.php b/app/Http/Controllers/User/UserRefundController.php
index e1cd074..61d2e50 100644
--- a/app/Http/Controllers/User/UserRefundController.php
+++ b/app/Http/Controllers/User/UserRefundController.php
@@ -5,7 +5,6 @@ namespace App\Http\Controllers\User;
use Throwable;
use Carbon\Carbon;
use App\Models\Refund;
-use App\Models\RefundUser;
use App\Models\Transaction;
use Illuminate\Http\Request;
use Yajra\DataTables\DataTables;
@@ -19,13 +18,7 @@ class UserRefundController extends Controller
{
public function index()
{
- $refunds = Refund::join('transactions', 'refunds.transaction_id', '=', 'transactions.id')
- ->where('transactions.pembeli', auth()->user()->email)
- ->get('refunds.*');
-
- return view('user.refund.index', [
- 'refunds' => $refunds
- ]);
+ return view('user.refund.index');
}
public function create($id)
diff --git a/composer.json b/composer.json
index 5559c57..0836311 100644
--- a/composer.json
+++ b/composer.json
@@ -9,6 +9,7 @@
"license": "MIT",
"require": {
"php": "^8.1",
+ "barryvdh/laravel-dompdf": "^2.0",
"guzzlehttp/guzzle": "^7.2",
"intervention/image": "^2.7",
"laravel/framework": "^10.10",
diff --git a/composer.lock b/composer.lock
index 14cdcab..0420d09 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,85 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "8a11a96f5b3b33624cb77d7ee7c3dba7",
+ "content-hash": "fb619bb949178b27fd06e732826b1686",
"packages": [
+ {
+ "name": "barryvdh/laravel-dompdf",
+ "version": "v2.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/barryvdh/laravel-dompdf.git",
+ "reference": "9843d2be423670fb434f4c978b3c0f4dd92c87a6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/9843d2be423670fb434f4c978b3c0f4dd92c87a6",
+ "reference": "9843d2be423670fb434f4c978b3c0f4dd92c87a6",
+ "shasum": ""
+ },
+ "require": {
+ "dompdf/dompdf": "^2.0.1",
+ "illuminate/support": "^6|^7|^8|^9|^10",
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "nunomaduro/larastan": "^1|^2",
+ "orchestra/testbench": "^4|^5|^6|^7|^8",
+ "phpro/grumphp": "^1",
+ "squizlabs/php_codesniffer": "^3.5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Barryvdh\\DomPDF\\ServiceProvider"
+ ],
+ "aliases": {
+ "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf",
+ "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf"
+ }
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Barryvdh\\DomPDF\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Barry vd. Heuvel",
+ "email": "barryvdh@gmail.com"
+ }
+ ],
+ "description": "A DOMPDF Wrapper for Laravel",
+ "keywords": [
+ "dompdf",
+ "laravel",
+ "pdf"
+ ],
+ "support": {
+ "issues": "https://github.com/barryvdh/laravel-dompdf/issues",
+ "source": "https://github.com/barryvdh/laravel-dompdf/tree/v2.0.1"
+ },
+ "funding": [
+ {
+ "url": "https://fruitcake.nl",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/barryvdh",
+ "type": "github"
+ }
+ ],
+ "time": "2023-01-12T15:12:49+00:00"
+ },
{
"name": "brick/math",
"version": "0.11.0",
@@ -304,6 +381,68 @@
],
"time": "2022-12-15T16:57:16+00:00"
},
+ {
+ "name": "dompdf/dompdf",
+ "version": "v2.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dompdf/dompdf.git",
+ "reference": "e8d2d5e37e8b0b30f0732a011295ab80680d7e85"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dompdf/dompdf/zipball/e8d2d5e37e8b0b30f0732a011295ab80680d7e85",
+ "reference": "e8d2d5e37e8b0b30f0732a011295ab80680d7e85",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "ext-mbstring": "*",
+ "masterminds/html5": "^2.0",
+ "phenx/php-font-lib": ">=0.5.4 <1.0.0",
+ "phenx/php-svg-lib": ">=0.3.3 <1.0.0",
+ "php": "^7.1 || ^8.0"
+ },
+ "require-dev": {
+ "ext-json": "*",
+ "ext-zip": "*",
+ "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": "The Dompdf Community",
+ "homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md"
+ }
+ ],
+ "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/v2.0.3"
+ },
+ "time": "2023-02-07T12:51:48+00:00"
+ },
{
"name": "dragonmantank/cron-expression",
"version": "v3.3.3",
@@ -2194,6 +2333,73 @@
],
"time": "2023-10-17T14:13:20+00:00"
},
+ {
+ "name": "masterminds/html5",
+ "version": "2.8.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Masterminds/html5-php.git",
+ "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f47dcf3c70c584de14f21143c55d9939631bc6cf",
+ "reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf",
+ "shasum": ""
+ },
+ "require": {
+ "ext-dom": "*",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Masterminds\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Matt Butcher",
+ "email": "technosophos@gmail.com"
+ },
+ {
+ "name": "Matt Farina",
+ "email": "matt@mattfarina.com"
+ },
+ {
+ "name": "Asmir Mustafic",
+ "email": "goetas@gmail.com"
+ }
+ ],
+ "description": "An HTML5 parser and serializer.",
+ "homepage": "http://masterminds.github.io/html5-php",
+ "keywords": [
+ "HTML5",
+ "dom",
+ "html",
+ "parser",
+ "querypath",
+ "serializer",
+ "xml"
+ ],
+ "support": {
+ "issues": "https://github.com/Masterminds/html5-php/issues",
+ "source": "https://github.com/Masterminds/html5-php/tree/2.8.1"
+ },
+ "time": "2023-05-10T11:58:31+00:00"
+ },
{
"name": "monolog/monolog",
"version": "3.5.0",
@@ -2827,6 +3033,96 @@
},
"time": "2023-04-30T00:54:53+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.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dompdf/php-svg-lib.git",
+ "reference": "76876c6cf3080bcb6f249d7d59705108166a6685"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/76876c6cf3080bcb6f249d7d59705108166a6685",
+ "reference": "76876c6cf3080bcb6f249d7d59705108166a6685",
+ "shasum": ""
+ },
+ "require": {
+ "ext-mbstring": "*",
+ "php": "^7.1 || ^8.0",
+ "sabberworm/php-css-parser": "^8.4"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^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/dompdf/php-svg-lib/issues",
+ "source": "https://github.com/dompdf/php-svg-lib/tree/0.5.0"
+ },
+ "time": "2022-09-06T12:16:56+00:00"
+ },
{
"name": "phpoption/phpoption",
"version": "1.9.1",
@@ -3680,6 +3976,59 @@
],
"time": "2023-11-08T05:53:05+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": "stella-maris/clock",
"version": "0.1.7",
@@ -9350,5 +9699,5 @@
"php": "^8.1"
},
"platform-dev": [],
- "plugin-api-version": "2.3.0"
+ "plugin-api-version": "2.6.0"
}
diff --git a/config/dompdf.php b/config/dompdf.php
new file mode 100644
index 0000000..8ad2022
--- /dev/null
+++ b/config/dompdf.php
@@ -0,0 +1,284 @@
+ false, // Throw an Exception on warnings from dompdf
+
+ 'public_path' => null, // Override the public path if needed
+
+ /*
+ * Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £.
+ */
+ 'convert_entities' => true,
+
+ 'options' => array(
+ /**
+ * The location of the DOMPDF font directory
+ *
+ * The location of the directory where DOMPDF will store fonts and font metrics
+ * Note: This directory must exist and be writable by the webserver process.
+ * *Please note the trailing slash.*
+ *
+ * Notes regarding fonts:
+ * Additional .afm font metrics can be added by executing load_font.php from command line.
+ *
+ * Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must
+ * be embedded in the pdf file or the PDF may not display correctly. This can significantly
+ * increase file size unless font subsetting is enabled. Before embedding a font please
+ * review your rights under the font license.
+ *
+ * Any font specification in the source HTML is translated to the closest font available
+ * in the font directory.
+ *
+ * The pdf standard "Base 14 fonts" are:
+ * Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
+ * Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
+ * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
+ * Symbol, ZapfDingbats.
+ */
+ "font_dir" => storage_path('fonts'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
+
+ /**
+ * The location of the DOMPDF font cache directory
+ *
+ * This directory contains the cached font metrics for the fonts used by DOMPDF.
+ * This directory can be the same as DOMPDF_FONT_DIR
+ *
+ * Note: This directory must exist and be writable by the webserver process.
+ */
+ "font_cache" => storage_path('fonts'),
+
+ /**
+ * The location of a temporary directory.
+ *
+ * The directory specified must be writeable by the webserver process.
+ * The temporary directory is required to download remote images and when
+ * using the PFDLib back end.
+ */
+ "temp_dir" => sys_get_temp_dir(),
+
+ /**
+ * ==== IMPORTANT ====
+ *
+ * dompdf's "chroot": Prevents dompdf from accessing system files or other
+ * files on the webserver. All local files opened by dompdf must be in a
+ * subdirectory of this directory. DO NOT set it to '/' since this could
+ * allow an attacker to use dompdf to read any files on the server. This
+ * should be an absolute path.
+ * This is only checked on command line call by dompdf.php, but not by
+ * direct class use like:
+ * $dompdf = new DOMPDF(); $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
+ */
+ "chroot" => realpath(base_path()),
+
+ /**
+ * Protocol whitelist
+ *
+ * Protocols and PHP wrappers allowed in URIs, and the validation rules
+ * that determine if a resouce may be loaded. Full support is not guaranteed
+ * for the protocols/wrappers specified
+ * by this array.
+ *
+ * @var array
+ */
+ 'allowed_protocols' => [
+ "file://" => ["rules" => []],
+ "http://" => ["rules" => []],
+ "https://" => ["rules" => []]
+ ],
+
+ /**
+ * @var string
+ */
+ 'log_output_file' => null,
+
+ /**
+ * Whether to enable font subsetting or not.
+ */
+ "enable_font_subsetting" => false,
+
+ /**
+ * The PDF rendering backend to use
+ *
+ * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
+ * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
+ * fall back on CPDF. 'GD' renders PDFs to graphic files. {@link
+ * Canvas_Factory} ultimately determines which rendering class to instantiate
+ * based on this setting.
+ *
+ * Both PDFLib & CPDF rendering backends provide sufficient rendering
+ * capabilities for dompdf, however additional features (e.g. object,
+ * image and font support, etc.) differ between backends. Please see
+ * {@link PDFLib_Adapter} for more information on the PDFLib backend
+ * and {@link CPDF_Adapter} and lib/class.pdf.php for more information
+ * on CPDF. Also see the documentation for each backend at the links
+ * below.
+ *
+ * The GD rendering backend is a little different than PDFLib and
+ * CPDF. Several features of CPDF and PDFLib are not supported or do
+ * not make any sense when creating image files. For example,
+ * multiple pages are not supported, nor are PDF 'objects'. Have a
+ * look at {@link GD_Adapter} for more information. GD support is
+ * experimental, so use it at your own risk.
+ *
+ * @link http://www.pdflib.com
+ * @link http://www.ros.co.nz/pdf
+ * @link http://www.php.net/image
+ */
+ "pdf_backend" => "CPDF",
+
+ /**
+ * PDFlib license key
+ *
+ * If you are using a licensed, commercial version of PDFlib, specify
+ * your license key here. If you are using PDFlib-Lite or are evaluating
+ * the commercial version of PDFlib, comment out this setting.
+ *
+ * @link http://www.pdflib.com
+ *
+ * If pdflib present in web server and auto or selected explicitely above,
+ * a real license code must exist!
+ */
+ //"DOMPDF_PDFLIB_LICENSE" => "your license key here",
+
+ /**
+ * html target media view which should be rendered into pdf.
+ * List of types and parsing rules for future extensions:
+ * http://www.w3.org/TR/REC-html40/types.html
+ * screen, tty, tv, projection, handheld, print, braille, aural, all
+ * Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
+ * Note, even though the generated pdf file is intended for print output,
+ * the desired content might be different (e.g. screen or projection view of html file).
+ * Therefore allow specification of content here.
+ */
+ "default_media_type" => "screen",
+
+ /**
+ * The default paper size.
+ *
+ * North America standard is "letter"; other countries generally "a4"
+ *
+ * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
+ */
+ "default_paper_size" => "a4",
+
+ /**
+ * The default paper orientation.
+ *
+ * The orientation of the page (portrait or landscape).
+ *
+ * @var string
+ */
+ 'default_paper_orientation' => "portrait",
+
+ /**
+ * The default font family
+ *
+ * Used if no suitable fonts can be found. This must exist in the font folder.
+ * @var string
+ */
+ "default_font" => "serif",
+
+ /**
+ * Image DPI setting
+ *
+ * This setting determines the default DPI setting for images and fonts. The
+ * DPI may be overridden for inline images by explictly setting the
+ * image's width & height style attributes (i.e. if the image's native
+ * width is 600 pixels and you specify the image's width as 72 points,
+ * the image will have a DPI of 600 in the rendered PDF. The DPI of
+ * background images can not be overridden and is controlled entirely
+ * via this parameter.
+ *
+ * For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
+ * If a size in html is given as px (or without unit as image size),
+ * this tells the corresponding size in pt.
+ * This adjusts the relative sizes to be similar to the rendering of the
+ * html page in a reference browser.
+ *
+ * In pdf, always 1 pt = 1/72 inch
+ *
+ * Rendering resolution of various browsers in px per inch:
+ * Windows Firefox and Internet Explorer:
+ * SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
+ * Linux Firefox:
+ * about:config *resolution: Default:96
+ * (xorg screen dimension in mm and Desktop font dpi settings are ignored)
+ *
+ * Take care about extra font/image zoom factor of browser.
+ *
+ * In images,
size in pixel attribute, img css style, are overriding
+ * the real image dimension in px for rendering.
+ *
+ * @var int
+ */
+ "dpi" => 96,
+
+ /**
+ * Enable inline PHP
+ *
+ * If this setting is set to true then DOMPDF will automatically evaluate
+ * inline PHP contained within tags.
+ *
+ * Enabling this for documents you do not trust (e.g. arbitrary remote html
+ * pages) is a security risk. Set this option to false if you wish to process
+ * untrusted documents.
+ *
+ * @var bool
+ */
+ "enable_php" => false,
+
+ /**
+ * Enable inline Javascript
+ *
+ * If this setting is set to true then DOMPDF will automatically insert
+ * JavaScript code contained within tags.
+ *
+ * @var bool
+ */
+ "enable_javascript" => true,
+
+ /**
+ * Enable remote file access
+ *
+ * If this setting is set to true, DOMPDF will access remote sites for
+ * images and CSS files as required.
+ * This is required for part of test case www/test/image_variants.html through www/examples.php
+ *
+ * Attention!
+ * This can be a security risk, in particular in combination with DOMPDF_ENABLE_PHP and
+ * allowing remote access to dompdf.php or on allowing remote html code to be passed to
+ * $dompdf = new DOMPDF(, $dompdf->load_html(...,
+ * This allows anonymous users to download legally doubtful internet content which on
+ * tracing back appears to being downloaded by your server, or allows malicious php code
+ * in remote html pages to be executed by your server with your account privileges.
+ *
+ * @var bool
+ */
+ "enable_remote" => true,
+
+ /**
+ * A ratio applied to the fonts height to be more like browsers' line height
+ */
+ "font_height_ratio" => 1.1,
+
+ /**
+ * Use the HTML5 Lib parser
+ *
+ * @deprecated This feature is now always on in dompdf 2.x
+ * @var bool
+ */
+ "enable_html5_parser" => true,
+ ),
+
+
+);
diff --git a/resources/views/Admin/index.blade.php b/resources/views/Admin/index.blade.php
index ecb36a2..81be7ce 100644
--- a/resources/views/Admin/index.blade.php
+++ b/resources/views/Admin/index.blade.php
@@ -162,9 +162,9 @@
diff --git a/resources/views/User/transaction/Pembeli/detail-transaction.blade.php b/resources/views/User/transaction/Pembeli/detail-transaction.blade.php
index 847bbe7..fce4496 100644
--- a/resources/views/User/transaction/Pembeli/detail-transaction.blade.php
+++ b/resources/views/User/transaction/Pembeli/detail-transaction.blade.php
@@ -106,7 +106,8 @@
Rangkuman Transaksi
Semua barang yang didaftarkan dalam transaksi.
-
+
# |
Nama Barang |
@@ -117,17 +118,19 @@
1 |
{{ $transaction->nama_barang }} |
- {{ $transaction->harga_barang }} |
+
+ Rp.{{ number_format($transaction->harga_barang, 2, ',', '.') }}
+ |
{{ $transaction->jumlah_barang }} |
- {{ $transaction->harga_barang * $transaction->jumlah_barang }}
+ Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }}
|
-
Payment Method
+
Metode Pembayaran
@if ($transaction->metode_pembayaran != null)
Subtotal
Rp
- {{ number_format($transaction->total_harga, 2, ',', '.') }}
+ Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }}
Biaya Admin
- Rp
- {{ number_format($transaction->total_keuntungan, 2, ',', '.') }}
+ Rp.{{ number_format($transaction->total_keuntungan, 2, ',', '.') }}
Total
- Rp {{ number_format($transaction->total_bayar, 2, ',', '.') }}
+ Rp.{{ number_format($transaction->total_bayar, 2, ',', '.') }}
diff --git a/resources/views/invoice/export-invoice.blade.php b/resources/views/invoice/export-invoice.blade.php
new file mode 100644
index 0000000..8a5978f
--- /dev/null
+++ b/resources/views/invoice/export-invoice.blade.php
@@ -0,0 +1,330 @@
+
+
+
+
+
+
+
+
REKBER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Invoice
+
Order #{{ $transaction->id }}
+
+
+
+
+
+ Pembeli:
+ {{ ucwords(strtolower($transaction->data_pembeli->nama_depan . ' ' . $transaction->data_pembeli->nama_belakang)) }}
+ {{ ucwords(strtolower($transaction->data_pembeli->alamat)) }}
+ {{ ucwords(strtolower($transaction->data_pembeli->getVillageName() . ', ' . $transaction->data_pembeli->getDistrictName())) }}
+ {{ ucwords(strtolower($transaction->data_pembeli->getCityName() . ', ' . $transaction->data_pembeli->getProvinceName())) }}
+
+
+
+
+ Penjual:
+ {{ ucwords(strtolower($transaction->data_penjual->nama_depan . ' ' . $transaction->data_penjual->nama_belakang)) }}
+ {{ ucwords(strtolower($transaction->data_penjual->alamat)) }}
+ {{ ucwords(strtolower($transaction->data_penjual->getVillageName() . ', ' . $transaction->data_penjual->getDistrictName())) }}
+ {{ ucwords(strtolower($transaction->data_penjual->getCityName() . ', ' . $transaction->data_penjual->getProvinceName())) }}
+
+
+
+
+
+
+ Payment Method:
+ Visa ending **** 4242
+ npannisa@gmail.com
+
+
+
+
+ Tanggal Transaksi:
+ {{ $transaction->created_at->format('d M Y, g:i') }}
+
+
+
+
+
+
+
+
+
Rangkuman Transaksi
+
Semua barang yang didaftarkan dalam transaksi.
+
+
+
+ # |
+ Nama Barang |
+ Harga |
+ Jumlah |
+ Total |
+
+
+ 1 |
+ {{ $transaction->nama_barang }} |
+
+ Rp.{{ number_format($transaction->harga_barang, 2, ',', '.') }}
+ |
+ {{ $transaction->jumlah_barang }} |
+
+ Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }}
+ |
+
+
+
+
+
+
Metode Pembayaran
+
+ @if ($transaction->metode_pembayaran != null)
+
 }})
+ @endif
+
+
+
+
+
Subtotal
+
+ Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }}
+
+
+
+
Biaya Admin
+
+ Rp.{{ number_format($transaction->total_keuntungan, 2, ',', '.') }}
+
+
+
+
+
Total
+
+ Rp.{{ number_format($transaction->total_bayar, 2, ',', '.') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/views/invoice/invoice-transaction.blade.php b/resources/views/invoice/invoice-transaction.blade.php
index e343d1f..0f5fc35 100644
--- a/resources/views/invoice/invoice-transaction.blade.php
+++ b/resources/views/invoice/invoice-transaction.blade.php
@@ -2,15 +2,6 @@
@section('content')
-
-
@@ -18,26 +9,26 @@
Invoice
-
Order #NVI-1234
+
Order #{{ $transaction->id }}
- Billed To:
- npannisa
- 1234 Main
- Apt. 4B
- Depok City, Indonesia
+ Pembeli:
+ {{ ucwords(strtolower($transaction->data_pembeli->nama_depan . ' ' . $transaction->data_pembeli->nama_belakang)) }}
+ {{ ucwords(strtolower($transaction->data_pembeli->alamat)) }}
+ {{ ucwords(strtolower($transaction->data_pembeli->getVillageName() . ', ' . $transaction->data_pembeli->getDistrictName())) }}
+ {{ ucwords(strtolower($transaction->data_pembeli->getCityName() . ', ' . $transaction->data_pembeli->getProvinceName())) }}
- Shipped To:
- Jilhan Haura
- 12345 Main
- Apt. 5B
- Bogor Barat, Indonesia
+ Penjual:
+ {{ ucwords(strtolower($transaction->data_penjual->nama_depan . ' ' . $transaction->data_penjual->nama_belakang)) }}
+ {{ ucwords(strtolower($transaction->data_penjual->alamat)) }}
+ {{ ucwords(strtolower($transaction->data_penjual->getVillageName() . ', ' . $transaction->data_penjual->getDistrictName())) }}
+ {{ ucwords(strtolower($transaction->data_penjual->getCityName() . ', ' . $transaction->data_penjual->getProvinceName())) }}
@@ -51,8 +42,8 @@
- Order Date:
- September 19, 2023
+ Tanggal Transaksi:
+ {{ $transaction->created_at->format('d M Y, g:i') }}
@@ -61,51 +52,59 @@
-
Order Summary
-
All items here cannot be deleted.
+
Rangkuman Transaksi
+
Semua barang yang didaftarkan dalam transaksi.
-
+
# |
- Item |
- Price |
- Quantity |
- Totals |
+ Nama Barang |
+ Harga |
+ Jumlah |
+ Total |
1 |
- Ayam Warna Warni |
- Rp. 50.000.000 |
- 1 |
- Rp. 50.000.000 |
+ {{ $transaction->nama_barang }} |
+
+ Rp.{{ number_format($transaction->harga_barang, 2, ',', '.') }} |
+ {{ $transaction->jumlah_barang }} |
+
+ Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }}
+ |
-
Payment Method
-
The payment method that we provide is to make it easier for
- you to pay invoices.
+
Metode Pembayaran
-

-

-

-

+ @if ($transaction->metode_pembayaran != null)
+
 }})
+ @endif
Subtotal
-
Rp.670.000.000
+
+ Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }}
+
-
Shipping
-
Rp.15.000
+
Biaya Admin
+
+ Rp.{{ number_format($transaction->total_keuntungan, 2, ',', '.') }}
+
Total
-
Rp.6715.000.000
+
+ Rp.{{ number_format($transaction->total_bayar, 2, ',', '.') }}
+
@@ -114,10 +113,21 @@
-
+
+
@endsection
diff --git a/routes/web.php b/routes/web.php
index da69968..7ecead5 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -92,7 +92,7 @@ Route::middleware(['auth'])->group(function(){
Route::prefix('invoice')->group(function(){
Route::controller(InvoiceController::class)->group(function(){
- Route::get('/{id}','getInvoice')->name('invoice.get');
+ Route::get('invoice/{id}','getInvoice')->name('invoice.get');
Route::get('export-invoice','exportInvoice')->name('invoice.export');
});
});