diff --git a/app/Http/Controllers/Admin/AdminRefundController.php b/app/Http/Controllers/Admin/AdminRefundController.php
index f3a3cc1..cbf3880 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,66 @@ 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{
+ Log::error($result['status_message']);
return response()->json([
'status' => false,
'message' => 'Refund gagal dilakukan',
- // 'refundMidtrans' => $refundMidtrans
]);
}
+
+
}
public function denyRefund(Request $request)
@@ -144,12 +166,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..6940a39 100644
--- a/app/Http/Controllers/Login/LoginController.php
+++ b/app/Http/Controllers/Login/LoginController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Login;
use App\Http\Controllers\Controller;
use App\Mail\verificationMail;
+use App\Models\Transaction;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
@@ -240,7 +241,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,
@@ -405,4 +406,18 @@ class LoginController extends Controller
}
//OCR
}
+
+ public function email(){
+ $verificationEmail = [
+ 'email' => 'Halo',
+ 'code' => 'kode'
+ ];
+ return view('email.verification-email',compact('verificationEmail'));
+ }
+
+ public function invoice(){
+ return view('invoice.export-invoice', [
+ 'transaction' => Transaction::findOrFail('80d9b19b-ba17-4aea-8cad-c3b4661d33bc'),
+ ]);
+ }
}
diff --git a/app/Http/Controllers/RefundDescriptionController.php b/app/Http/Controllers/RefundDescriptionController.php
deleted file mode 100644
index f7a69c5..0000000
--- a/app/Http/Controllers/RefundDescriptionController.php
+++ /dev/null
@@ -1,65 +0,0 @@
-format('F');
+ $tahun = $now->year;
+ $persentase_keuntungan = Setting::where('status', 'Active')
+ ->where('bulan', '=', $bulan)
+ ->where('tahun', '=', $tahun)
+ ->value('persentase');
+ if (is_null($persentase_keuntungan)) {
+ $persentase_keuntungan = Setting::where('status', 'Active')
+ ->latest()
+ ->value('persentase');
+ }
+ return view('user.transaction.pembeli.new-transaction', [
+ 'persentase_keuntungan' => $persentase_keuntungan,
+ ]);
+ }
+
+ /**
+ * Store a newly created resource in storage.
+ */
+
+ public function store(Request $request)
+ {
+ $pembeli = auth()->user()->email;
+ $penjual = $request->email_penjual;
+ $nama_barang = $request->nama_barang;
+ $satuan_barang = $request->satuan_barang;
+ $deskripsi_transaksi = $request->deskripsi;
+ $harga_barang = $request->harga_barang;
+ $jumlah_barang = $request->jumlah_barang;
+
+ $nama_depan_pembeli = auth()->user()->nama_depan;
+ $nama_belakang_pembeli = auth()->user()->nama_belakang;
+ $nohp_pembeli = auth()->user()->nohp;
+ $nama_penjual = User::where('email', $penjual)->value('nama_depan');
+ $bank_penjual = User::where('email', $penjual)->value('nama_bank');
+ $no_rek_penjual = User::where('email', $penjual)->value('no_rek');
+
+ if ($bank_penjual == '' && $no_rek_penjual == '') {
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Penjual belum memiliki/memasukan nomor rek bank',
+ ]);
+ }
+
+ $alamat = ucwords(strtolower(auth()->user()->alamat));
+
+ $now = Carbon::now();
+
+ $persentase_keuntungan = $request->persentase_keuntungan;
+
+ $total_harga = $request->total_harga;
+ $total_keuntungan = $request->total_keuntungan;
+ $total_bayar = $request->total_bayar;
+
+ $batas_pembayaran = $now->addDays(1)->toTimeString();
+ $batas_konfirmasi_transaksi = $now->addDays(2)->toDateTimeString();
+ $batas_pengiriman_barang_awal = $now->addDays(3)->toDateTimeString();
+ $batas_pengiriman_barang_akhir = $now->addDays(4)->toDateTimeString();
+
+ $status = 'created';
+
+ try {
+ DB::beginTransaction();
+
+ $query = Transaction::create([
+ 'pembeli' => $pembeli,
+ 'penjual' => $penjual,
+ 'nama_barang' => $nama_barang,
+ 'deskripsi_transaksi' => $deskripsi_transaksi,
+ 'satuan_barang' => $satuan_barang,
+ 'harga_barang' => $harga_barang,
+ 'jumlah_barang' => $jumlah_barang,
+ 'persentase_keuntungan' => $persentase_keuntungan,
+ 'total_keuntungan' => $total_keuntungan,
+ 'total_harga' => $total_harga,
+ 'total_bayar' => $total_bayar,
+ 'nama_bank_penjual' => $bank_penjual,
+ 'no_rek_penjual' => $no_rek_penjual,
+ 'status_transaksi' => $status,
+ 'batas_pembayaran' => $batas_pembayaran,
+ 'batas_konfirmasi_transaksi' => $batas_konfirmasi_transaksi,
+ 'batas_pengiriman_barang_awal' => $batas_pengiriman_barang_awal,
+ 'batas_pengiriman_barang_akhir' => $batas_pengiriman_barang_akhir,
+ ]);
+
+ $params = [
+ 'transaction_details' => [
+ 'order_id' => $query->id,
+ 'gross_amount' => $total_bayar,
+ ],
+ 'item_details' => [
+ [
+ 'id' => $nama_barang . time(),
+ 'price' => $harga_barang,
+ 'quantity' => $jumlah_barang,
+ 'name' => $nama_barang,
+ ],
+ [
+ 'id' => 'BA01',
+ 'price' => $total_keuntungan,
+ 'quantity' => 1,
+ 'name' => 'Biaya Admin',
+ ],
+ ],
+ 'customer_details' => [
+ 'firts_name' => $nama_depan_pembeli,
+ 'last_name' => $nama_belakang_pembeli,
+ 'email' => $pembeli,
+ 'phone' => $nohp_pembeli,
+ 'billing' => [
+ 'first_name' => $nama_depan_pembeli,
+ 'last_name' => $nama_belakang_pembeli,
+ 'email' => $pembeli,
+ 'phone' => $nohp_pembeli,
+ 'address' => $alamat,
+ 'city' => auth()->user()->village->district->city->name,
+ 'country_code' => 'IDN',
+ ],
+ ],
+ 'callbacks' => [
+ 'finish' => route('user-pembeli.index'),
+ ],
+ 'enabled_payments' => ['credit_card', 'shopeepay', 'gopay', 'other_qris'],
+ ];
+
+ $client = new Client([
+ 'verify' => false,
+ ]);
+
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
+
+ $response = $client->request('POST', 'https://app.sandbox.midtrans.com/snap/v1/transactions', [
+ 'body' => json_encode($params),
+ 'headers' => [
+ 'accept' => 'application/json',
+ 'authorization' => 'Basic ' . $auth,
+ 'content-type' => 'application/json',
+ ],
+ ]);
+
+ $result = json_decode($response->getBody(), true);
+
+ Transaction::where('id', $query->id)->update([
+ 'token' => $result['token'],
+ ]);
+
+ $contact = Contact::where('pemilik_kontak', $pembeli)
+ ->where('relasi_kontak', $penjual)
+ ->count();
+
+ if ($contact == 0) {
+ Contact::create([
+ 'pemilik_kontak' => $pembeli,
+ 'relasi_kontak' => $penjual,
+ ]);
+ }
+
+ TransactionDescription::create([
+ 'transaction_id' => $query->id,
+ 'status' => $status,
+ 'user' => $pembeli,
+ 'judul' => 'fa fa-plus',
+ 'background' => 'bg-buyer',
+ 'deskripsi' => $nama_depan_pembeli . ' telah membuat transaksi baru dengan ' . $nama_penjual,
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Berhasil menambahkan transaksi. Silahkan lakukan pembayaran.',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Gagal menambahkan transaksi.',
+ ]);
+ }
+ }
+
+ public function finishTransaction(Request $request)
+ {
+ try {
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->id)->update([
+ 'status_transaksi' => 'finished',
+ 'status_pembayaran' => 'settlement',
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'finished',
+ 'background' => 'bg-buyer',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fas fa-check',
+ 'deskripsi' => 'Pesanan telah diselesaikan oleh ' . auth()->user()->nama_depan . '.',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Pesanan telah diselesaikan oleh ' . auth()->user()->nama_depan . '.',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Gagal update status karena kesalahan server.',
+ ]);
+ }
+ }
+
+ public function payTransaction(Request $request)
+ {
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
+
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
+
+ $result = json_decode($response->body(), true);
+
+ $code = substr($result['status_code'], 0, 1);
+
+ try {
+ DB::beginTransaction();
+
+ if ($code == '4') {
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi error di server.',
+ 'data' => $result,
+ ]);
+ } else {
+ if ($result['transaction_status'] == 'settlement') {
+ $transaction = 'success';
+ } elseif ($result['transaction_status'] == 'capture') {
+ if ($result['fraud_status'] == 'accept') {
+ $transaction = 'success';
+ } elseif ($result['fraud_status'] == 'challenge') {
+ $transaction = 'challenge';
+ }
+ } else {
+ $transaction = 'failure';
+ }
+
+ Transaction::where('id', $request->id)->update([
+ 'metode_pembayaran' => $result['payment_type'],
+ 'tanggal_transaksi' => $result['transaction_time'],
+ 'status_transaksi' => $transaction,
+ 'status_pembayaran' => $result['transaction_status'],
+ 'fraud_status' => $result['fraud_status'],
+ 'signature_key' => $result['signature_key'],
+ ]);
+
+ if ($transaction == 'success') {
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'success',
+ 'background' => 'bg-buyer',
+ 'judul' => 'fas fa-money-bill',
+ 'deskripsi' => auth()->user()->nama_depan . ' telah sukses melakukan pembayaran. Transaksi diteruskan ke penjual.',
+ 'user' => auth()->user()->email,
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Pembayaran sukses',
+ ]);
+ } elseif ($transaction == 'challenge') {
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'challenge',
+ 'background' => 'bg-primary',
+ 'judul' => 'fas fa-clock',
+ 'deskripsi' => 'Transaksi ' . auth()->user()->email . ' terindikasi masalah, tunggu sesaat hingga admin menyetujui pembayaran.',
+ 'user' => 'admin@example.net',
+ 'keterangan' => $result['status_message'],
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Pembayaran ditunda hingga disetujui oleh admin.',
+ ]);
+ } else {
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'failure',
+ 'background' => 'bg-primary',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => 'Terjadi kegagalan pembayaran.',
+ 'user' => 'admin@example.net',
+ 'keterangan' => $result['status_message'],
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Transaksi pembayaran gagal',
+ ]);
+ }
+ }
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Transaksi pembayaran gagal.',
+ ]);
+ }
+
+ return response()->json();
+ }
+
+ public function cancelTransaction(Request $request)
+ {
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
+
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->post('https://api.sandbox.midtrans.com/v2/' . $request->id . '/cancel');
+
+ $result = json_decode($response->body(), true);
+
+ if (in_array($result['status_code'], ['412','401'])) {
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Transaksi gagal.',
+ 'data' => $result
+ ]);
+ } else {
+ try {
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->id)->update([
+ 'status_transaksi' => 'failure',
+ 'status_pembayaran' => 'cancel'
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'cancel',
+ 'background' => 'bg-buyer',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => auth()->user()->nama_depan . ' telah membatalkan transaksi.',
+ 'user' => auth()->user()->email,
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Transaksi berhasil dibatalkan',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Transaksi gagal dibatalkan',
+ ]);
+ }
+ }
+ }
+
+ public function pendingTransaction(Request $request)
+ {
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
+
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
+
+ $result = json_decode($response->body(), true);
+
+ try {
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->id)->update([
+ 'status_pembayaran' => $result['transaction_status'],
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Pembayaran di-pending, silahkan masuk lagi dan bayar secepat mungkin.',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi error di bagian server.',
+ ]);
+ }
+ }
+
+ public function complaintTransaction($id)
+ {
+ return view('user.refund.new-refund', compact('id'));
+ }
+
+ public function onErrorTransaction(Request $request)
+ {
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
+
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
+
+ $result = json_decode($response->body(), true);
+
+ try {
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->id)->update([
+ 'status_pembayaran' => $result['transaction_status'],
+ ]);
+
+ if ($result['transaction_status'] == 'expire') {
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'cancel',
+ 'background' => 'bg-buyer',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => 'Pembayaran sudah expire',
+ 'user' => 'admin@example.net',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Pembayaran sudah expire, silahkan buat transaksi baru.',
+ ]);
+ } elseif ($result['transaction'] == 'failure') {
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'failure',
+ 'background' => 'bg-buyer',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => auth()->user()->nama_depan . ' telah membatalkan transaksi.',
+ 'user' => 'admin@example.net',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi kesalahan di server saat pembayaran.',
+ 'data' => $result,
+ ]);
+ } else {
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => $result['transaction_status'],
+ 'background' => 'bg-primary',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => 'Status tidak diketahui',
+ 'user' => 'admin@example.net',
+ 'keterangan' => $result['status_message'],
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Terjadi kesalahan di server',
+ 'data' => $result,
+ ]);
+ }
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi error di bagian server.',
+ ]);
+ }
+ }
+
+ public function onCloseTransaction(Request $request)
+ {
+ $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
+
+ $response = Http::withOptions([
+ 'verify' => false,
+ ])
+ ->withHeaders([
+ 'Content-Type' => 'application/json',
+ 'Authorization' => "Basic $auth",
+ ])
+ ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
+
+ $result = json_decode($response->body(), true);
+
+ $status = $result['transaction_status'] == null ? '' : $result['transaction_status'];
+
+ if ($status == '') {
+ return response()->json([
+ 'status' => true,
+ 'message' => 'On Close',
+ ]);
+ } else {
+ try {
+ DB::beginTransaction();
+
+ if ($result['transaction_status'] == 'expire') {
+ Transaction::where('id', $request->id)->update([
+ 'status_pembayaran' => $result['transaction_status'],
+ 'status_transaksi' => 'failure',
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'cancel',
+ 'background' => 'bg-buyer',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => 'Pembayaran sudah expire',
+ 'user' => 'admin@example.net',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Pembayaran sudah expire, silahkan buat transaksi baru.',
+ ]);
+ } elseif ($result['transaction'] == 'failure') {
+ Transaction::where('id', $request->id)->update([
+ 'status_pembayaran' => $result['transaction_status'],
+ 'status_transaksi' => 'failure',
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'failure',
+ 'background' => 'bg-buyer',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => auth()->user()->nama_depan . ' telah membatalkan transaksi.',
+ 'user' => 'admin@example.net',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi kesalahan di server saat pembayaran.',
+ ]);
+ } else {
+ Transaction::where('id', $request->id)->update([
+ 'status_pembayaran' => $result['transaction_status'],
+ 'status_transaksi' => 'failure',
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => $result['transaction_status'],
+ 'background' => 'bg-primary',
+ 'judul' => 'fas fa-exclamation',
+ 'deskripsi' => 'Status tidak diketahui.',
+ 'user' => 'admin@example.net',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Terjadi kesalahan di server',
+ ]);
+ }
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Terjadi error di bagian server.',
+ ]);
+ }
+ }
+ }
+
+ public function listPembeli(Request $request)
+ {
+ try{
+ $subQuery = Transaction::join('users','transactions.penjual','=','users.email')
+ ->where('transactions.pembeli',auth()->user()->email)
+ ->select(
+ 'transactions.id',
+ DB::raw("CONCAT(users.nama_depan,' ',users.nama_belakang) as nama_penjual"),
+ 'transactions.nama_barang',
+ 'transactions.total_harga',
+ 'transactions.created_at',
+ 'transactions.status_transaksi',
+ 'transactions.token'
+ );
+
+ if($request->has('search') && !empty($request->search['value'])){
+ $searchPembeli = $request->search['value'];
+ if(!is_numeric($searchPembeli)){
+ $subQuery->where(function($a) use ($searchPembeli){
+ $a->whereRaw("LOWER(CONCAT(users.nama_depan,' ',users.nama_belakang)) LIKE ?",['%'.strtolower($searchPembeli).'%'])
+ ->orWhereRaw('LOWER(transactions.nama_barang) LIKE ?',['%'.strtolower($searchPembeli).'%'])
+ ->orWhereRaw('LOWER(transactions.status_transaksi) LIKE ?',['%'.strtolower($searchPembeli).'%']);
+ });
+ }else{
+ $subQuery->where(function($a) use ($searchPembeli){
+ $a->where('transactions.total_harga','=',$searchPembeli);
+ });
+ }
+ }
+
+ $queryPembeli = Transaction::from(DB::raw("({$subQuery->toSql()}) as tmp"))
+ ->mergeBindings($subQuery->getQuery()) // Menggabungkan binding parameters
+ ->select('*')
+ ->get();
+
+ if ($request->ajax()) {
+ return DataTables::of($queryPembeli)
+ ->addIndexColumn()
+ ->addColumn('action', function ($row) {
+ $url = route('user-transaction.show', ['id' => $row->id]);
+ $invoice = route('invoice.get',['id' => $row->id]);
+ $html_code = '
+
+
+ ....
+
+
+
+
';
+ return $html_code;
+ })
+ ->rawColumns(['action'])
+ ->make(true);
+ }
+ }catch(Throwable $e){
+ Log::error($e->getMessage());
+
+ return response()->json(['success' => false, 'message' => 'Terjadi Kesalahan pada sisi server']);
+ }
+
+ }
+}
diff --git a/app/Http/Controllers/User/PenjualController.php b/app/Http/Controllers/User/PenjualController.php
new file mode 100644
index 0000000..ba341f5
--- /dev/null
+++ b/app/Http/Controllers/User/PenjualController.php
@@ -0,0 +1,331 @@
+where('transactions.penjual',auth()->user()->email)
+ ->select(
+ 'transactions.id',
+ DB::raw("CONCAT(users.nama_depan,' ',users.nama_belakang) as nama_pembeli"),
+ 'transactions.nama_barang',
+ 'transactions.total_harga',
+ 'transactions.created_at',
+ 'transactions.status_transaksi',
+ );
+
+ if($request->has('search') && !empty($request->search['value'])){
+ $searchPenjual = $request->search['value'];
+ if(!is_numeric($searchPenjual)){
+ $subQuery->where(function($a) use ($searchPenjual){
+ $a->whereRaw("LOWER(CONCAT(users.nama_depan,' ',users.nama_belakang)) LIKE ?",['%'.strtolower($searchPenjual).'%'])
+ ->orWhereRaw('LOWER(transactions.nama_barang) LIKE ?',['%'.strtolower($searchPenjual).'%'])
+ ->orWhereRaw('LOWER(transactions.status_transaksi) LIKE ?',['%'.strtolower($searchPenjual).'%']);
+ });
+ }else{
+ $subQuery->where(function($a) use ($searchPenjual){
+ $a->whereDay('transactions.created_at', '=', $searchPenjual)
+ ->orWhereMonth('transactions.created_at', '=', $searchPenjual)
+ ->orWhereYear('transactions.created_at', '=', $searchPenjual)
+ ->orWhere('transactions.total_harga', '=', $searchPenjual);
+ });
+ }
+ }
+
+ $queryPenjual = Transaction::from(DB::raw("({$subQuery->toSql()}) as tmp"))
+ ->mergeBindings($subQuery->getQuery()) // Menggabungkan binding parameters
+ ->select('*')
+ ->get();
+
+ if ($request->ajax()) {
+ return DataTables::of($queryPenjual)
+ ->addIndexColumn()
+ ->addColumn('action', function ($row) {
+ $url = route('user-transaction.show', ['id' => $row->id]);
+ $invoice = route('invoice.get',['id' => $row->id]);
+ $html_code = '
+
+
+ ....
+
+
+
+
';
+ return $html_code;
+ })
+ ->rawColumns(['action'])
+ ->make(true);
+ }
+ }catch(Throwable $e){
+ Log::error($e->getMessage());
+
+ return response()->json(['success' => false, 'message' => 'Terjadi Kesalahan pada sisi server']);
+ }
+ }
+
+ public function acceptTransaction(Request $request)
+ {
+ try {
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->id)->update([
+ 'status_transaksi' => 'process',
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'process',
+ 'background' => 'bg-seller',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fas fa-handshake',
+ 'deskripsi' => 'Transaksi telah diterima oleh ' . auth()->user()->nama_depan,
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Transaksi telah diterima. Siapkan pesanan untuk dikirim ke penjual.',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Gagal update status karena kesalahan server.',
+ ]);
+ }
+ }
+
+ public function denyTransaction(Request $request){
+
+ $transaction = Transaction::where('id', $request->id)->first();
+ $refund = Refund::create([
+ 'transaction_id' => $request->id,
+ 'total' => $transaction->total_bayar,
+ 'due_date' => now(),
+ 'status' => 'refund',
+ 'complaint' => $request->complaint
+ ]);
+
+ // $params = [
+ // 'refund_key' => $request->id . '-ref1',
+ // 'amount' => $refund->total,
+ // 'reason' => $refund->complaint,
+ // ];
+
+ // $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
+
+ // $response = Http::withOptions([
+ // 'verify' => false,
+ // ])
+ // ->withHeaders([
+ // 'Content-Type' => 'application/json',
+ // 'Authorization' => "Basic $auth",
+ // ])
+ // ->post('https://api.sandbox.midtrans.com/v2/'.$request->id.'/refund', $params);
+
+ // $result = json_decode($response->body(), true);
+ // $code = $result['status_code'];
+ $code = '200';
+
+ if($code == '200'){
+ try{
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->id)->update([
+
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'refund',
+ 'background' => 'bg-seller',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fas fa-handshake',
+ 'deskripsi' => 'Transaksi ditolak '.auth()->user()->nama_depan.', uang akan dikembalikan ke pembeli. ',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Transaksi telah ditolak. Uang akan dikirimkan ke pembeli.',
+ ]);
+ }catch(Throwable $e){
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Gagal update status karena kesalahan server.',
+ ]);
+ }
+ }else{
+ // Log::error($result['status_message']);
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Transaksi gagal',
+ ]);
+ }
+ }
+
+ public function sendingOrder(Request $request)
+ {
+ try {
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->id)->update([
+ 'status_transaksi' => 'sending',
+ ]);
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->id,
+ 'status' => 'sending',
+ 'background' => 'bg-seller',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fas fa-truck-moving',
+ 'deskripsi' => 'Pesanan telah dikirim oleh ' . auth()->user()->nama_depan . ' dan sedang dalam perjalanan menuju pembeli.',
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Pesanan sedang dikirim dan menuju pembeli.',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Gagal update status karena kesalahan server.',
+ ]);
+ }
+ }
+
+ public function sentOrder(Request $request)
+ {
+ try {
+ DB::beginTransaction();
+
+ Transaction::where('id', $request->transaction_id)->update([
+ 'status_transaksi' => 'sent',
+ ]);
+
+ $bukti_foto = '';
+
+ if ($request->hasFile('bukti_foto')) {
+ $file = $request->file('bukti_foto');
+ $bukti_foto = time() . '.' . $file->getClientOriginalExtension();
+ $path = 'bukti-foto/' . $bukti_foto;
+
+ Storage::disk('public')->put($path, file_get_contents($file));
+ }
+
+ TransactionDescription::create([
+ 'transaction_id' => $request->transaction_id,
+ 'status' => 'sent',
+ 'background' => 'bg-seller',
+ 'user' => auth()->user()->email,
+ 'judul' => 'fas fa-check',
+ 'deskripsi' => 'Pesanan telah sampai di tempat pembeli. Keterangan: '.$request->keterangan_bukti,
+ 'bukti_foto' => $bukti_foto,
+ ]);
+
+ DB::commit();
+
+ return response()->json([
+ 'status' => true,
+ 'message' => 'Pesanan telah sampai di tempat pembeli.',
+ ]);
+ } catch (Throwable $e) {
+ DB::rollBack();
+
+ Log::error($e->getMessage());
+
+ return response()->json([
+ 'status' => false,
+ 'message' => 'Gagal update status karena kesalahan server.',
+ ]);
+ }
+
+ return response([
+ 'status' => true,
+ 'message' => 'Sukses kirim data.',
+ 'data' => $request
+ ]);
+ }
+}
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/app/Http/Controllers/User/UserTransactionController.php b/app/Http/Controllers/User/UserTransactionController.php
index 895bd08..d461a54 100644
--- a/app/Http/Controllers/User/UserTransactionController.php
+++ b/app/Http/Controllers/User/UserTransactionController.php
@@ -24,23 +24,6 @@ use Stichoza\GoogleTranslate\GoogleTranslate;
class UserTransactionController extends Controller
{
- /**
- * Display a listing of the resource.
- */
-
- public function indexPembeli()
- {
- return view('user.transaction.pembeli.index');
- }
-
- /**
- * Display a listing of the resource.
- */
- public function indexPenjual()
- {
- return view('user.transaction.penjual.index');
- }
-
public function show($id)
{
return view('user.transaction.pembeli.detail-transaction', [
@@ -51,968 +34,6 @@ class UserTransactionController extends Controller
]);
}
- /**
- * Show the form for creating a new resource.
- */
- public function create()
- {
- $now = Carbon::now();
- $bulan = $now->format('F');
- $tahun = $now->year;
- $persentase_keuntungan = Setting::where('status', 'Active')
- ->where('bulan', '=', $bulan)
- ->where('tahun', '=', $tahun)
- ->value('persentase');
- if (is_null($persentase_keuntungan)) {
- $persentase_keuntungan = Setting::where('status', 'Active')
- ->latest()
- ->value('persentase');
- }
- return view('user.transaction.pembeli.new-transaction', [
- 'persentase_keuntungan' => $persentase_keuntungan,
- ]);
- }
-
- /**
- * Store a newly created resource in storage.
- */
-
- public function store(Request $request)
- {
- $pembeli = Auth::user()->email;
- $penjual = $request->email_penjual;
- $nama_barang = $request->nama_barang;
- $satuan_barang = $request->satuan_barang;
- $deskripsi_transaksi = $request->deskripsi;
- $harga_barang = $request->harga_barang;
- $jumlah_barang = $request->jumlah_barang;
-
- $nama_depan_pembeli = Auth::user()->nama_depan;
- $nama_belakang_pembeli = Auth::user()->nama_belakang;
- $nohp_pembeli = Auth::user()->nohp;
- $nama_penjual = User::where('email', $penjual)->value('nama_depan');
- $bank_penjual = User::where('email', $penjual)->value('nama_bank');
- $no_rek_penjual = User::where('email', $penjual)->value('no_rek');
-
- if ($bank_penjual == '' && $no_rek_penjual == '') {
- return response()->json([
- 'status' => false,
- 'message' => 'Penjual belum memiliki/memasukan nomor rek bank',
- ]);
- }
-
- $alamat = ucwords(strtolower(Auth::user()->alamat));
-
- $now = Carbon::now();
-
- $persentase_keuntungan = $request->persentase_keuntungan;
-
- $total_harga = $request->total_harga;
- $total_keuntungan = $request->total_keuntungan;
- $total_bayar = $request->total_bayar;
-
- $batas_pembayaran = $now->addDays(1)->toTimeString();
- $batas_konfirmasi_transaksi = $now->addDays(2)->toDateTimeString();
- $batas_pengiriman_barang_awal = $now->addDays(3)->toDateTimeString();
- $batas_pengiriman_barang_akhir = $now->addDays(4)->toDateTimeString();
-
- $status = 'created';
-
- try {
- DB::beginTransaction();
-
- $query = Transaction::create([
- 'pembeli' => $pembeli,
- 'penjual' => $penjual,
- 'nama_barang' => $nama_barang,
- 'deskripsi_transaksi' => $deskripsi_transaksi,
- 'satuan_barang' => $satuan_barang,
- 'harga_barang' => $harga_barang,
- 'jumlah_barang' => $jumlah_barang,
- 'persentase_keuntungan' => $persentase_keuntungan,
- 'total_keuntungan' => $total_keuntungan,
- 'total_harga' => $total_harga,
- 'total_bayar' => $total_bayar,
- 'nama_bank_penjual' => $bank_penjual,
- 'no_rek_penjual' => $no_rek_penjual,
- 'status_transaksi' => $status,
- 'batas_pembayaran' => $batas_pembayaran,
- 'batas_konfirmasi_transaksi' => $batas_konfirmasi_transaksi,
- 'batas_pengiriman_barang_awal' => $batas_pengiriman_barang_awal,
- 'batas_pengiriman_barang_akhir' => $batas_pengiriman_barang_akhir,
- ]);
-
- $params = [
- 'transaction_details' => [
- 'order_id' => $query->id,
- 'gross_amount' => $total_bayar,
- ],
- 'item_details' => [
- [
- 'id' => $nama_barang . time(),
- 'price' => $harga_barang,
- 'quantity' => $jumlah_barang,
- 'name' => $nama_barang,
- ],
- [
- 'id' => 'BA01',
- 'price' => $total_keuntungan,
- 'quantity' => 1,
- 'name' => 'Biaya Admin',
- ],
- ],
- 'customer_details' => [
- 'firts_name' => $nama_depan_pembeli,
- 'last_name' => $nama_belakang_pembeli,
- 'email' => $pembeli,
- 'phone' => $nohp_pembeli,
- 'billing' => [
- 'first_name' => $nama_depan_pembeli,
- 'last_name' => $nama_belakang_pembeli,
- 'email' => $pembeli,
- 'phone' => $nohp_pembeli,
- 'address' => $alamat,
- 'city' => Auth::user()->village->district->city->name,
- 'country_code' => 'IDN',
- ],
- ],
- 'callbacks' => [
- 'finish' => route('user-pembeli.index'),
- ],
- 'enabled_payments' => ['credit_card', 'shopeepay', 'gopay', 'other_qris'],
- ];
-
- $client = new Client([
- 'verify' => false,
- ]);
-
- $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
-
- $response = $client->request('POST', 'https://app.sandbox.midtrans.com/snap/v1/transactions', [
- 'body' => json_encode($params),
- 'headers' => [
- 'accept' => 'application/json',
- 'authorization' => 'Basic ' . $auth,
- 'content-type' => 'application/json',
- ],
- ]);
-
- $result = json_decode($response->getBody(), true);
-
- Transaction::where('id', $query->id)->update([
- 'token' => $result['token'],
- ]);
-
- $contact = Contact::where('pemilik_kontak', $pembeli)
- ->where('relasi_kontak', $penjual)
- ->count();
-
- if ($contact == 0) {
- Contact::create([
- 'pemilik_kontak' => $pembeli,
- 'relasi_kontak' => $penjual,
- ]);
- }
-
- TransactionDescription::create([
- 'transaction_id' => $query->id,
- 'status' => $status,
- 'user' => $pembeli,
- 'judul' => 'fa fa-plus',
- 'background' => 'bg-buyer',
- 'deskripsi' => $nama_depan_pembeli . ' telah membuat transaksi baru dengan ' . $nama_penjual,
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Berhasil menambahkan transaksi. Silahkan lakukan pembayaran.',
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Gagal menambahkan transaksi.',
- ]);
- }
- }
-
- public function acceptTransaction(Request $request)
- {
- try {
- DB::beginTransaction();
-
- Transaction::where('id', $request->id)->update([
- 'status_transaksi' => 'process',
- ]);
-
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'process',
- 'background' => 'bg-seller',
- 'user' => Auth::user()->email,
- 'judul' => 'fas fa-handshake',
- 'deskripsi' => 'Transaksi telah diterima oleh ' . Auth::user()->nama_depan,
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Transaksi telah diterima. Siapkan pesanan untuk dikirim ke penjual.',
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Gagal update status karena kesalahan server.',
- ]);
- }
- }
-
- public function sendingOrder(Request $request)
- {
- try {
- DB::beginTransaction();
-
- Transaction::where('id', $request->id)->update([
- 'status_transaksi' => 'sending',
- ]);
-
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'sending',
- 'background' => 'bg-seller',
- 'user' => Auth::user()->email,
- 'judul' => 'fas fa-truck-moving',
- 'deskripsi' => 'Pesanan telah dikirim oleh ' . Auth::user()->nama_depan . ' dan sedang dalam perjalanan menuju pembeli.',
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Pesanan sedang dikirim dan menuju pembeli.',
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Gagal update status karena kesalahan server.',
- ]);
- }
- }
-
- public function sentOrder(Request $request)
- {
- try {
- DB::beginTransaction();
-
- Transaction::where('id', $request->transaction_id)->update([
- 'status_transaksi' => 'sent',
- ]);
-
- $bukti_foto = '';
-
- if ($request->hasFile('bukti_foto')) {
- $file = $request->file('bukti_foto');
- $bukti_foto = time() . '.' . $file->getClientOriginalExtension();
- $path = 'bukti-foto/' . $bukti_foto;
-
- Storage::disk('public')->put($path, file_get_contents($file));
- }
-
- TransactionDescription::create([
- 'transaction_id' => $request->transaction_id,
- 'status' => 'sent',
- 'background' => 'bg-seller',
- 'user' => Auth::user()->email,
- 'judul' => 'fas fa-check',
- 'deskripsi' => 'Pesanan telah sampai di tempat pembeli. Keterangan: '.$request->keterangan_bukti,
- 'bukti_foto' => $bukti_foto,
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Pesanan telah sampai di tempat pembeli.',
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Gagal update status karena kesalahan server.',
- ]);
- }
-
- return response([
- 'status' => true,
- 'message' => 'Sukses kirim data.',
- 'data' => $request
- ]);
- }
-
- public function finishTransaction(Request $request)
- {
- try {
- DB::beginTransaction();
-
- Transaction::where('id', $request->id)->update([
- 'status_transaksi' => 'finished',
- 'status_pembayaran' => 'settlement',
- ]);
-
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'finished',
- 'background' => 'bg-buyer',
- 'user' => Auth::user()->email,
- 'judul' => 'fas fa-check',
- 'deskripsi' => 'Pesanan telah diselesaikan oleh ' . auth()->user()->nama_depan . '.',
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Pesanan telah diselesaikan oleh ' . auth()->user()->nama_depan . '.',
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Gagal update status karena kesalahan server.',
- ]);
- }
- }
-
- public function payTransaction(Request $request)
- {
- $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
-
- $response = Http::withOptions([
- 'verify' => false,
- ])
- ->withHeaders([
- 'Content-Type' => 'application/json',
- 'Authorization' => "Basic $auth",
- ])
- ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
-
- $result = json_decode($response->body(), true);
-
- $code = substr($result['status_code'], 0, 1);
-
- try {
- DB::beginTransaction();
-
- if ($code == '4') {
- return response()->json([
- 'status' => false,
- 'message' => 'Terjadi error di server.',
- 'data' => $result,
- ]);
- } else {
- if ($result['transaction_status'] == 'settlement') {
- $transaction = 'success';
- } elseif ($result['transaction_status'] == 'capture') {
- if ($result['fraud_status'] == 'accept') {
- $transaction = 'success';
- } elseif ($result['fraud_status'] == 'challenge') {
- $transaction = 'challenge';
- }
- } else {
- $transaction = 'failure';
- }
-
- Transaction::where('id', $request->id)->update([
- 'metode_pembayaran' => $result['payment_type'],
- 'tanggal_transaksi' => $result['transaction_time'],
- 'status_transaksi' => $transaction,
- 'status_pembayaran' => $result['transaction_status'],
- 'fraud_status' => $result['fraud_status'],
- 'signature_key' => $result['signature_key'],
- ]);
-
- if ($transaction == 'success') {
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'success',
- 'background' => 'bg-buyer',
- 'judul' => 'fas fa-money-bill',
- 'deskripsi' => Auth::user()->nama_depan . ' telah sukses melakukan pembayaran. Transaksi diteruskan ke penjual.',
- 'user' => auth()->user()->email,
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Pembayaran sukses',
- ]);
- } elseif ($transaction == 'challenge') {
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'challenge',
- 'background' => 'bg-primary',
- 'judul' => 'fas fa-clock',
- 'deskripsi' => 'Transaksi ' . auth()->user()->email . ' terindikasi masalah, tunggu sesaat hingga admin menyetujui pembayaran.',
- 'user' => 'admin@example.net',
- 'keterangan' => $result['status_message'],
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => false,
- 'message' => 'Pembayaran ditunda hingga disetujui oleh admin.',
- ]);
- } else {
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'failure',
- 'background' => 'bg-primary',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => 'Terjadi kegagalan pembayaran.',
- 'user' => 'admin@example.net',
- 'keterangan' => $result['status_message'],
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => false,
- 'message' => 'Transaksi pembayaran gagal',
- ]);
- }
- }
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Transaksi pembayaran gagal.',
- ]);
- }
-
- return response()->json();
- }
-
- public function cancelTransaction(Request $request)
- {
- $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
-
- $response = Http::withOptions([
- 'verify' => false,
- ])
- ->withHeaders([
- 'Content-Type' => 'application/json',
- 'Authorization' => "Basic $auth",
- ])
- ->post('https://api.sandbox.midtrans.com/v2/' . $request->id . '/cancel');
-
- $result = json_decode($response->body(), true);
-
- if (in_array($result['status_code'], ['412','401'])) {
- return response()->json([
- 'status' => false,
- 'message' => 'Transaksi gagal.',
- 'data' => $result
- ]);
- } else {
- try {
- DB::beginTransaction();
-
- Transaction::where('id', $request->id)->update([
- 'status_transaksi' => 'failure',
- 'status_pembayaran' => 'cancel'
- ]);
-
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'cancel',
- 'background' => 'bg-buyer',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => auth()->user()->nama_depan . ' telah membatalkan transaksi.',
- 'user' => auth()->user()->email,
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Transaksi berhasil dibatalkan',
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Transaksi gagal dibatalkan',
- ]);
- }
- }
- }
-
- public function pendingTransaction(Request $request)
- {
- $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
-
- $response = Http::withOptions([
- 'verify' => false,
- ])
- ->withHeaders([
- 'Content-Type' => 'application/json',
- 'Authorization' => "Basic $auth",
- ])
- ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
-
- $result = json_decode($response->body(), true);
-
- try {
- DB::beginTransaction();
-
- Transaction::where('id', $request->id)->update([
- 'status_pembayaran' => $result['transaction_status'],
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Pembayaran di-pending, silahkan masuk lagi dan bayar secepat mungkin.',
- ]);
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Terjadi error di bagian server.',
- ]);
- }
- }
-
- public function complaintTransaction($id)
- {
- return view('user.refund.new-refund', compact('id'));
- }
-
- public function onErrorTransaction(Request $request)
- {
- $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
-
- $response = Http::withOptions([
- 'verify' => false,
- ])
- ->withHeaders([
- 'Content-Type' => 'application/json',
- 'Authorization' => "Basic $auth",
- ])
- ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
-
- $result = json_decode($response->body(), true);
-
- try {
- DB::beginTransaction();
-
- Transaction::where('id', $request->id)->update([
- 'status_pembayaran' => $result['transaction_status'],
- ]);
-
- if ($result['transaction_status'] == 'expire') {
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'cancel',
- 'background' => 'bg-buyer',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => 'Pembayaran sudah expire',
- 'user' => 'admin@example.net',
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => false,
- 'message' => 'Pembayaran sudah expire, silahkan buat transaksi baru.',
- ]);
- } elseif ($result['transaction'] == 'failure') {
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'failure',
- 'background' => 'bg-buyer',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => auth()->user()->nama_depan . ' telah membatalkan transaksi.',
- 'user' => 'admin@example.net',
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => false,
- 'message' => 'Terjadi kesalahan di server saat pembayaran.',
- 'data' => $result,
- ]);
- } else {
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => $result['transaction_status'],
- 'background' => 'bg-primary',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => 'Status tidak diketahui',
- 'user' => 'admin@example.net',
- 'keterangan' => $result['status_message'],
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Terjadi kesalahan di server',
- 'data' => $result,
- ]);
- }
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Terjadi error di bagian server.',
- ]);
- }
- }
-
- public function onCloseTransaction(Request $request)
- {
- $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
-
- $response = Http::withOptions([
- 'verify' => false,
- ])
- ->withHeaders([
- 'Content-Type' => 'application/json',
- 'Authorization' => "Basic $auth",
- ])
- ->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
-
- $result = json_decode($response->body(), true);
-
- $status = $result['transaction_status'] == null ? '' : $result['transaction_status'];
-
- if ($status == '') {
- return response()->json([
- 'status' => true,
- 'message' => 'On Close',
- ]);
- } else {
- try {
- DB::beginTransaction();
-
- if ($result['transaction_status'] == 'expire') {
- Transaction::where('id', $request->id)->update([
- 'status_pembayaran' => $result['transaction_status'],
- 'status_transaksi' => 'failure',
- ]);
-
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'cancel',
- 'background' => 'bg-buyer',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => 'Pembayaran sudah expire',
- 'user' => 'admin@example.net',
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => false,
- 'message' => 'Pembayaran sudah expire, silahkan buat transaksi baru.',
- ]);
- } elseif ($result['transaction'] == 'failure') {
- Transaction::where('id', $request->id)->update([
- 'status_pembayaran' => $result['transaction_status'],
- 'status_transaksi' => 'failure',
- ]);
-
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => 'failure',
- 'background' => 'bg-buyer',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => auth()->user()->nama_depan . ' telah membatalkan transaksi.',
- 'user' => 'admin@example.net',
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => false,
- 'message' => 'Terjadi kesalahan di server saat pembayaran.',
- ]);
- } else {
- Transaction::where('id', $request->id)->update([
- 'status_pembayaran' => $result['transaction_status'],
- 'status_transaksi' => 'failure',
- ]);
-
- TransactionDescription::create([
- 'transaction_id' => $request->id,
- 'status' => $result['transaction_status'],
- 'background' => 'bg-primary',
- 'judul' => 'fas fa-exclamation',
- 'deskripsi' => 'Status tidak diketahui.',
- 'user' => 'admin@example.net',
- ]);
-
- DB::commit();
-
- return response()->json([
- 'status' => true,
- 'message' => 'Terjadi kesalahan di server',
- ]);
- }
- } catch (Throwable $e) {
- DB::rollBack();
-
- Log::error($e->getMessage());
-
- return response()->json([
- 'status' => false,
- 'message' => 'Terjadi error di bagian server.',
- ]);
- }
- }
- }
-
- public function listPembeli(Request $request)
- {
- try{
- $subQuery = Transaction::join('users','transactions.penjual','=','users.email')
- ->where('transactions.pembeli',auth()->user()->email)
- ->select(
- 'transactions.id',
- DB::raw("CONCAT(users.nama_depan,' ',users.nama_belakang) as nama_penjual"),
- 'transactions.nama_barang',
- 'transactions.total_harga',
- 'transactions.created_at',
- 'transactions.status_transaksi',
- 'transactions.token'
- );
-
- if($request->has('search') && !empty($request->search['value'])){
- $searchPembeli = $request->search['value'];
- if(!is_numeric($searchPembeli)){
- $subQuery->where(function($a) use ($searchPembeli){
- $a->whereRaw("LOWER(CONCAT(users.nama_depan,' ',users.nama_belakang)) LIKE ?",['%'.strtolower($searchPembeli).'%'])
- ->orWhereRaw('LOWER(transactions.nama_barang) LIKE ?',['%'.strtolower($searchPembeli).'%'])
- ->orWhereRaw('LOWER(transactions.status_transaksi) LIKE ?',['%'.strtolower($searchPembeli).'%']);
- });
- }else{
- $subQuery->where(function($a) use ($searchPembeli){
- $a->where('transactions.total_harga','=',$searchPembeli);
- });
- }
- }
-
- $queryPembeli = Transaction::from(DB::raw("({$subQuery->toSql()}) as tmp"))
- ->mergeBindings($subQuery->getQuery()) // Menggabungkan binding parameters
- ->select('*')
- ->get();
-
- if ($request->ajax()) {
- return DataTables::of($queryPembeli)
- ->addIndexColumn()
- ->addColumn('action', function ($row) {
- $url = route('user-pembeli.show', ['id' => $row->id]);
- $invoice = route('invoice.get',['id' => $row->id]);
- $html_code = '
-
-
- ....
-
-
-
-
';
- return $html_code;
- })
- ->rawColumns(['action'])
- ->make(true);
- }
- }catch(Throwable $e){
- Log::error($e->getMessage());
-
- return response()->json(['success' => false, 'message' => 'Terjadi Kesalahan pada sisi server']);
- }
-
- }
-
- public function listPenjual(Request $request){
- try{
- $subQuery = Transaction::join('users','transactions.pembeli','=','users.email')
- ->where('transactions.penjual',auth()->user()->email)
- ->select(
- 'transactions.id',
- DB::raw("CONCAT(users.nama_depan,' ',users.nama_belakang) as nama_pembeli"),
- 'transactions.nama_barang',
- 'transactions.total_harga',
- 'transactions.created_at',
- 'transactions.status_transaksi',
- );
-
- if($request->has('search') && !empty($request->search['value'])){
- $searchPenjual = $request->search['value'];
- if(!is_numeric($searchPenjual)){
- $subQuery->where(function($a) use ($searchPenjual){
- $a->whereRaw("LOWER(CONCAT(users.nama_depan,' ',users.nama_belakang)) LIKE ?",['%'.strtolower($searchPenjual).'%'])
- ->orWhereRaw('LOWER(transactions.nama_barang) LIKE ?',['%'.strtolower($searchPenjual).'%'])
- ->orWhereRaw('LOWER(transactions.status_transaksi) LIKE ?',['%'.strtolower($searchPenjual).'%']);
- });
- }else{
- $subQuery->where(function($a) use ($searchPenjual){
- $a->whereDay('transactions.created_at', '=', $searchPenjual)
- ->orWhereMonth('transactions.created_at', '=', $searchPenjual)
- ->orWhereYear('transactions.created_at', '=', $searchPenjual)
- ->orWhere('transactions.total_harga', '=', $searchPenjual);
- });
- }
- }
-
- $queryPenjual = Transaction::from(DB::raw("({$subQuery->toSql()}) as tmp"))
- ->mergeBindings($subQuery->getQuery()) // Menggabungkan binding parameters
- ->select('*')
- ->get();
-
- if ($request->ajax()) {
- return DataTables::of($queryPenjual)
- ->addIndexColumn()
- ->addColumn('action', function ($row) {
- $url = route('user-penjual.show', ['id' => $row->id]);
- $invoice = route('invoice.get',['id' => $row->id]);
- $html_code = '
-
-
- ....
-
-
-
-
';
- return $html_code;
- })
- ->rawColumns(['action'])
- ->make(true);
- }
- }catch(Throwable $e){
- Log::error($e->getMessage());
-
- return response()->json(['success' => false, 'message' => 'Terjadi Kesalahan pada sisi server']);
- }
- }
-
public function transactionTracking(Request $request){
$data = TransactionDescription::where('transaction_id', $request->id)->get();
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/User/transaction/penjual/index.blade.php b/resources/views/User/transaction/penjual/index.blade.php
index bd028de..d2e7de3 100644
--- a/resources/views/User/transaction/penjual/index.blade.php
+++ b/resources/views/User/transaction/penjual/index.blade.php
@@ -278,6 +278,83 @@
});
});
+ $('#table-penjual').on('click', '#denyTransaction', function() {
+ const id = $(this).data('id');
+ const csrfToken = $('meta[name="csrf-token"]').attr('content');
+
+ Swal.fire({
+ title: 'Tolak Transaksi?',
+ text: 'Apakah anda yakin untuk menolak transaksi ini?',
+ icon: 'question',
+ showCancelButton: true,
+ cancelButtonText: 'Tunggu, lihat detail dahulu.',
+ confirmButtonText: 'Ya, tolak transaksi.'
+ }).then((result) => {
+ if (result.isConfirmed) {
+ const {
+ value: complaint
+ } = await Swal.fire({
+ title: 'Tolak Transaksi?',
+ inputLabel: 'Berikan alasan untuk menolak transaksi ini',
+ input: 'text',
+ inputPlaceholder: 'Cth: Salah penjual.'
+ });
+
+ if (complaint) {
+ Swal.fire({
+ html: '
Form Anda sedang diproses! Mohon tunggu...
',
+ allowEscapeKey: false,
+ allowOutsideClick: false,
+ didOpen: () => {
+ Swal.showLoading();
+ }
+ });
+
+ $.ajaxSetup({
+ headers: {
+ 'X-CSRF-TOKEN': csrfToken
+ }
+ });
+
+ $.ajax({
+ url: "{{ route('user-penjual.deny') }}",
+ type: 'PUT',
+ data: {
+ id: id,
+ complaint: complaint
+ },
+ success: function(response) {
+ Swal.fire({
+ title: response.status ? 'Berhasil' :
+ 'Gagal',
+ text: response.message,
+ icon: response.status ? 'success' :
+ 'error',
+ }).then(function() {
+ Swal.close();
+ if (response.status) {
+ listPenjual.ajax.reload();
+ }
+ });
+ },
+ error: function(error) {
+ Swal.fire({
+ title: 'Gagal',
+ text: 'Pemrosesan transaksi gagal',
+ icon: 'error'
+ });
+ }
+ });
+ } else {
+ Swal.close();
+ }
+ } else {
+ location.href = "{{ route('user-transaction.show', ':id') }}".replace(':id',
+ id);
+ }
+ });
+ });
+
$('#table-penjual').on('click', '#sendOrder', function() {
const id = $(this).data('id');
const csrfToken = $('meta[name="csrf-token"]').attr('content');
diff --git a/resources/views/email/verification-email.blade.php b/resources/views/email/verification-email.blade.php
index 2f30238..3053168 100644
--- a/resources/views/email/verification-email.blade.php
+++ b/resources/views/email/verification-email.blade.php
@@ -17,12 +17,12 @@