diff --git a/app/Http/Controllers/Admin/AdminDashboardController.php b/app/Http/Controllers/Admin/AdminDashboardController.php index 5b56d105..4f5f150f 100644 --- a/app/Http/Controllers/Admin/AdminDashboardController.php +++ b/app/Http/Controllers/Admin/AdminDashboardController.php @@ -12,29 +12,28 @@ use Illuminate\Support\Facades\Auth; class AdminDashboardController extends Controller { - public function index(){ + public function index() + { $sumSettlement = 0; $sumCancelled = 0; $sumRefund = 0; $currentYear = Carbon::now()->year; $dataChartTransaction = []; $dataChartRefund = []; - for($bulan = 1; $bulan <= 12; $bulan++){ - $transaction = Transaction::whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total_bayar'); + for ($bulan = 1; $bulan <= 12; $bulan++) { + $transaction = Transaction::whereMonth('created_at', $bulan) + ->whereYear('created_at', $currentYear) + ->sum('total_bayar'); // $transaction = Transaction::where('status','finished')->whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total_bayar'); // $refund = Refund::whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total'); // $refund = Refund::where('status','Partial Refund')->whereMonth('created_at',$bulan)->whereYear('created_at', $currentYear)->sum('total'); $dataChartTransaction[] = intval($transaction); // $dataChartRefund[] = intval($refund); } - return view('admin.index',[ - "transaction"=>Transactions::allTransactions(), - "dataChartTransaction" => $dataChartTransaction, + return view('admin.index', [ + 'transaction' => Transactions::allTransactions(), + 'dataChartTransaction' => $dataChartTransaction, // "dataChartRefund" => $dataChartRefund ]); } - - public function profile(){ - return view('admin.profile.index'); - } } diff --git a/app/Http/Controllers/Admin/AdminRefundController.php b/app/Http/Controllers/Admin/AdminRefundController.php index bb559fff..bf748c98 100644 --- a/app/Http/Controllers/Admin/AdminRefundController.php +++ b/app/Http/Controllers/Admin/AdminRefundController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin; use App\Models\Refund; use App\Models\Refunds; use App\Http\Controllers\Controller; +use App\Models\RefundDescription; use Illuminate\Http\Request; class AdminRefundController extends Controller @@ -14,60 +15,33 @@ class AdminRefundController extends Controller */ public function index() { - // $refundData = Refund::all(); - // return view('Admin.refund.history-refund', ['history_refund' => $refundData]); return view('admin.refund.index',[ - "refunds" => Refunds::HistoryRefund() + "refunds" => Refund::latest()->get() ]); } - /** - * Show the form for creating a new resource. - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - } - /** * Display the specified resource. */ - public function show(Refund $refund) + public function show($id) { + $refund = Refund::find($id); + $refundDescription = RefundDescription::where($id)->get(); return view('admin.refund.detail-refund',[ - "detail_refund"=> Refunds::DetailRefund() + "refund"=> $refund, + 'descriptions' => $refundDescription ]); } - /** - * Show the form for editing the specified resource. - */ - public function edit(Refund $refund) - { - // + public function aprroveRefund($id){ + $query = Refund::where('id',$id)->update([ + + ]); } - /** - * Update the specified resource in storage. - */ - public function update(Request $request, Refund $refund) - { - // - } + public function denyRefund($id){ + $query = Refund::where('id',$id)->update([ - /** - * Remove the specified resource from storage. - */ - public function destroy(Refund $refund) - { - // + ]); } } diff --git a/app/Http/Controllers/Admin/AdminSettingController.php b/app/Http/Controllers/Admin/AdminSettingController.php index 4f47e2ad..7bafff36 100644 --- a/app/Http/Controllers/Admin/AdminSettingController.php +++ b/app/Http/Controllers/Admin/AdminSettingController.php @@ -5,6 +5,9 @@ namespace App\Http\Controllers\Admin; use App\Models\Setting; use Illuminate\Http\Request; use App\Http\Controllers\Controller; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; +use Throwable; class AdminSettingController extends Controller { @@ -24,39 +27,31 @@ class AdminSettingController extends Controller */ public function store(Request $request) { - // dd($request->persentase); - [$tahun, $bulan] = explode('-', $request->bulan_tahun); - Setting::create([ - 'bulan' => $bulan, - 'tahun' => $tahun, - 'persentase' => $request->persentase, - 'status' => 'Active', - ]); - return redirect()->route('admin-setting.index'); - } + try{ + DB::beginTransaction(); + Setting::updateOrCreate( + ['bulan' => $request->bulan, 'tahun' => $request->tahun], + ['persentase' => $request->persentase] + ); + DB::commit(); - /** - * Display the specified resource. - */ - public function show(Setting $setting) - { - // - } + return response()->json(['status' => true, 'message' => 'Berhasil menambah']); + + }catch(Throwable $e){ + DB::rollBack(); + + Log::error($e->getMessage()); + + return response()->json(['status' => false, 'message' => 'Terjadi Kesalahan pada sisi server']); + } - /** - * Show the form for editing the specified resource. - */ - public function edit(Setting $setting) - { - // } /** * Update the specified resource in storage. */ - public function update(Request $request, $id) + public function activeSetting($id) { - // dd($setting['status'] ); $setting = Setting::findOrFail($id); if ($setting->status == 'Active') { $setting->status = 'Nonactive'; @@ -87,15 +82,5 @@ class AdminSettingController extends Controller ]); } } - - // return response()->json($id); - } - - /** - * Remove the specified resource from storage. - */ - public function destroy(Setting $setting) - { - // } } diff --git a/app/Http/Controllers/Admin/AdminTransactionController.php b/app/Http/Controllers/Admin/AdminTransactionController.php index b97155f6..2be473da 100644 --- a/app/Http/Controllers/Admin/AdminTransactionController.php +++ b/app/Http/Controllers/Admin/AdminTransactionController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Admin; use App\Models\Transaction; -use App\Models\Transactions; use App\Http\Controllers\Controller; use Illuminate\Http\Request; @@ -19,53 +18,13 @@ class AdminTransactionController extends Controller ]); } - /** - * Show the form for creating a new resource. - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - } - /** * Display the specified resource. */ - public function show(transaction $transaction) + public function show(Transaction $transaction) { return view('admin.transaction.detail-transaction',[ - 'detail_transaction' => Transactions::allDetailTransactions() + 'transaction' => $transaction ]); } - - /** - * Show the form for editing the specified resource. - */ - public function edit(transaction $transaction) - { - // - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, transaction $transaction) - { - // - } - - /** - * Remove the specified resource from storage. - */ - public function destroy(transaction $transaction) - { - // - } } diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php index 577c3edb..ed0f8bdb 100644 --- a/app/Http/Controllers/Admin/AdminUserController.php +++ b/app/Http/Controllers/Admin/AdminUserController.php @@ -13,10 +13,6 @@ class AdminUserController extends Controller */ public function index() { - // $users = User::where('role', 'User') - // ->orderByRaw("FIELD(status, 'Progress', 'Finished', 'Rejected') ASC") - // ->latest() - // ->get(); $users = User::where('role', 'User') ->orderByRaw("CASE WHEN status = 'Progress' THEN 1 WHEN status = 'Finished' THEN 2 WHEN status = 'Rejected' THEN 3 ELSE 4 END ASC") ->latest() @@ -24,22 +20,6 @@ class AdminUserController extends Controller return view('admin.users.index', ['users' => $users]); } - /** - * Show the form for creating a new resource. - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - // - } - /** * Display the specified resource. */ @@ -49,25 +29,6 @@ class AdminUserController extends Controller return view('admin.users.detail-user', ['user' => $user]); } - /** - * Show the form for editing the specified resource. - */ - public function edit(User $user) - { - // - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id) - { - return response()->json([ - 'user' => $request, - 'id' => $id, - ]); - } - /** * Remove the specified resource from storage. */ diff --git a/app/Http/Controllers/Login/LoginController.php b/app/Http/Controllers/Login/LoginController.php index 4a58e06a..59f3b265 100644 --- a/app/Http/Controllers/Login/LoginController.php +++ b/app/Http/Controllers/Login/LoginController.php @@ -22,16 +22,6 @@ use Ramsey\Uuid\Uuid; class LoginController extends Controller { - // /** - // * Create a new AuthController instance. - // * - // * @return void - // */ - // public function __construct() - // { - // $this->middleware('auth:api', ['except' => ['login', 'authenticate', 'register', 'hai']]); - // } - public function login() { return view('index'); @@ -44,7 +34,6 @@ class LoginController extends Controller */ public function authenticate(Request $request) { - // dd($request); $credentials = $request->validate( [ 'email' => ['required', 'email'], @@ -62,7 +51,6 @@ class LoginController extends Controller if (Auth::user()->status == 'Finished') { $request->session()->regenerate(); if (ucwords(Auth::user()->role) == 'Admin') { - // return redirect()->route('admin.index'); return redirect()->intended('admin'); } else { return redirect()->intended('user'); @@ -74,16 +62,12 @@ class LoginController extends Controller Session::flash('message', 'Akun tidak ditemukan atau sedang dalam pengajuan'); return redirect()->back(); } - } - - // $error = $credentials->errors(); - // ->withInput($request->except('key')) - // ->withErrors($validator) - - return redirect() + }else{ + return redirect() ->back() ->withErrors($credentials) ->onlyInput('email'); + } } /** @@ -221,7 +205,7 @@ class LoginController extends Controller } } - public function statusAkun($email) + public function accountStatus($email) { $result = User::where('email', $email)->get(); if ($result->isNotEmpty()) { @@ -237,14 +221,14 @@ class LoginController extends Controller } } - public function cariProvinsi() + public function searchProvince() { $data = Province::where('name', 'LIKE', '%' . strtoupper(request('q')) . '%')->paginate(10); return response()->json($data); } - public function cariKota($code) + public function searchCity($code) { $data = City::where('province_code', $code) ->where('name', 'LIKE', '%' . strtoupper(request('q')) . '%') @@ -253,7 +237,7 @@ class LoginController extends Controller return response()->json($data); } - public function cariKecamatan($code) + public function searchDistrict($code) { $data = District::where('city_code', $code) ->where('name', 'LIKE', '%' . strtoupper(request('q')) . '%') @@ -262,7 +246,7 @@ class LoginController extends Controller return response()->json($data); } - public function cariKelurahan($code) + public function searchVillage($code) { $data = Village::where('district_code', $code) ->where('name', 'LIKE', '%' . strtoupper(request('q')) . '%') @@ -271,7 +255,7 @@ class LoginController extends Controller return response()->json($data); } - public function kirimKodeVerifikasi(Request $request) + public function sendVerificationCode(Request $request) { $email = $request->get('email'); $code = $request->get('code'); diff --git a/app/Http/Controllers/Profile/ProfileController.php b/app/Http/Controllers/Profile/ProfileController.php new file mode 100644 index 00000000..f609f4f0 --- /dev/null +++ b/app/Http/Controllers/Profile/ProfileController.php @@ -0,0 +1,59 @@ + Auth::user()]); + } + + public function update(Request $request){ + $nama_depan = $request->nama_depan; + $nama_belakang = $request->nama_belakang; + $nohp = $request->nohp; + $kode_kelurahan = $request->kelurahan; + $alamat = $request->alamat; + $nama_bank = $request->nama_bank; + $no_rek = $request->no_rek; + $foto_profile = ''; + if($request->hasFile('foto_profile')){ + $file = $request->file('foto_profile'); + $extension = $file->getClientOriginalExtension(); + $foto_profile = 'Foto-Profil-'.$nama_depan.' '.$nama_belakang.'.'.$extension; + $file->storeAs('storage/foto-profile/'.$foto_profile); + } + + try{ + DB::beginTransaction(); + + User::where('id', Auth::user()->id)->update([ + 'nama_depan' => $nama_depan, + 'nama_belakang' => $nama_belakang, + 'nohp' => $nohp, + 'kode_kelurahan' => $kode_kelurahan, + 'alamat' => $alamat, + 'nama_bank' => $nama_bank, + 'no_rek' => $no_rek, + 'foto_profile' => $foto_profile, + ]); + + DB::commit(); + }catch(Throwable $e){ + DB::rollBack(); + + Log::error($e->getMessage()); + + return response()->json(['status' => false, 'message' => 'Terjadi Kesalahan pada sisi server']); + } + } +} diff --git a/app/Http/Controllers/User/UserContactController.php b/app/Http/Controllers/User/UserContactController.php index 7470fd90..907c871e 100644 --- a/app/Http/Controllers/User/UserContactController.php +++ b/app/Http/Controllers/User/UserContactController.php @@ -18,7 +18,6 @@ class UserContactController extends Controller { $contacts = Contact::where('pemilik_kontak', Auth::user()->email)->get(); return view('user.contact.index', ['contacts' => $contacts]); - // dd($contacts); } public function getContact() @@ -31,14 +30,6 @@ class UserContactController extends Controller return response()->json($data); } - /** - * Show the form for creating a new resource. - */ - public function create() - { - // - } - /** * Store a newly created resource in storage. */ @@ -70,33 +61,10 @@ class UserContactController extends Controller } } - /** - * Display the specified resource. - */ - public function show(Contact $contact) - { - } - - /** - * Show the form for editing the specified resource. - */ - public function edit(Contact $contact) - { - // - } - - /** - * Update the specified resource in storage. - */ - public function update(Request $request, Contact $contact) - { - // - } - /** * Remove the specified resource from storage. */ - public function destroy(Contact $contact, $id) + public function destroy($id) { try { $result = Contact::destroy($id); @@ -121,7 +89,7 @@ class UserContactController extends Controller public function cekEmail($email) { - $result = User::where('email', $email)->get(); + $result = User::where('email', $email)->first(); if ($result->isNotEmpty() && $result[0]->role == 'User' && $result[0]->status != 'Rejected') { if ($result[0]->status == 'Finished') { return response()->json([ diff --git a/app/Http/Controllers/User/UserDashboardController.php b/app/Http/Controllers/User/UserDashboardController.php index 90704e85..c36c55d0 100644 --- a/app/Http/Controllers/User/UserDashboardController.php +++ b/app/Http/Controllers/User/UserDashboardController.php @@ -5,16 +5,16 @@ namespace App\Http\Controllers\User; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\RefundUser; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; +use Throwable; class UserDashboardController extends Controller { public function index(){ return view('user.index',[ - "refundUserss"=>RefundUser::HistoryRefundUser() + "refundUserss"=>RefundUser::HistoryRefundUser(), ]); } - - public function profile(){ - return view('user.profile.index'); - } } diff --git a/app/Http/Controllers/User/UserRefundController.php b/app/Http/Controllers/User/UserRefundController.php index 4a1e7942..9b849f49 100644 --- a/app/Http/Controllers/User/UserRefundController.php +++ b/app/Http/Controllers/User/UserRefundController.php @@ -5,26 +5,83 @@ namespace App\Http\Controllers\User; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Models\RefundUser; +use App\Models\Refund; +use App\Models\RefundDescription; +use App\Models\Transaction; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; +use Throwable; class UserRefundController extends Controller { public function index() { return view('user.refund.index', [ - 'name' => 'npannisa', - 'refundUserss' => RefundUser::HistoryRefundUser(), + 'refunds' => Refund::where() ]); } - public function create(Request $request) + public function create($id) { - return view('user.refund.new-refund'); + return view('user.refund.new-refund',['id' => $id]); } - public function historyRefund($id){ - return view('user.transaction.pembeli.history-refund',[ - 'name'=>'npannisa', - "refundUserss"=>RefundUser::HistoryRefundUser() + public function store(Request $request, $id){ + try{ + DB::beginTransaction(); + + $transaction = Transaction::where('id',$id)->first(); + + $refund = Refund::create([ + 'transaction_id' => $id, + 'total' => $transaction->harga, + 'due_date' => $transaction, + 'complain' => $request->complain + ]); + + if ($request->hasFile('files')) { + $files = $request->file('files'); + foreach ($files as $file) { + $filename = $file->getClientOriginalName(); + $mime = $file->getClientMimeType(); + if (strpos($mime, 'image') !== false) { + $type = 'Image'; + $file->storeAs('public/refund-image/', $filename); + } elseif (strpos($mime, 'video') !== false) { + $type = 'Video'; + $file->storeAs('public/refund-video/', $filename); + } else { + $type = 'Other'; + } + + RefundDescription::create([ + 'refund_id' => $refund->id, + 'filename' => $filename, + 'type' => $type + ]); + } + } + + DB::commit(); + }catch(Throwable $e){ + DB::rollback(); + + Log::error($e->getMessage()); + + return response()->json(['success' => false, 'message' => 'Terjadi Kesalahan pada sisi server']); + } + } + + public function show($id){ + $refund = Refund::find($id); + $refundDescription = RefundDescription::where($id)->get(); + return view('admin.refund.detail-refund',[ + "refund"=> $refund, + 'descriptions' => $refundDescription + ]); + return view('user.refund.history-refund',[ + 'refund' => $refund, + 'descriptions' => $refundDescription ]); } } diff --git a/app/Http/Controllers/User/UserTransactionController.php b/app/Http/Controllers/User/UserTransactionController.php index bd6fd7c5..13245094 100644 --- a/app/Http/Controllers/User/UserTransactionController.php +++ b/app/Http/Controllers/User/UserTransactionController.php @@ -5,6 +5,9 @@ namespace App\Http\Controllers\User; use App\Models\Transaction; use App\Models\TransactionDescription; use App\Http\Controllers\Controller; +use App\Models\Contact; +use App\Models\Refund; +use App\Models\RefundDescription; use App\Models\Setting; use Illuminate\Http\Request; use App\Models\TransactionUser; @@ -57,24 +60,20 @@ class UserTransactionController extends Controller ]); } - public function detailTransaction($id) + public function show($id) { return view('user.transaction.pembeli.detail-transaction', [ 'transaction' => Transaction::findOrFail($id), - 'trackings' => TransactionDescription::where('order_id', $id)->get(), + 'trackings' => TransactionDescription::where('order_id', $id) + ->latest() + ->get(), ]); - - // $transaction = Transaction::findOrFail($id); - - // var_dump($transaction->metode_pembayaran == 'qris'); - - // dd(Transaction::findOrFail($id)); } /** * Show the form for creating a new resource. */ - public function createTransaction() + public function create() { $now = Carbon::now(); $bulan = $now->format('F'); @@ -99,12 +98,11 @@ class UserTransactionController extends Controller public function invoiceTransaction($id) { return view('user.transaction.pembeli.invoice-transaction', [ - 'name' => 'npannisa', 'TransactionUser' => TransactionUser::HistoryTransaction(), ]); } - public function storeTransaction(Request $request) + public function store(Request $request) { $pembeli = Auth::user()->email; $penjual = $request->get('email_penjual'); @@ -131,7 +129,7 @@ class UserTransactionController extends Controller $batas_pembayaran = $now->addDays(1)->toDateTimeString(); $batas_pengiriman_barang_awal = $now->addDays(2)->toDateTimeString(); - $batas_pengiriman_barang_akhir = $now->addDays(5)->toDateTimeString(); + $batas_pengiriman_barang_akhir = $now->addDays(4)->toDateTimeString(); $params = [ 'transaction_details' => [ @@ -168,18 +166,21 @@ class UserTransactionController extends Controller ], ], 'callbacks' => [ - 'finish' => 'http://127.0.0.1:8000/user/user-transaction-pembeli/', + 'finish' => route('user-transaction.index.pembeli'), + ], + 'enabled_payments' => [ + 'credit_card', 'gopay', 'shopeepay' ], 'expiry' => [ 'start_time' => $now->format('Y-m-d H:i:s P'), - 'unit' => 'hours', - 'duration' => 24, + 'unit' => 'days', + 'duration' => 1, ], ]; $snap_token = Snap::getSnapToken($params); $token = $snap_token; - $status = 'pending'; + $status = 'created'; $query = Transaction::create([ 'id' => $id, 'pembeli' => $pembeli, @@ -201,8 +202,18 @@ class UserTransactionController extends Controller ]); if ($query) { + $contact = Contact::where('pemilik_kontak', $pembeli) + ->where('relasi_kontak', $penjual) + ->count(); + if ($contact == 0) { + Contact::create([ + 'pemilik_kontak' => $pembeli, + 'relasi_kontak' => $penjual, + ]); + } + TransactionDescription::create([ - 'order_id' => $id, + 'transaction_id' => $id, 'status' => $status, 'user' => $pembeli, 'judul' => 'fa fa-plus', @@ -221,106 +232,115 @@ class UserTransactionController extends Controller } } - public function updateStatusTransaction(Request $request) + public function acceptTransaction($id) { - } - - public function acceptTransaction(Request $request) - { - } - - public function paymentTransaction($id) - { - // Membuat objek Google Translate - $translator = new GoogleTranslate(); - - // Mengatur bahasa sumber (Inggris) dan bahasa target (Indonesia) - $translator->setSource('en'); - $translator->setTarget('id'); - - // Config::$serverKey = 'SB-Mid-server-8rydZAwKoWuoQ6g_3ot0-K7p'; - // Config::$isProduction = false; - // // Set sanitization on (default) - // Config::$isSanitized = true; - // // Set 3DS transaction for credit card to true - // Config::$is3ds = true; - - $payment = Trans::status($id); - $result = json_decode(json_encode($payment), true); - return response()->json([ - 'status' => true, - 'message' => $result, - ]); $query = Transaction::where('id', $id)->update([ - 'currency' => $result['currency'], - 'merchant_id' => $result['merchant_id'], - 'metode_pembayaran' => $result['payment_type'], - 'tanggal_transaksi' => $result['transaction_time'], - 'signature_key' => $result['signature_key'], - 'status' => $result['transaction_status'], - 'status_code' => $result['status_code'], - 'status_message' => $result['status_message'], - 'fraud_status' => $result['fraud_status'], + 'status' => 'process', ]); if ($query) { TransactionDescription::create([ - 'order_id' => $id, - 'status' => $result['transaction_status'], + 'transaction_id' => $id, + 'status' => 'process', + 'background' => 'bg-seller', 'user' => Auth::user()->email, - 'judul' => 'fa fa-plus', - 'background' => 'bg-buyer', - 'deskripsi' => Auth::user()->nama_depan . ' telah membayar menggunakan ' . $result['payment_type'] . ' ' . $result['acquirer'].'. '.$translator->translate($result['status_message']), + 'judul' => 'fas fa-handshake', + 'deskripsi' => 'Transaksi telah diterima oleh ' . Auth::user()->nama_depan, ]); + return response()->json([ 'status' => true, - 'message' => 'Pembayaran sukses. Proses akan dilanjutkan ke penjual', + 'message' => 'Transaksi telah diterima. Siapkan pesanan untuk dikirim ke penjual.', ]); } else { return response()->json([ 'status' => false, - 'message' => 'Pembayaran gagal', + 'message' => 'Gagal update status karena kesalahan server.', ]); } } - /** - * Display the specified resource. - */ - public function show(Transaction $transaction) + public function sendingOrder($id) { - // + $query = Transaction::where('id', $id)->update([ + 'status' => 'sending', + ]); + if ($query) { + TransactionDescription::create([ + 'transaction_id' => $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.', + ]); + + return response()->json([ + 'status' => true, + 'message' => 'Pesanan sedang dikirim dan menuju pembeli.', + ]); + } else { + return response()->json([ + 'status' => false, + 'message' => 'Gagal update status karena kesalahan server.', + ]); + } } - /** - * Show the form for editing the specified resource. - */ - public function edit(Transaction $transaction) + public function sentOrder($id) { - // + $query = Transaction::where('id', $id)->update([ + 'status' => 'sended', + ]); + if ($query) { + TransactionDescription::create([ + 'transaction_id' => $id, + 'status' => 'sended', + 'background' => 'bg-seller', + 'user' => Auth::user()->email, + 'judul' => 'fas fa-check', + 'deskripsi' => 'Pesanan telah sampai di tempat pembeli.', + ]); + + return response()->json([ + 'status' => true, + 'message' => 'Pesanan telah sampai di tempat pembeli.', + ]); + } else { + return response()->json([ + 'status' => false, + 'message' => 'Gagal update status karena kesalahan server.', + ]); + } } - /** - * Update the specified resource in storage. - */ - public function update(Request $request, Transaction $transaction) + public function finishTransaction($id) { - // + $query = Transaction::where('id', $id)->update([ + 'status' => 'finished', + ]); + if ($query) { + TransactionDescription::create([ + 'transaction_id' => $id, + 'status' => 'sended', + 'background' => 'bg-buyer', + 'user' => Auth::user()->email, + 'judul' => 'fas fa-check', + 'deskripsi' => 'Pesanan telah sampai di tempat pembeli.', + ]); + + return response()->json([ + 'status' => true, + 'message' => 'Pesanan telah sampai di tempat pembeli.', + ]); + } else { + return response()->json([ + 'status' => false, + 'message' => 'Gagal update status karena kesalahan server.', + ]); + } } - /** - * Remove the specified resource from storage. - */ - public function destroy(Transaction $transaction) - { - // - } - - public function cancelTransaction(){ - $cancel = \Midtrans\Transaction::cancel('005d662f-eaf2-45aa-8789-b5da82a8948d'); - var_dump($cancel); // Hasilnya 200 atau kode - } - - public function translate() + public function payTransaction($id) { // Membuat objek Google Translate $translator = new GoogleTranslate(); @@ -329,10 +349,140 @@ class UserTransactionController extends Controller $translator->setSource('en'); $translator->setTarget('id'); - // Menerjemahkan teks - $translatedText = $translator->translate('Hello, world!'); + $payment = Trans::status($id); + $result = json_decode(json_encode($payment), true); + if (in_array($result['status_code'], ['200', '201', '202'])) { + $query = Transaction::where('id', $id)->update([ + 'currency' => $result['currency'], + 'merchant_id' => $result['merchant_id'], + 'metode_pembayaran' => $result['payment_type'], + 'tanggal_transaksi' => $result['transaction_time'], + 'signature_key' => $result['signature_key'], + 'status' => $result['transaction_status'], + 'fraud_status' => $result['fraud_status'], + ]); + if ($query) { + if ($result['transaction_status'] == 'pending') { + TransactionDescription::create([ + 'transaction_id' => $id, + 'status' => $result['transaction_status'], + 'user' => Auth::user()->email, + 'judul' => 'fas fa-clock', + 'status_code' => $result['status_code'], + 'background' => 'bg-buyer', + 'deskripsi' => 'Pembayaran ditunda.', + ]); + return response()->json([ + 'status' => true, + 'message' => 'Transaksi ditunda. Silahkan bayar nanti selama dalam waktu batas pembayaran.', + ]); + } else { + TransactionDescription::create([ + 'transaction_id' => $id, + 'status' => $result['transaction_status'], + 'user' => Auth::user()->email, + 'judul' => 'fas fa-plus', + 'status_code' => $result['status_code'], + 'background' => 'bg-buyer', + 'deskripsi' => Auth::user()->nama_depan . ' telah sukses melakukan pembayaran. Transaksi diteruskan ke penjual.', + ]); + return response()->json([ + 'status' => true, + 'message' => 'Pembayaran sukses.', + ]); + } + } else { + return response()->json([ + 'status' => false, + 'message' => 'Transaksi pembayaran gagal.', + ]); + } + } elseif (in_array($result['status_code'], ['400', '401', '402', '403', '404', '405', '406', '407', '408', '409', '410', '411', '412', '413'])) { + return response()->json([ + 'status' => false, + 'message' => 'Terjadi kesalahan di server.', + ]); + } else { + return response()->json([ + 'status' => false, + 'message' => 'Transaksi pembayaran gagal', + ]); + } + } - // Output hasil terjemahan - echo $translatedText; + public function cancelTransaction($id) + { + // Membuat objek Google Translate + $translator = new GoogleTranslate(); + + // Mengatur bahasa sumber (Inggris) dan bahasa target (Indonesia) + $translator->setSource('en'); + $translator->setTarget('id'); + + $transaction = Transaction::where('id', $id)->first(); + + if ($transaction->status == 'created') { + $query = Transaction::where('id', $id)->update([ + 'status' => 'cancel', + ]); + if ($query) { + TransactionDescription::create([ + 'transcation_id' => $id, + 'status' => 'cancel', + 'user' => Auth::user()->email, + 'judul' => 'fas fa-exclamation', + 'background' => 'bg-buyer', + 'deskripsi' => 'Transaksi dibatalkan', + ]); + + return response()->json([ + 'status' => true, + 'message' => 'Transaksi berhasil dibatal', + ]); + } else { + return response()->json([ + 'status' => false, + 'message' => 'Transaksi gagal dibatalkan', + ]); + } + } else { + $cancel = json_decode(json_encode(Trans::cancel($id)), true); + if ($cancel['status_code'] == '200') { + $query = Transaction::where('id', $id)->update([ + 'status' => $cancel['transaction_status'], + ]); + if ($query) { + TransactionDescription::create([ + 'transaction_id' => $id, + 'status' => $cancel['transaction_status'], + 'user' => Auth::user()->email, + 'judul' => 'fas fa-exclamation', + 'status_code' => $cancel['status_code'], + 'background' => 'bg-buyer', + 'deskripsi' => $translator->translate($cancel['status_message']), + ]); + + return response()->json([ + 'status' => true, + 'message' => $translator->translate($cancel['status_message']), + ]); + } else { + return response()->json([ + 'status' => false, + 'message' => $translator->translate($cancel['status_message']), + ]); + } + } elseif ($cancel['status_code'] == '412') { + return response()->json([ + 'status' => false, + 'message' => $translator->translate($cancel['status_message']), + ]); + } + } + } + + public function complainTransaction($id) + { + return view('user.refund.new-refund', compact('id')); } } diff --git a/app/Models/Refund.php b/app/Models/Refund.php index 568b2961..4604bef0 100644 --- a/app/Models/Refund.php +++ b/app/Models/Refund.php @@ -15,15 +15,15 @@ class Refund extends Model * @var array */ protected $fillable = [ - 'order_id', + 'transaction_id', 'total', 'due_date', 'status', ]; //Relasi - public function orders(){ - return $this->belongsTo(Transaction::class, 'id', 'order_id'); + public function transaction(){ + return $this->belongsTo(Transaction::class, 'id', 'transaction_id'); } //Relasi } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 99d25256..b7e200c6 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -18,6 +18,5 @@ class Setting extends Model 'bulan', 'tahun', 'persentase', - 'status', ]; } diff --git a/app/Models/TransactionDescription.php b/app/Models/TransactionDescription.php index 6810c6ba..66aebddd 100644 --- a/app/Models/TransactionDescription.php +++ b/app/Models/TransactionDescription.php @@ -19,6 +19,7 @@ class TransactionDescription extends Model 'user', 'judul', 'status', + 'status_code', 'background', 'deskripsi' ]; diff --git a/app/Models/transaction.php b/app/Models/transaction.php index 1bcbfa43..4120d1b8 100644 --- a/app/Models/transaction.php +++ b/app/Models/transaction.php @@ -55,11 +55,11 @@ class Transaction extends Model } public function refunds(){ - return $this->hasMany(Refund::class, 'order_id', 'id'); + return $this->hasMany(Refund::class, 'transaction_id', 'id'); } public function transactionDescription(){ - return $this->hasMany(TransactionDescription::class, 'order_id', 'id'); + return $this->hasMany(TransactionDescription::class, 'transaction_id', 'id'); } //Relasi } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index ee19fe14..bdad536e 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -30,7 +30,7 @@ class UserFactory extends Factory 'nik' => $this->faker->nik($this->faker->randomElement(['male', 'female']),$this->faker->dateTimeBetween('-65 years', '-18 years')), 'alamat'=> $this->faker->address, 'nohp'=> $this->faker->phoneNumber(), - 'persentase_kemiripan' => random_int(0, 100).'%', + 'persentase_kemiripan' => random_int(0, 100), 'status'=> $this->faker->randomElement(['Progress', 'Finished', 'Rejected']), 'gender' => $this->faker->randomElement(['Laki-laki', 'Perempuan']), 'kode_kelurahan' => '1101012002', diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index fc18ea30..588e80c6 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -3,6 +3,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Facades\DB; return new class extends Migration { @@ -12,7 +13,7 @@ return new class extends Migration public function up(): void { Schema::create('users', function (Blueprint $table) { - $table->uuid('id')->primary; + $table->uuid('id')->default(DB::raw('uuid_generate_v4()'))->primary(); $table->string('nama_depan',255); $table->string('nama_belakang',255); $table->date('tanggal_lahir'); @@ -21,19 +22,22 @@ return new class extends Migration $table->string('password'); $table->enum('role',['Admin','User'])->default('User'); $table->string('nohp',20); - $table->string('nik',20); + $table->string('nik',20)->unique(); $table->string('alamat',255); $table->string('foto_ktp')->nullable(); $table->string('foto_wajah')->nullable(); $table->string('foto_profil')->nullable(); - $table->string('persentase_kemiripan')->nullable(); + $table->integer('persentase_kemiripan')->nullable(); $table->enum('status',['Finished','Progress','Rejected'])->default('Progress'); $table->string('gender',15); $table->char('kode_kelurahan',10); + $table->string('no_rek')->nullable(); + $table->string('nama_bank')->nullable(); $table->rememberToken(); $table->timestamps(); - // $table->foreign('kode_kelurahan')->on('villages')->references('code'); + $table->index('status'); + $table->index('kode_kelurahan'); }); } diff --git a/database/migrations/2016_08_03_072729_create_provinces_table.php b/database/migrations/2016_08_03_072729_create_provinces_table.php index 2379b086..3b8e7eca 100644 --- a/database/migrations/2016_08_03_072729_create_provinces_table.php +++ b/database/migrations/2016_08_03_072729_create_provinces_table.php @@ -19,6 +19,9 @@ class CreateProvincesTable extends Migration $table->string('name', 255); $table->text('meta')->nullable(); $table->timestamps(); + + $table->index('code'); + $table->index('id'); }); } diff --git a/database/migrations/2016_08_03_072750_create_cities_table.php b/database/migrations/2016_08_03_072750_create_cities_table.php index 6a917a5d..72cb727f 100644 --- a/database/migrations/2016_08_03_072750_create_cities_table.php +++ b/database/migrations/2016_08_03_072750_create_cities_table.php @@ -25,6 +25,9 @@ class CreateCitiesTable extends Migration ->references('code') ->on(config('laravolt.indonesia.table_prefix').'provinces') ->onUpdate('cascade')->onDelete('restrict'); + $table->index('id'); + $table->index('code'); + $table->index('province_code'); }); } diff --git a/database/migrations/2016_08_03_072804_create_districts_table.php b/database/migrations/2016_08_03_072804_create_districts_table.php index f5b466ed..08e938da 100644 --- a/database/migrations/2016_08_03_072804_create_districts_table.php +++ b/database/migrations/2016_08_03_072804_create_districts_table.php @@ -13,7 +13,7 @@ class CreateDistrictsTable extends Migration */ public function up() { - Schema::create(config('laravolt.indonesia.table_prefix').'districts', function (Blueprint $table) { + Schema::create(config('laravolt.indonesia.table_prefix') . 'districts', function (Blueprint $table) { $table->bigIncrements('id'); $table->char('code', 7)->unique(); $table->char('city_code', 4); @@ -21,10 +21,15 @@ class CreateDistrictsTable extends Migration $table->text('meta')->nullable(); $table->timestamps(); - $table->foreign('city_code') + $table + ->foreign('city_code') ->references('code') - ->on(config('laravolt.indonesia.table_prefix').'cities') - ->onUpdate('cascade')->onDelete('restrict'); + ->on(config('laravolt.indonesia.table_prefix') . 'cities') + ->onUpdate('cascade') + ->onDelete('restrict'); + $table->index('id'); + $table->index('code'); + $table->index('city_code'); }); } @@ -35,6 +40,6 @@ class CreateDistrictsTable extends Migration */ public function down() { - Schema::drop(config('laravolt.indonesia.table_prefix').'districts'); + Schema::drop(config('laravolt.indonesia.table_prefix') . 'districts'); } } diff --git a/database/migrations/2016_08_03_072819_create_villages_table.php b/database/migrations/2016_08_03_072819_create_villages_table.php index 9501bca9..0efb62d1 100644 --- a/database/migrations/2016_08_03_072819_create_villages_table.php +++ b/database/migrations/2016_08_03_072819_create_villages_table.php @@ -13,7 +13,7 @@ class CreateVillagesTable extends Migration */ public function up() { - Schema::create(config('laravolt.indonesia.table_prefix').'villages', function (Blueprint $table) { + Schema::create(config('laravolt.indonesia.table_prefix') . 'villages', function (Blueprint $table) { $table->bigIncrements('id'); $table->char('code', 10)->unique(); $table->char('district_code', 7); @@ -21,10 +21,15 @@ class CreateVillagesTable extends Migration $table->text('meta')->nullable(); $table->timestamps(); - $table->foreign('district_code') + $table + ->foreign('district_code') ->references('code') - ->on(config('laravolt.indonesia.table_prefix').'districts') - ->onUpdate('cascade')->onDelete('restrict'); + ->on(config('laravolt.indonesia.table_prefix') . 'districts') + ->onUpdate('cascade') + ->onDelete('restrict'); + $table->index('id'); + $table->index('code'); + $table->index('district_code'); }); } @@ -35,6 +40,6 @@ class CreateVillagesTable extends Migration */ public function down() { - Schema::drop(config('laravolt.indonesia.table_prefix').'villages'); + Schema::drop(config('laravolt.indonesia.table_prefix') . 'villages'); } } diff --git a/database/migrations/2023_08_01_073859_create_transactions_table.php b/database/migrations/2023_08_01_073859_create_transactions_table.php index c32cebb1..7f5046e9 100644 --- a/database/migrations/2023_08_01_073859_create_transactions_table.php +++ b/database/migrations/2023_08_01_073859_create_transactions_table.php @@ -30,16 +30,19 @@ return new class extends Migration $table->char('currency',3)->nullable(); $table->string('fraud_status')->nullable(); $table->string('merchant_id')->nullable(); - $table->string('status_code')->nullable(); - $table->string('status_message')->nullable(); - $table->enum('status',['settlement','capture','pending','cancel','refund','expire','failure','progress','failed','sending','sended','finished'])->default('pending'); // transaction_status + $table->enum('status',['settlement','capture','pending','cancel','refund', 'expire','failure','process','sending','sended','finished','created'])->default('created'); // transaction_status $table->timestamp('batas_pembayaran'); $table->timestamp('batas_pengiriman_barang_awal'); $table->timestamp('batas_pengiriman_barang_akhir'); $table->timestamp('tanggal_transaksi')->nullable(); + $table->string('nama_bank_penjual'); + $table->string('no_rek_penjual'); $table->timestamps(); + $table->foreign('pembeli')->on('users')->references('email'); $table->foreign('penjual')->on('users')->references('email'); + + $table->index('id'); }); } diff --git a/database/migrations/2023_08_16_044527_create_refunds_table.php b/database/migrations/2023_08_16_044527_create_refunds_table.php index 25e60e5e..d332d54b 100644 --- a/database/migrations/2023_08_16_044527_create_refunds_table.php +++ b/database/migrations/2023_08_16_044527_create_refunds_table.php @@ -12,13 +12,14 @@ return new class extends Migration public function up(): void { Schema::create('refunds', function (Blueprint $table) { - $table->id(); - $table->foreignUuid('order_id'); + $table->uuid('id')->primary(); + $table->foreignUuid('transaction_id'); $table->double('total',10); $table->timestamp('due_date'); - $table->enum('status',['partial refund','deny','pending'])->default('Pending'); + $table->enum('status',['partial refund','deny','pending'])->default('pending'); + $table->text('complaint'); $table->timestamps(); - $table->foreign('order_id')->on('transactions')->references('id'); + $table->foreign('transaction_id')->on('transactions')->references('id'); }); } diff --git a/database/migrations/2023_08_27_074453_create_settings_table.php b/database/migrations/2023_08_27_074453_create_settings_table.php index ce097fd2..7e00fa20 100644 --- a/database/migrations/2023_08_27_074453_create_settings_table.php +++ b/database/migrations/2023_08_27_074453_create_settings_table.php @@ -12,11 +12,12 @@ return new class extends Migration public function up(): void { Schema::create('settings', function (Blueprint $table) { - $table->id(); - $table->string('bulan',20); + $table->uuid('id')->primary(); + $table->string('bulan',5); $table->string('tahun',5); - $table->integer('persentase'); - $table->enum('status',['Active', 'Nonactive']); + $table->float('persentase'); + $table->enum('status',['Active', 'Nonactive'])->default('Active'); + $table->unique(['bulan','tahun']); $table->timestamps(); }); } diff --git a/database/migrations/2023_09_01_044300_create_contacts_table.php b/database/migrations/2023_09_01_044300_create_contacts_table.php index 94371bdd..5a245248 100644 --- a/database/migrations/2023_09_01_044300_create_contacts_table.php +++ b/database/migrations/2023_09_01_044300_create_contacts_table.php @@ -12,7 +12,7 @@ return new class extends Migration public function up(): void { Schema::create('contacts', function (Blueprint $table) { - $table->id(); + $table->uuid('id')->primary(); $table->string('pemilik_kontak'); $table->string('relasi_kontak'); $table->foreign('pemilik_kontak')->on('users')->references('email'); diff --git a/database/migrations/2023_09_04_022513_create_transaction_descriptions_table.php b/database/migrations/2023_09_04_022513_create_transaction_descriptions_table.php index 43098c4d..e409f3ce 100644 --- a/database/migrations/2023_09_04_022513_create_transaction_descriptions_table.php +++ b/database/migrations/2023_09_04_022513_create_transaction_descriptions_table.php @@ -13,15 +13,17 @@ return new class extends Migration { Schema::create('transaction_descriptions', function (Blueprint $table) { $table->id(); - $table->foreignUuid('order_id'); + $table->foreignUuid('transaction_id'); $table->string('status',15); $table->string('user'); $table->string('background'); $table->string('judul'); $table->string('deskripsi'); + $table->string('status_code')->nullable(); + $table->string('bukti_foto')->nullable(); $table->timestamps(); - $table->foreign('order_id')->on('transactions')->references('id'); + $table->foreign('transaction_id')->on('transactions')->references('id'); $table->foreign('user')->on('users')->references('email'); }); } diff --git a/database/migrations/2023_09_04_023526_create_refund_descriptions_table.php b/database/migrations/2023_09_04_023526_create_refund_descriptions_table.php index 6481bc8a..6e2ef9fa 100644 --- a/database/migrations/2023_09_04_023526_create_refund_descriptions_table.php +++ b/database/migrations/2023_09_04_023526_create_refund_descriptions_table.php @@ -13,7 +13,7 @@ return new class extends Migration { Schema::create('refund_descriptions', function (Blueprint $table) { $table->id(); - $table->foreignId('refund_id'); + $table->foreignUuid('refund_id'); $table->string('filename'); $table->string('type'); $table->timestamps(); diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 87bef331..e4eb484b 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -39,16 +39,17 @@ class DatabaseSeeder extends Seeder 'alamat' => $faker->address, 'nohp' => $faker->phoneNumber(), 'status' => 'Finished', - 'persentase_kemiripan' => '100%', + 'persentase_kemiripan' => 100, 'gender' => $faker->randomElement(['Laki-laki', 'Perempuan']), 'kode_kelurahan' => '1101012002', ]); User::factory(20)->create(); $now = Carbon::now()->tz('Asia/Jakarta'); - $bulan = $now->format('F'); + $bulan = $now->format('n'); $tahun = $now->year; Setting::create([ + 'id' => Str::uuid(), 'bulan' => $bulan, 'tahun' => $tahun, 'persentase' => 5, diff --git a/public/assets/audio/Renai Saiban_[Uwamono].mp3 b/public/assets/audio/Renai Saiban_[Uwamono].mp3 new file mode 100644 index 00000000..8d9c03df Binary files /dev/null and b/public/assets/audio/Renai Saiban_[Uwamono].mp3 differ diff --git a/public/assets/css/style.css b/public/assets/css/style.css index 5f31c320..818e49b7 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -242,7 +242,7 @@ select.form-control:not([size]):not([multiple]), .form-control:not(.form-control-sm):not(.form-control-lg) { font-size: 14px; padding: 10px 15px; - height: 42px; + height: auto; } textarea.form-control { diff --git a/public/assets/img/metode_pembayaran/alfamart.png b/public/assets/img/metode_pembayaran/alfamart.png new file mode 100644 index 00000000..8e6a86ee Binary files /dev/null and b/public/assets/img/metode_pembayaran/alfamart.png differ diff --git a/public/assets/img/metode_pembayaran/bank_transfer.png b/public/assets/img/metode_pembayaran/bank_transfer.png new file mode 100644 index 00000000..284f7b20 Binary files /dev/null and b/public/assets/img/metode_pembayaran/bank_transfer.png differ diff --git a/public/assets/img/metode_pembayaran/bca.png b/public/assets/img/metode_pembayaran/bca.png new file mode 100644 index 00000000..8700dd52 Binary files /dev/null and b/public/assets/img/metode_pembayaran/bca.png differ diff --git a/public/assets/img/metode_pembayaran/bri.png b/public/assets/img/metode_pembayaran/bri.png new file mode 100644 index 00000000..c2b6f468 Binary files /dev/null and b/public/assets/img/metode_pembayaran/bri.png differ diff --git a/public/assets/img/metode_pembayaran/bri_epay.png b/public/assets/img/metode_pembayaran/bri_epay.png new file mode 100644 index 00000000..25249a8b Binary files /dev/null and b/public/assets/img/metode_pembayaran/bri_epay.png differ diff --git a/public/assets/img/metode_pembayaran/gopay.png b/public/assets/img/metode_pembayaran/gopay.png new file mode 100644 index 00000000..e6788f2d Binary files /dev/null and b/public/assets/img/metode_pembayaran/gopay.png differ diff --git a/public/assets/img/metode_pembayaran/indomaret.png b/public/assets/img/metode_pembayaran/indomaret.png new file mode 100644 index 00000000..fdb90b77 Binary files /dev/null and b/public/assets/img/metode_pembayaran/indomaret.png differ diff --git a/public/assets/img/metode_pembayaran/mandiri.png b/public/assets/img/metode_pembayaran/mandiri.png new file mode 100644 index 00000000..3fd96a63 Binary files /dev/null and b/public/assets/img/metode_pembayaran/mandiri.png differ diff --git a/public/assets/img/metode_pembayaran/qris.png b/public/assets/img/metode_pembayaran/qris.png new file mode 100644 index 00000000..9b0cb198 Binary files /dev/null and b/public/assets/img/metode_pembayaran/qris.png differ diff --git a/public/assets/js/page/modules-datatables.js b/public/assets/js/page/modules-datatables.js index bc155477..7759c29d 100644 --- a/public/assets/js/page/modules-datatables.js +++ b/public/assets/js/page/modules-datatables.js @@ -55,3 +55,9 @@ $("#table-3").dataTable({ columnDefs: [{ sortable: false, targets: [7] }], searchable: true, }); + +// Refund Admin +$("#table-4").dataTable({ + columnDefs: [{ sortable: false, targets: [8] }], + searchable: true, +}); diff --git a/public/assets/js/progress_bar/progress_bar.js b/public/assets/js/progress_bar/progress_bar.js new file mode 100644 index 00000000..dcfbb352 --- /dev/null +++ b/public/assets/js/progress_bar/progress_bar.js @@ -0,0 +1,9 @@ +var modal = document.getElementById("modalProgressBar"); + +function showLoading() { + $(modal).modal("show"); +} + +function hideLoading() { + $(modal).modal("hide"); +} diff --git a/public/assets/js/user/new-transaction.js b/public/assets/js/user/new-transaction.js new file mode 100644 index 00000000..3febd2c8 --- /dev/null +++ b/public/assets/js/user/new-transaction.js @@ -0,0 +1,287 @@ +$(document).ready(function () { + let totalHarga = 0; + let biayaAdmin = persentaseKeuntungan; + let totalBiayaAdmin = 0; + let totalBayar = 0; + + function tampilTotalHarga(harga) { + let tampilTotalNominal = document.getElementById("totalBiaya"); + let tampilTotalBiaya = document.getElementById("totalBayar"); + let tampilTotalBiayaAdmin = document.getElementById("totalBiayaAdmin"); + totalBiayaAdmin = (harga * biayaAdmin) / 100; + totalBayar = totalBiayaAdmin + harga; + tampilTotalNominal.innerHTML = harga.toLocaleString("id-ID", { + style: "currency", + currency: "IDR", + }); + tampilTotalBiaya.innerHTML = totalBayar.toLocaleString("id-ID", { + style: "currency", + currency: "IDR", + }); + tampilTotalBiayaAdmin.innerHTML = totalBiayaAdmin.toLocaleString( + "id-ID", + { + style: "currency", + currency: "IDR", + } + ); + } + + $("#selectContact").select2({ + placeholder: "Pilih Kontak", + ajax: { + url: "{{ route('user-contact.get') }}", + processResults: function ({ data }) { + return { + results: $.map(data, function (item) { + return { + id: item.relasi_kontak, + text: item.nama_depan + " " + item.nama_belakang, + }; + }), + }; + }, + }, + }); + + $("#hargaBarang").change(function () { + let harga = $(this).val(); + let jumlah = $("#jumlahBarang").val(); + let biaya = document.getElementById("totalBiaya"); + if (harga.trim() != "") { + if (jumlah.trim() != "") { + totalHarga = harga * jumlah; + } else { + totalHarga = harga * 0; + } + tampilTotalHarga(totalHarga); + } + }); + + $("#jumlahBarang").change(function () { + let jumlah = $(this).val(); + let harga = $("#hargaBarang").val(); + let nominal = document.getElementById("jumlah"); + if (jumlah.trim() != "") { + if (jumlah == 0) { + nominal.innerHTML = "Nominal"; + } else { + nominal.innerHTML = "Nominal (x" + jumlah + ")"; + } + if (harga.trim() != "") { + totalHarga = harga * jumlah; + } else { + totalHarga = 0 * jumlah; + } + tampilTotalHarga(totalHarga); + } + }); + + $("#selectContact").change(function () { + let email = $("#selectContact").val(); + if (email === null) { + $("#inputPenjual").prop("disabled", false); + $("#checkButton").prop("disabled", false); + $("#deleteOption").prop("disabled", false); + } else { + $("#inputPenjual").prop("disabled", true); + $("#deleteOption").prop("disabled", false); + $("#checkButton").prop("disabled", true); + } + }); + + $("#deleteOption").click(function () { + $("#selectContact").val(null).trigger("change"); + }); + + $("#inputPenjual").on("input", function () { + let emailInput = $("#inputPenjual").val(); + if (emailInput.trim() == "") { + $("#selectContact").prop("disabled", false); + $("#deleteOption").prop("disabled", false); + } else { + $("#selectContact").prop("disabled", true); + $("#deleteOption").prop("disabled", true); + } + }); + + $("#checkButton").click(function () { + let email = document.querySelector('[name="input_penjual"]').value; + const csrfToken = $('meta[name="csrf-token"]').attr("content"); + + if (email.trim() == "") { + Swal.fire({ + title: "Gagal", + text: "Email tidak boleh kosong", + icon: "error", + }); + } else { + if (email != "{{ Auth::user()->email }}") { + $.ajaxSetup({ + headers: { + "X-CSRF-TOKEN": csrfToken, + }, + }); + + $.ajax({ + url: "{{ route('user-contact.email', ':email') }}".replace( + ":email", + email + ), + type: "GET", + success: function (response) { + if ( + response.status && + (response.message.nama_bank == null || + response.message.nama_bank == "") && + (response.message.no_rek == null || + response.message.no_rek == "") + ) { + Swal.fire({ + title: "Berhasil", + text: "Akun tersedia", + icon: "success", + }); + } else { + Swal.fire({ + title: "Gagal", + text: response.message, + icon: "error", + }); + } + }, + error: function (error) { + Swal.fire({ + title: "Gagal", + text: "Terjadi error karena, " + error, + icon: "error", + }); + }, + }); + } else { + Swal.fire({ + title: "Gagal", + text: "Email penjual tidak boleh sama denggan email pembeli", + icon: "error", + }); + } + } + }); + + $("#save").on("click", function () { + let opsiKontak = document.querySelector( + '[name="select_penjual"]' + ).value; + let inputKontak = document.querySelector( + '[name="input_penjual"]' + ).value; + let namaBarang = document.querySelector('[name="nama_barang"]').value; + let hargaBarang = document.querySelector('[name="harga_barang"]').value; + let satuanBarang = document.querySelector( + '[name="satuan_barang"]' + ).value; + let jumlahBarang = document.querySelector( + '[name="jumlah_barang"]' + ).value; + let deskripsi = document.querySelector( + 'textarea[name="deskripsi"]' + ).value; + + let emptyInput = []; + + let penjual = ""; + if (opsiKontak != "" && inputKontak != "") { + penjual = opsiKontak; + } else if (opsiKontak == "" && inputKontak != "") { + penjual = inputKontak; + } else if (inputKontak == "" && opsiKontak != "") { + penjual = opsiKontak; + } else { + emptyInput.push("Kolom penjual tidak boleh kosong"); + } + + if (penjual == "{{ Auth::user()->email }}") { + emptyInput.push( + "Email penjual tidak boleh sama dengan email pembeli" + ); + } + + if (namaBarang == "") { + emptyInput.push("Nama barang tidak boleh kosong"); + } + + if (hargaBarang == "") { + emptyInput.push("Harga barang tidak boleh kosong"); + } + + if (satuanBarang == "") { + emptyInput.push("Satuan barang tidak boleh kosong"); + } + + if (jumlahBarang == "") { + emptyInput.push("Jumlah barang tidak boleh kosong"); + } + + if (emptyInput.length > 0) { + const emptyInputError = emptyInput.join(", "); + Swal.fire({ + title: "Gagal", + text: emptyInputError, + icon: "error", + confirmButtonText: "OK", + }); + } else { + const csrfToken = $('meta[name="csrf-token"]').attr("content"); + const formData = new FormData(); + formData.append("email_penjual", penjual); + formData.append("nama_barang", namaBarang); + formData.append("satuan_barang", satuanBarang); + formData.append("harga_barang", hargaBarang); + formData.append("jumlah_barang", jumlahBarang); + // formData.append('batas_pengiriman', batasPengiriman); + formData.append("deskripsi", deskripsi); + formData.append("persentase_keuntungan", biayaAdmin); + formData.append("total_keuntungan", totalBiayaAdmin); + formData.append("total_harga", totalHarga); + formData.append("total_bayar", totalBayar); + + $(modal).modal("show"); + + $.ajaxSetup({ + headers: { + "X-CSRF-TOKEN": csrfToken, + }, + }); + + $.ajax({ + url: "{{ route('store-transaction.pembeli') }}", + type: "POST", + data: formData, + processData: false, + contentType: false, + success: function (response) { + $(modal).modal("hide"); + Swal.fire({ + title: response.status ? "Berhasil" : "Gagal", + text: response.message, + icon: response.status ? "success" : "error", + confirmButtonText: "OK", + }).then(function () { + location.href = + "{{ route('user-transaction.index.pembeli') }}"; + }); + console.log(response); + }, + error: function (error) { + $(modal).modal("hide"); + Swal.fire({ + title: "Gagal", + text: "Gagal mengirimkan data karena " + error, + icon: "error", + }); + console.log(error); + }, + }); + } + }); +}); diff --git a/resources/views/Admin/layout/header.blade.php b/resources/views/Admin/layout/header.blade.php index 8781a208..1ded9b13 100644 --- a/resources/views/Admin/layout/header.blade.php +++ b/resources/views/Admin/layout/header.blade.php @@ -3,11 +3,10 @@
+ diff --git a/resources/views/Admin/profile/index.blade.php b/resources/views/Admin/profile/index.blade.php index 21ada313..6f2fb6cd 100644 --- a/resources/views/Admin/profile/index.blade.php +++ b/resources/views/Admin/profile/index.blade.php @@ -9,9 +9,10 @@ style="border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); position: relative; background: linear-gradient(45deg, #f3f3f3, #e0e0e0);"> - Profile -

Nurul Prima Annisa

-
#1238dsbias0-30832bjs
+ {{ Auth::user()->nama_depan }} +

{{ Auth::user()->nama_depan . ' ' . Auth::user()->nama_belakang }}

+
#{{ Auth::user()->id }}
@@ -20,114 +21,104 @@ +
-
-
About
-

Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul - prima - annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa - Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima annisa Nurul prima - annisa Nurul prima annisa -

+ {{-- Detail Profil --}} +
-
Profile Details
+
Detail Profil
-
Full Name
-
Nurul Prima Annisa
-
- -
-
Company
-
Ya apa yak
-
- -
-
Job
-
Frontend Web
-
- -
-
Country
-
Indonesia
-
- -
-
Address
-
Depok city broww
-
- -
-
Phone
-
(+62) 486-3538 29071
+
Nama Lengkap
+
+ {{ Auth::user()->nama_depan . ' ' . Auth::user()->nama_belakang }}
Email
-
npannisa23@gmail.com
+
{{ Auth::user()->email }}
+
+ +
+
No. HP
+
{{ Auth::user()->nohp }}
+
+ +
+
Negara
+
Indonesia
+
+ +
+
Provinsi
+
{{ Auth::user()->getProvinceName() }}
+
+ +
+
Kota/Kabupaten
+
{{ Auth::user()->getCityName() }}
+
+ +
+
Kecamatan
+
{{ Auth::user()->getDistrictName() }}
+
+ +
+
Kelurahan
+
{{ Auth::user()->getVillageName() }}
+
+ + +
+
Alamat
+
{{ Auth::user()->alamat }}
+
+ +
+
Nama Bank/e-Wallet Tujuan
+
Dana
+
+ +
+
Nomor Rekening/e-Wallet Tujuan
+
088376473
+ {{-- Edit Profile --}}
- - -
+ + @csrf
- +
- Profile + Profile
@@ -136,163 +127,164 @@
- -
- + +
+ +
+
+
- +
- + +
+ +
+
- +
- +
- +
- +
- +
- +
- +
- +
- -
- + +
+
-
- -
- -
- -
-
- - {{--
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
--}} - - - - -
- -
- - -
- -
- -
-
- - -
-
- - -
-
- - -
-
- - -
+
+
- + Simpan
- - +
+ {{-- Edit Profil --}} + {{-- Change Password --}}
-
-
- +
@@ -300,15 +292,16 @@
- +
- +
@@ -316,24 +309,23 @@
- +
- - +
+ {{-- Change Password --}} -
- +
+ {{-- profile --}} + {{-- profile --}} @endsection diff --git a/resources/views/Admin/refund/detail-refund.blade.php b/resources/views/Admin/refund/detail-refund.blade.php index ad9db847..ebaaae97 100644 --- a/resources/views/Admin/refund/detail-refund.blade.php +++ b/resources/views/Admin/refund/detail-refund.blade.php @@ -6,60 +6,69 @@

Detail

- - - + +
- @foreach ($detail_refund as $DetailRefund) -
-
-

Image/Video

- Return Image - Return Image - Return Image -

-
-
ID Order
-
{{ $DetailRefund['orderId'] }}
-

-
-
Customer Name
-
{{ $DetailRefund['customer'] }}
-

-
-
Seller Name
-
{{ $DetailRefund['seller'] }}
-

-
-
Total
-
{{ $DetailRefund['total'] }}
-

-
-
Due Date
-
{{ $DetailRefund['date'] }}
-

-
-
Reason Complaint
-
{{ $DetailRefund['complaint'] }}
+
+
+

Image/Video

+ @foreach ($descriptions as $description) + @if ($description->type == 'image') + Return Image + @endif + @if ($description->type == 'videos') +
-
+ @endif +
- @endforeach +
+
- -
@include('admin.refund.modal-next-detail-refund') diff --git a/resources/views/Admin/refund/index.blade.php b/resources/views/Admin/refund/index.blade.php index 8193442f..7c2b94db 100644 --- a/resources/views/Admin/refund/index.blade.php +++ b/resources/views/Admin/refund/index.blade.php @@ -5,28 +5,29 @@

History Refund

- + - + {{-- --}}
- +
- - + + - - + + + @@ -34,22 +35,22 @@ - - - - + + + + + diff --git a/resources/views/Admin/setting/index.blade.php b/resources/views/Admin/setting/index.blade.php index cf946aea..9afe5051 100644 --- a/resources/views/Admin/setting/index.blade.php +++ b/resources/views/Admin/setting/index.blade.php @@ -3,10 +3,10 @@
-

Setting

+

Kebijakan Keuntungan

- +
@@ -14,7 +14,7 @@
Add Data + data-target="#ModalSetting">Tambah Data Kebijakan
# Order IDCustomerSellerPembeliPenjual TotalDue Date StatusActionTanggal PengajuanBatas KonfirmasiAksi
{{ $loop->iteration }} {{ $refund->orderId }}{{ $refund['customer'] }}{{ $refund['seller'] }}{{ $refund['total'] }}{{ $refund['date'] }}{{ $refund->orders->pembeli }}{{ $refund->orders->penjual }}{{ $refund->total }}
{{ $refund->status }}
{{ $refund->created_at }}{{ $refund->due_date }}
@@ -32,10 +32,9 @@ @foreach ($settings as $setting) - + - {{-- --}} - + diff --git a/resources/views/User/layout/main.blade.php b/resources/views/User/layout/main.blade.php index 1134f3b5..a2b5caca 100644 --- a/resources/views/User/layout/main.blade.php +++ b/resources/views/User/layout/main.blade.php @@ -45,31 +45,21 @@ - + - - - - - - {{-- - --}} - + {{-- CSS Libraries --}} + + + + {{-- JS --}} - {{-- --}} @@ -93,9 +83,34 @@ @include('user.layout.footer') - + + + + + + + + + + + + + + + + + + + + + + i + + + + - - - - - - - - - - - - {{-- --}} - - - {{-- --}} - - - - - - {{-- --}} - - {{-- --}} - - - - - - - i - - - diff --git a/resources/views/User/layout/progress-bar.blade.php b/resources/views/User/layout/progress-bar.blade.php new file mode 100644 index 00000000..06428d6e --- /dev/null +++ b/resources/views/User/layout/progress-bar.blade.php @@ -0,0 +1,15 @@ + diff --git a/resources/views/User/layout/sidebar.blade.php b/resources/views/User/layout/sidebar.blade.php index e08cce1d..37f64491 100644 --- a/resources/views/User/layout/sidebar.blade.php +++ b/resources/views/User/layout/sidebar.blade.php @@ -47,12 +47,6 @@ - - {{-- --}} diff --git a/resources/views/User/refund/new-refund.blade.php b/resources/views/User/refund/new-refund.blade.php index c31f9009..fe866e59 100644 --- a/resources/views/User/refund/new-refund.blade.php +++ b/resources/views/User/refund/new-refund.blade.php @@ -7,33 +7,39 @@
-
-
-

Form Refund Pesanan

-
-
-
Reason Complaint
-
- - + + @csrf +
+
+

Form Refund Pesanan

+ +
+
Reason Complaint
+
+ + +
-
Upload Image / Video
-
- - +
Upload Image / Video
+
+ + +
+ +
+
-
-
- -
+
+ +
@@ -57,10 +63,80 @@
{{-- akhir modal konfirmasi --}} + + + @endsection diff --git a/resources/views/User/transaction/Pembeli/detail-transaction.blade.php b/resources/views/User/transaction/Pembeli/detail-transaction.blade.php index 3e476485..af421034 100644 --- a/resources/views/User/transaction/Pembeli/detail-transaction.blade.php +++ b/resources/views/User/transaction/Pembeli/detail-transaction.blade.php @@ -91,28 +91,6 @@ -
-
-
- Tanggal Transaksi:
- {{ $transaction->created_at }}

-
-
-
-
- Metode Pembayaran:
- Visa ending **** 4242
- npannisa@gmail.com -
-
-
-
- Tanggal Pembayaran:
- {{ $transaction->updated_at }}

- {{-- {{$transaction->tanggal_pembayaran}}

--}} -
-
-
@@ -142,12 +120,10 @@
Payment Method
-

{{ $transaction->metode_pembayaran }}

- visa - jcb - mastercard - paypal + @if ($transaction->metode_pembayaran != null) + {{$transaction->metode_pembayaran}} + @endif
@@ -175,13 +151,6 @@

- {{--
- @if ($transaction->metode_pembayaran == "qris") - - - @endif - -
--}} @@ -189,97 +158,4 @@ - {{-- - --}} @endsection diff --git a/resources/views/User/transaction/Pembeli/index.blade.php b/resources/views/User/transaction/Pembeli/index.blade.php index d036e4c5..0a51f496 100644 --- a/resources/views/User/transaction/Pembeli/index.blade.php +++ b/resources/views/User/transaction/Pembeli/index.blade.php @@ -68,6 +68,7 @@ href="{{ route('user-transaction.detail.pembeli', $transaction->id) }}">Detail + {{-- di midtrans statusnya settlement --}} @if ($transaction->status == 'sended')
  • @endif - @if ($transaction->status == 'pending') + @if (in_array($transaction->status, ['pending', 'created']))
  • @endif + @if (in_array($transaction->status, ['pending', 'authorize', 'capture', 'created'])) +
  • Batal
  • + @endif + @if (!$transaction->transactionDescription->isEmpty())
  • + + @extends('user.transaction.pembeli.modal-end-transaction') @extends('user.transaction.pembeli.modal-tracking') @extends('user.transaction.pembeli.modal-keterangan-status') @@ -121,21 +132,17 @@ snap.pay(token, { onSuccess: function(result) { - const formData = new FormData(); - formData.append('status', result.transaction_status); - formData.append('tanggal_pembayaran', result.transaction_time); - formData.append('metode_pembayaran', result.payment_type); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': csrfToken } }); + $.ajax({ url: "{{ route('payment-transaction.pembeli', ':id') }}" .replace(':id', id), type: "POST", - data: formData, contentType: false, processData: false, success: function(response) { @@ -146,6 +153,8 @@ icon: response.status ? 'success' : 'error', confirmButtonText: 'OK' + }).then(function() { + location.reload(); }); console.log(response); }, @@ -155,19 +164,74 @@ text: 'Gagal mengupdate pembayaran ke database', icon: 'error' }); + console.log(result); } }); console.log(result); }, onPending: function(result) { - Swal.fire({ - title: 'Ditunda', - text: 'Pemabayaran ditunda. Silahkan lakukan pembayaran nanti', - icon: 'info' + $.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': csrfToken + } + }); + + $.ajax({ + url: "{{ route('payment-transaction.pembeli', ':id') }}" + .replace(':id', id), + type: "POST", + contentType: false, + processData: false, + success: function(response) { + Swal.fire({ + title: 'Berhasil', + text: response.message, + icon: 'info', + confirmButtonText: 'OK' + }); + console.log(response); + }, + error: function(error) { + Swal.fire({ + title: 'Gagal', + text: 'Gagal mengupdate pembayaran ke database', + icon: 'error' + }); + console.log(error); + } }); console.log(result); }, onError: function(result) { + $.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': csrfToken + } + }); + + $.ajax({ + url: "{{ route('payment-transaction.pembeli', ':id') }}" + .replace(':id', id), + type: "POST", + contentType: false, + processData: false, + success: function(response) { + Swal.fire({ + title: 'Gagal', + text: response.message, + icon: 'error', + }); + console.log(response); + }, + error: function(error) { + Swal.fire({ + title: 'Gagal', + text: 'Gagal mengupdate pembayaran ke database', + icon: 'error' + }); + console.log(error); + } + }); Swal.fire({ title: 'Gagal', text: 'Terjadi kesalahan karena ' + result, @@ -185,6 +249,55 @@ } }); }); + + $('#table-3').on('click', '#cancel', function() { + const id = $(this).data('id'); + const csrfToken = $('meta[name="csrf-token"]').attr('content'); + + Swal.fire({ + title: 'Batal Transaksi?', + text: 'Apakah anda yakin batal transaksi?', + icon: 'info', + showCancelButton: true, + confirmButtonText: 'Ya, batal', + cancelButtonText: 'Tidak', + }).then((result) => { + if (result.isConfirmed) { + $.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': csrfToken + } + }); + + $.ajax({ + url: "{{ route('cancel-transaction.pembeli', ':id') }}" + .replace(':id', id), + type: "POST", + contentType: false, + processData: false, + success: function(response) { + Swal.fire({ + title: response.status ? 'Berhasil' : + 'Gagal', + text: response.message, + icon: response.status ? 'success' : 'error' + }).then(function() { + location.reload(); + }); + console.log(response); + }, + error: function(error) { + Swal.fire({ + title: 'Gagal', + text: response.message, + icon: 'error' + }); + console.log(error); + } + }); + } + }); + }); }); @@ -246,28 +359,21 @@ var modal = $(this); activitiesHtml += ` - Pesanan Belum diterima - Pesanan diterima - Refund + Selesaikan Transaksi + Ajukan Komplain `; modal.find('.modal-footer').html(activitiesHtml); console.log(id); }); - //pesanan belum datang - $('#modalFinish').on('click', '#orderHasNotReceived', function() { + // selesai + $('#modalFinish').on('click', '#finishTransaction', function() { var id = $(this).data('id'); console.log(id); }); - //selesai - $('#modalFinish').on('click', '#orderHasReceived', function() { - var id = $(this).data('id'); - console.log(id); - }); - - // refund - $('#modalFinish').on('click', '#refund', function() { + // complain + $('#modalFinish').on('click', '#complain', function() { var id = $(this).data('id'); console.log(id); }); diff --git a/resources/views/User/transaction/Pembeli/modal-keterangan-status.blade.php b/resources/views/User/transaction/Pembeli/modal-keterangan-status.blade.php index b1b1e665..353ba267 100644 --- a/resources/views/User/transaction/Pembeli/modal-keterangan-status.blade.php +++ b/resources/views/User/transaction/Pembeli/modal-keterangan-status.blade.php @@ -1,70 +1,70 @@ -
  • {{ $loop->iteration }}{{ DateTime::createFromFormat('!m', $setting->bulan)->format('F') }}{{ DateTime::createFromFormat('n', $setting->bulan)->format('F') }} {{ $setting->tahun }} {{ $setting->persentase }}
    @@ -76,7 +75,8 @@ const rowData = table.row(parentRow).data(); // Dapatkan data baris dari DataTable $.ajax({ - url: "{{ route('admin-setting.update', ':admin_setting') }}".replace(':admin_setting', dataId), + url: "{{ route('admin-setting.update', ':admin_setting') }}".replace( + ':admin_setting', dataId), type: 'PUT', data: { _token: csrfToken, @@ -104,10 +104,78 @@ }, error: function(error) { Swal.fire({ - title:'Error!', - text:'Terjadi error, '+error, - icon:'error', - confirmButtonText : 'OK' + title: 'Error!', + text: 'Terjadi error, ' + error, + icon: 'error', + confirmButtonText: 'OK' + }); + } + }); + }); + + $("#bulan").select2(); + + $('#formTambahSetting').on('submit', function(e) { + e.preventDefault(); + + let form = this; + + if (!form.checkValidity()) { + form.reportValidity(); + return; + } + + let formData = new FormData(this); + + Swal.fire({ + html: '

    Form Anda sedang diproses!

    Mohon tunggu...

    ', + allowEscapeKey: false, + allowOutsideClick: false, + didOpen: () => { + Swal.showLoading() + } + }); + + $.ajax({ + type: 'POST', + url: `{{ route('admin-setting.store') }}`, + data: formData, + proccessData: false, + contentType: false, + success: function(response) { + Swal.fire({ + title: response.status ? 'Berhasil!' : 'Gagal!', + text: response.message, + icon: response.status ? 'success' : 'error', + confirmButtonText: 'OK', + position: 'center', + }).then(function() { + // location.reload(); + Swal.close(); + if (response.status) { + $('#table-2').DataTable().draw(); + form.reset(); + } + }); + }, + error: function(error) { + console.log(error.responseText) + + var response = JSON.parse(error.responseText); + + var errorMessage = ''; + + for (var key in response.errors) { + if (response.errors.hasOwnProperty(key)) { + errorMessage += response.errors[key][0] + '
    '; + } + } + Swal.fire({ + position: 'center', + icon: 'error', + title: 'Terjadi Kesalahan', + html: errorMessage, + showConfirmButton: true }); } }); diff --git a/resources/views/Admin/setting/modal-add-setting.blade.php b/resources/views/Admin/setting/modal-add-setting.blade.php index f03ab0c7..4a90639f 100644 --- a/resources/views/Admin/setting/modal-add-setting.blade.php +++ b/resources/views/Admin/setting/modal-add-setting.blade.php @@ -2,17 +2,17 @@ aria-hidden="true">
    {{ $user->id }}
    - ... + ...
    {{ $user->nama_depan.' '.$user->nama_belakang }}{{ $user->nama_depan . ' ' . $user->nama_belakang }} {{ $user->email }} {{ $user->created_at }} @@ -106,8 +107,7 @@ icon: response.status ? 'success' : 'error', confirmButtonText: 'OK' }).then(function() { - // location.reload(); - console.log(response); + location.reload(); }); }, error: function(error) { diff --git a/resources/views/User/contact/index.blade.php b/resources/views/User/contact/index.blade.php index 5939331e..32fb370a 100644 --- a/resources/views/User/contact/index.blade.php +++ b/resources/views/User/contact/index.blade.php @@ -54,8 +54,7 @@ data-city="{{ $contact->relasiKontak->getCityName() }}" data-district="{{ $contact->relasiKontak->getDistrictName() }}" data-village="{{ $contact->relasiKontak->getVillageName() }}">Detail -