First Commit
This commit is contained in:
parent
edb574db71
commit
8f71500bf1
89
app/Http/Controllers/User/UserRefundController.php
Normal file
89
app/Http/Controllers/User/UserRefundController.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
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', [
|
||||
'refunds' => Refund::join('transactions', 'refunds.transaction_id', '=', 'transactions.id')
|
||||
->where('transactions.pembeli', auth()->user()->email)
|
||||
->select()
|
||||
]);
|
||||
}
|
||||
|
||||
public function create($id)
|
||||
{
|
||||
return view('user.refund.new-refund',['id' => $id]);
|
||||
}
|
||||
|
||||
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
|
||||
]);
|
||||
}
|
||||
}
|
499
app/Http/Controllers/User/UserTransactionController.php
Normal file
499
app/Http/Controllers/User/UserTransactionController.php
Normal file
@ -0,0 +1,499 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Midtrans\Config;
|
||||
use Midtrans\Snap;
|
||||
use Midtrans\Transaction as Trans;
|
||||
use Stichoza\GoogleTranslate\GoogleTranslate;
|
||||
use Throwable;
|
||||
|
||||
class UserTransactionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public function indexPembeli()
|
||||
{
|
||||
return view('user.transaction.pembeli.index', [
|
||||
'transactions' => Transaction::where('pembeli', Auth::user()->email)
|
||||
->latest()
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function indexPenjual()
|
||||
{
|
||||
return view('user.transaction.penjual.index', [
|
||||
'transactions' => Transaction::where('penjual', Auth::user()->email)
|
||||
->latest()
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return view('user.transaction.pembeli.detail-transaction', [
|
||||
'transaction' => Transaction::findOrFail($id),
|
||||
'trackings' => TransactionDescription::where('transaction_id', $id)
|
||||
->latest()
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 invoiceTransaction($id)
|
||||
{
|
||||
return view('user.transaction.pembeli.invoice-transaction', [
|
||||
'TransactionUser' => TransactionUser::HistoryTransaction(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$pembeli = Auth::user()->email;
|
||||
$penjual = $request->get('email_penjual');
|
||||
$nama_barang = $request->get('nama_barang');
|
||||
$satuan_barang = $request->get('satuan_barang');
|
||||
$deskripsi_transaksi = $request->get('deskripsi');
|
||||
$harga_barang = $request->get('harga_barang');
|
||||
$jumlah_barang = $request->get('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');
|
||||
$alamat = ucwords(strtolower(Auth::user()->alamat));
|
||||
$id = Uuid::uuid4();
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
$persentase_keuntungan = $request->get('persentase_keuntungan');
|
||||
|
||||
$total_harga = $request->get('total_harga');
|
||||
$total_keuntungan = $request->get('total_keuntungan');
|
||||
$total_bayar = $request->get('total_bayar');
|
||||
|
||||
$batas_pembayaran = $now->addDays(1)->toDateTimeString();
|
||||
$batas_pengiriman_barang_awal = $now->addDays(2)->toDateTimeString();
|
||||
$batas_pengiriman_barang_akhir = $now->addDays(4)->toDateTimeString();
|
||||
|
||||
$params = [
|
||||
'transaction_details' => [
|
||||
'order_id' => $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-transaction.index.pembeli'),
|
||||
],
|
||||
'enabled_payments' => [
|
||||
'credit_card', 'gopay', 'shopeepay'
|
||||
],
|
||||
'expiry' => [
|
||||
'start_time' => $now->format('Y-m-d H:i:s P'),
|
||||
'unit' => 'days',
|
||||
'duration' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
$snap_token = Snap::getSnapToken($params);
|
||||
$token = $snap_token;
|
||||
$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,
|
||||
'token' => $token,
|
||||
'status' => $status,
|
||||
'batas_pembayaran' => $batas_pembayaran,
|
||||
'batas_pengiriman_barang_awal' => $batas_pengiriman_barang_awal,
|
||||
'batas_pengiriman_barang_akhir' => $batas_pengiriman_barang_akhir,
|
||||
]);
|
||||
|
||||
$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($id)
|
||||
{
|
||||
$query = Transaction::where('id', $id)->update([
|
||||
'status' => 'process',
|
||||
]);
|
||||
if ($query) {
|
||||
TransactionDescription::create([
|
||||
'transaction_id' => $id,
|
||||
'status' => 'process',
|
||||
'background' => 'bg-seller',
|
||||
'user' => Auth::user()->email,
|
||||
'judul' => 'fas fa-handshake',
|
||||
'deskripsi' => 'Transaksi telah diterima oleh ' . Auth::user()->nama_depan,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Transaksi telah diterima. Siapkan pesanan untuk dikirim ke penjual.',
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Gagal update status karena kesalahan server.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
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.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
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.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
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.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function payTransaction($id)
|
||||
{
|
||||
// Membuat objek Google Translate
|
||||
$translator = new GoogleTranslate();
|
||||
|
||||
// Mengatur bahasa sumber (Inggris) dan bahasa target (Indonesia)
|
||||
$translator->setSource('en');
|
||||
$translator->setTarget('id');
|
||||
|
||||
$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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
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'));
|
||||
}
|
||||
}
|
@ -54,7 +54,33 @@ class transaction
|
||||
"status"=>"paid"
|
||||
]
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
];
|
||||
=======
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'pembeli',
|
||||
'penjual',
|
||||
'nama_barang',
|
||||
'deskripsi_transaksi',
|
||||
'satuan_barang',
|
||||
'harga_barang',
|
||||
'jumlah_barang',
|
||||
'persentase_keuntungan',
|
||||
'total_keuntungan',
|
||||
'total_harga',
|
||||
'total_bayar',
|
||||
'token',
|
||||
'status',
|
||||
'batas_pembayaran',
|
||||
'batas_pengiriman_barang_awal',
|
||||
'batas_pengiriman_barang_akhir',
|
||||
];
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
private static $detail_transaction=[
|
||||
[
|
||||
|
@ -34,7 +34,42 @@ $("#table-1").dataTable({
|
||||
]
|
||||
});
|
||||
$("#table-2").dataTable({
|
||||
<<<<<<< Updated upstream
|
||||
"columnDefs": [
|
||||
{ "sortable": false, "targets": [0,2,3] }
|
||||
]
|
||||
=======
|
||||
ordering: true,
|
||||
searchable: true,
|
||||
});
|
||||
|
||||
// Transaksi pembeli
|
||||
$("#table-3").dataTable({
|
||||
columnDefs: [{ sortable: false, targets: [6] }],
|
||||
searchable: true,
|
||||
});
|
||||
|
||||
// Refund, Transaction Admin
|
||||
$("#table-4").dataTable({
|
||||
columnDefs: [{ sortable: false, targets: [8] }],
|
||||
searchable: true,
|
||||
});
|
||||
|
||||
// Setting Admin
|
||||
$("#table-5").dataTable({
|
||||
columnDefs: [{ sortable: false, targets: [4, 5] }],
|
||||
searchable: true,
|
||||
});
|
||||
|
||||
// Contact User
|
||||
$("#table-6").dataTable({
|
||||
columnDefs: [{ sortable: false, targets: [4] }],
|
||||
searchable: true,
|
||||
>>>>>>> Stashed changes
|
||||
});
|
||||
|
||||
//Refund User
|
||||
$("#table-7").dataTable({
|
||||
columnDefs: [{ sortable: false, targets: [5] }],
|
||||
searchable: true,
|
||||
});
|
||||
|
73
resources/views/Admin/refund/index.blade.php
Normal file
73
resources/views/Admin/refund/index.blade.php
Normal file
@ -0,0 +1,73 @@
|
||||
@extends('layouts.main')
|
||||
@section('content')
|
||||
<div class="main-content">
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h1>Refund</h1>
|
||||
<div class="section-header-breadcrumb">
|
||||
<div class="breadcrumb-item active"><a href="{{ route('admin.index') }}">Dashboard</a></div>
|
||||
<div class="breadcrumb-item">Refund</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="table-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">
|
||||
#
|
||||
</th>
|
||||
<th>ID</th>
|
||||
<th>Pembeli</th>
|
||||
<th>Nama Barang</th>
|
||||
<th>Penjual</th>
|
||||
<th>Total</th>
|
||||
<th>Tanggal Pengajuan</th>
|
||||
<th>Batas Konfirmasi</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($refunds as $refund)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $refund->id }}</td>
|
||||
<td>{{ $refund->transaction->data_pembeli->nama_depan }}
|
||||
</td>
|
||||
<td>{{ $refund->transaction->nama_barang }}
|
||||
</td>
|
||||
<td>{{ $refund->transaction->data_penjual->nama_depan }}
|
||||
</td>
|
||||
<td>{{ $refund->total }}</td>
|
||||
<td>{{ $refund->created_at }}</td>
|
||||
<td>{{ $refund->due_date }}</td>
|
||||
<td><a href="#" data-toggle="modal" data-target="#modalKeteranganStatus"
|
||||
class="badge {{ $refund->status == 'partial refund' ? 'badge-succes' : ($refund->status == 'pending' ? 'badge-warning' : 'badge-danger') }}">{{ ucwords($refund->status) }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Aksi
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('admin-refund.show', $refund->id) }}">Detail</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@extends('admin.transaction.modal-keterangan-status')
|
||||
@endsection
|
260
resources/views/User/contact/index.blade.php
Normal file
260
resources/views/User/contact/index.blade.php
Normal file
@ -0,0 +1,260 @@
|
||||
@extends('layouts.main')
|
||||
@section('content')
|
||||
<div class="main-content">
|
||||
<section class="section">
|
||||
|
||||
<div class="section-header">
|
||||
<h1>Kontak</h1>
|
||||
<div class="section-header-breadcrumb">
|
||||
<div class="breadcrumb-item active"><a href="{{ route('user.index') }}">Dashboard</a></div>
|
||||
<div class="breadcrumb-item">Kontak</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- tabel list kontak --}}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-end">
|
||||
<button class="btn btn-primary btn-lg" data-toggle="modal"
|
||||
data-target="#modalForm">Tambahkan Kontak Baru</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="table-6">
|
||||
<thead>
|
||||
<tr class="text-center">
|
||||
<th>#</th>
|
||||
<th>Email</th>
|
||||
<th>Name</th>
|
||||
<th>Phone</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($contacts as $contact)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td class="font-weight-600">
|
||||
{{ $contact->relasiKontak->nama_depan . ' ' . $contact->relasiKontak->nama_belakang }}
|
||||
</td>
|
||||
<td class="text-center font-weight-600">{{ $contact->relasiKontak->email }}
|
||||
</td>
|
||||
<td class="text-center font-weight-600">{{ $contact->relasiKontak->nohp }}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<button class="btn btn-info open-detail-modal" data-toggle="modal"
|
||||
data-target="#modaldetail" id="detailContact"
|
||||
data-id="{{ $contact->relasiKontak }}"
|
||||
data-province="{{ $contact->relasiKontak->getProvinceName() }}"
|
||||
data-city="{{ $contact->relasiKontak->getCityName() }}"
|
||||
data-district="{{ $contact->relasiKontak->getDistrictName() }}"
|
||||
data-village="{{ $contact->relasiKontak->getVillageName() }}">Detail</button>
|
||||
<button class="btn btn-danger open-detail-modal" id="deleteContact"
|
||||
data-id="{{ $contact->id }}">Hapus</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@extends('user.contact.modal-detail-contact')
|
||||
@extends('user.contact.modal-add-contact')
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let check = false;
|
||||
var teksArea = document.getElementById('resultArea');
|
||||
var teksNama = document.getElementById('teksNama');
|
||||
var teksNohp = document.getElementById('teksNoHP');
|
||||
var teksEmail = document.getElementById('teksEmail');
|
||||
var teksAlamat = document.getElementById('teksAlamat');
|
||||
|
||||
$('#table-2').on('click', '#detailContact', function() {
|
||||
let dataId = $(this).data('id');
|
||||
let dataProvince = $(this).data('province');
|
||||
let dataCity = $(this).data('city');
|
||||
let dataDistrict = $(this).data('district');
|
||||
let dataVillage = $(this).data('village');
|
||||
teksNama.innerHTML = dataId.nama_depan + " " + dataId.nama_belakang;
|
||||
teksAlamat.innerHTML = dataId.alamat + ", " + capital(dataVillage) + ", " + capital(
|
||||
dataDistrict) + ", " + capital(dataCity) + ", " + capital(dataProvince);
|
||||
teksNohp.innerHTML = dataId.nohp;
|
||||
teksEmail.innerHTML = dataId.email;
|
||||
});
|
||||
|
||||
function capital(text) {
|
||||
return text.toLowerCase().replace(/(?:^|\s)\w/g, function(match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
$('#table-2').on('click', '#deleteContact', function() {
|
||||
let dataId = $(this).data('id');
|
||||
const csrfToken = $('meta[name="csrf-token"]').attr('content');
|
||||
Swal.fire({
|
||||
title: 'Hapus Kontak',
|
||||
text: 'Yakin hapus kontak ini?',
|
||||
icon: 'warning',
|
||||
confirmButtonText: 'Ya, Hapus!',
|
||||
showDenyButton: true,
|
||||
denyButtonText: 'Tidak, jangan hapus',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('user-contact.destroy', ':id') }}".replace(
|
||||
':id',
|
||||
dataId),
|
||||
type: 'DELETE',
|
||||
contentType: false,
|
||||
processType: false,
|
||||
success: function(response) {
|
||||
Swal.fire({
|
||||
title: response.status ? 'Berhasil' :
|
||||
'Gagal',
|
||||
text: response.message,
|
||||
icon: response.status ? 'success' : 'error',
|
||||
confirmButtonText: 'OK'
|
||||
}).then(function() {
|
||||
if (response.status == true) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(error) {
|
||||
Swal.fire({
|
||||
title: 'Gagal',
|
||||
text: "Terjadi error karena " + error
|
||||
.message,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (result.isDenied) {
|
||||
Swal.fire({
|
||||
title: 'Gagal',
|
||||
text: 'Tidak ada kontak yang dihapus',
|
||||
icon: 'info',
|
||||
confirmButtonText: 'OK',
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#checkButton').on('click', function() {
|
||||
const email = document.querySelector('[name="email"]').value;
|
||||
const csrfToken = $('meta[name="csrf-token"]').attr('content');
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('user-contact.email', ':email') }}".replace(':email', email),
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
let status = response.message[0].status
|
||||
Swal.fire({
|
||||
title: response.status ? 'Akun ditemukan' :
|
||||
'Akun tidak ditemukan',
|
||||
text: response.status ? 'Akun dengan email ' + email +
|
||||
' tersedia' : 'Akun dengan email ' + email +
|
||||
' tidak tersedia',
|
||||
icon: response.status ? 'success' : 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
let messages = response.message[0];
|
||||
let hasil = "Nama : " + messages.nama_depan + " " + messages
|
||||
.nama_belakang +
|
||||
"\n" + "Email : " + messages.email + "\n" + "No. HP : " +
|
||||
messages.nohp + "\n" + "Alamat : " + messages.alamat;
|
||||
teksArea.value = hasil;
|
||||
teksArea.style.height = 'auto';
|
||||
check = true;
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Gagal',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
check = false;
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
Swal.fire({
|
||||
title: 'Gagal!',
|
||||
text: 'Gagal memuat data karena ' + error,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK',
|
||||
});
|
||||
check = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#tambahkanContact').on('click', function() {
|
||||
const email = document.querySelector('[name="email"]').value;
|
||||
const csrfToken = $('meta[name="csrf-token"]').attr('content');
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('email', email);
|
||||
|
||||
if (check) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('user-contact.store') }}',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
Swal.fire({
|
||||
title: response.status ? 'Berhasil' : 'Gagal',
|
||||
text: response.message,
|
||||
icon: response.status ? 'success' : 'error',
|
||||
confirmButtonText: 'OK',
|
||||
}).then(function() {
|
||||
if (response.status == true) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
check = false;
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Gagal',
|
||||
text: 'Silahkan check email terlebih dahulu',
|
||||
icon: 'error',
|
||||
});
|
||||
check = false;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
68
resources/views/User/refund/index.blade.php
Normal file
68
resources/views/User/refund/index.blade.php
Normal file
@ -0,0 +1,68 @@
|
||||
@extends('layouts.main')
|
||||
@section('content')
|
||||
<div class="main-content">
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h1>Refund</h1>
|
||||
<div class="section-header-breadcrumb">
|
||||
<div class="breadcrumb-item active"><a href="{{ route('user.index') }}">Dashboard</a></div>
|
||||
<div class="breadcrumb-item">Refund</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="table-7">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">
|
||||
#
|
||||
</th>
|
||||
<th>Nama Barang</th>
|
||||
<th>Penjual</th>
|
||||
<th>Total</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($refunds as $refund)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $refund->transaction->nama_barang }}
|
||||
</td>
|
||||
<td>{{ $refund->transaction->data_penjual->nama_depan }}
|
||||
</td>
|
||||
<td>{{ $refund->total }}</td>
|
||||
<td><a href="#" data-toggle="modal"
|
||||
data-target="#modalKeteranganStatus"
|
||||
class="badge {{ $refund->status == 'partial refund' ? 'badge-succes' : ($refund->status == 'pending' ? 'badge-warning' : 'badge-danger') }}">{{ ucwords($refund->status) }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
Aksi
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('admin-refund.show', $refund->id) }}">Detail</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@endsection
|
396
resources/views/User/transaction/Pembeli/index.blade.php
Normal file
396
resources/views/User/transaction/Pembeli/index.blade.php
Normal file
@ -0,0 +1,396 @@
|
||||
@extends('layouts.main')
|
||||
@section('content')
|
||||
<div class="main-content">
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h1>Halaman Pembeli</h1>
|
||||
<div class="section-header-breadcrumb">
|
||||
<div class="breadcrumb-item active"><a href="{{ route('user.index') }}">Dashboard</a></div>
|
||||
<div class="breadcrumb-item">Transaksi Pembeli
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
<div class="hero bg-primary text-white">
|
||||
<div class="hero-inner">
|
||||
<h1>Selamat Datang! {{ Auth::user()->nama_depan }}</h1>
|
||||
<p class="lead">Mau belanja apa hari ini?</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end" style="margin-bottom: 20px">
|
||||
<a class="nav-link active" href="{{ route('user-pembeli.create') }}">
|
||||
<button class="btn btn-primary btn-lg">Lakukan Transaksi Baru</button>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="table-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">
|
||||
#
|
||||
</th>
|
||||
<th>Penjual</th>
|
||||
<th>Total</th>
|
||||
<th>Tanggal Transaksi</th>
|
||||
<th>Tanggal Update</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($transactions as $transaction)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $transaction->data_penjual->nama_depan . ' ' . $transaction->data_penjual->nama_belakang }}
|
||||
</td>
|
||||
<td>Rp {{ number_format($transaction->total_bayar, 2, ',', '.') }}</td>
|
||||
<td>{{ $transaction->created_at }}</td>
|
||||
<td>{{ $transaction->updated_at }}</td>
|
||||
<td><a href="#" data-toggle="modal"
|
||||
data-target="#modalKeteranganStatus"
|
||||
class="badge {{ in_array($transaction->status, ['pending', 'created'])
|
||||
? 'badge-light'
|
||||
: (in_array($transaction->status, ['settlement', 'capture'])
|
||||
? 'badge-info'
|
||||
: (in_array($transaction->status, ['process', 'sending', 'sended'])
|
||||
? 'badge-warning'
|
||||
: (in_array($transaction->status, ['cancel', 'expire', 'failure', 'refund'])
|
||||
? 'badge-danger'
|
||||
: ($transaction->status == 'finished'
|
||||
? 'badge-success'
|
||||
: '')))) }}">{{ ucwords($transaction->status) }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
Action
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item"
|
||||
href="{{ route('user-transaction.detail.pembeli', $transaction->id) }}">Detail</a>
|
||||
</li>
|
||||
|
||||
{{-- di midtrans statusnya settlement --}}
|
||||
@if ($transaction->status == 'sended')
|
||||
<li><a class="dropdown-item" data-toggle="modal"
|
||||
data-target="#modalFinish" id="tracking"
|
||||
data-id="{{ $transaction->id }}"
|
||||
href="#">Selesaikan</a>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
@if (in_array($transaction->status, ['pending', 'created']))
|
||||
<li><a class="dropdown-item" id="bayar"
|
||||
data-id="{{ $transaction->id }}"
|
||||
data-token="{{ $transaction->token }}"
|
||||
href="#">Bayar</a>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
@if (in_array($transaction->status, ['pending', 'authorize', 'capture', 'created']))
|
||||
<li><a href="#" data-id="{{ $transaction->id }}"
|
||||
id="cancel" class="dropdown-item">Batal</a></li>
|
||||
@endif
|
||||
|
||||
@if (!$transaction->transactionDescription->isEmpty())
|
||||
<li><a class="dropdown-item" data-toggle="modal"
|
||||
data-target="#modalTracking"
|
||||
data-transaction="{{ $transaction->transactionDescription }}">Tracking</a>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<!-- Tambahkan elemen progress bar ke tampilan Anda (dengan awalnya disembunyikan) -->
|
||||
<div class="progress" style="display: none;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0"
|
||||
aria-valuemax="100"></div>
|
||||
</div>
|
||||
@extends('user.transaction.pembeli.modal-end-transaction')
|
||||
@extends('user.transaction.pembeli.modal-tracking')
|
||||
@extends('user.transaction.pembeli.modal-keterangan-status')
|
||||
|
||||
<script type="text/javascript" src="https://app.sandbox.midtrans.com/snap/snap.js"
|
||||
data-client-key="SB-Mid-client-rk6kY5XbPLChy3Lg"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Bayar
|
||||
$('#table-3').on('click', '#bayar', function() {
|
||||
const id = $(this).data('id');
|
||||
const token = $(this).data('token');
|
||||
const csrfToken = $('meta[name="csrf-token"]').attr('content');
|
||||
|
||||
snap.pay(token, {
|
||||
onSuccess: function(result) {
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('user-pembeli.pay', ':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',
|
||||
confirmButtonText: 'OK'
|
||||
}).then(function() {
|
||||
location.reload();
|
||||
});
|
||||
console.log(response);
|
||||
},
|
||||
error: function(error) {
|
||||
Swal.fire({
|
||||
title: 'Gagal',
|
||||
text: 'Gagal mengupdate pembayaran ke database',
|
||||
icon: 'error'
|
||||
});
|
||||
console.log(result);
|
||||
}
|
||||
});
|
||||
console.log(result);
|
||||
},
|
||||
onPending: function(result) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('user-pembeli.pay', ':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('user-pembeli.pay', ':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,
|
||||
icon: 'error'
|
||||
});
|
||||
console.log(result);
|
||||
},
|
||||
onClose: function(error) {
|
||||
Swal.fire({
|
||||
title: 'Ditunda',
|
||||
text: 'Kamu menutup halaman pembayaran. Silahkan lakukan pembayaran nanti',
|
||||
icon: 'info'
|
||||
});
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#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('user-pembeli.cancel', ':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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{{-- Modal --}}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#modalTracking').on('show.bs.modal', function(event) {
|
||||
var triggerLink = $(event.relatedTarget); // Tombol yang memicu modal
|
||||
var transactionDatas = triggerLink.data('transaction'); // Ambil data dari tombol
|
||||
|
||||
// Buat variabel untuk menyimpan HTML aktivitas
|
||||
transactionDatas = transactionDatas.reverse();
|
||||
var activitiesHtml = '';
|
||||
|
||||
// Periksa apakah ada data transaksi
|
||||
if (transactionDatas && transactionDatas.length > 0) {
|
||||
// Iterasi melalui data transaksi dan tambahkan ke activitiesHtml
|
||||
$.each(transactionDatas, function(index, transactionDescription) {
|
||||
activitiesHtml += `
|
||||
<div class="activity">
|
||||
<div class="activity-icon ${transactionDescription.background} text-white shadow-primary">
|
||||
<i class="${transactionDescription.judul}" style="font-size: 36px;"></i>
|
||||
</div>
|
||||
<div class="activity-detail">
|
||||
<div class="mb-2">
|
||||
<span class="text-job text-primary">${new Date(transactionDescription.created_at).toLocaleString()}</span>
|
||||
</div>
|
||||
<p>${transactionDescription.deskripsi}</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
} else {
|
||||
// Tidak ada data transaksi, tambahkan pesan kosong
|
||||
activitiesHtml += `
|
||||
<div class="activity">
|
||||
<div class="activity-icon bg-primary text-white shadow-primary">
|
||||
<i class="fas fa-ban" style="font-size: 36px;"></i>
|
||||
</div>
|
||||
<div class="activity-detail">
|
||||
<div class="mb-2">
|
||||
<span class="text-job text-primary">--, --:--:-- --</span>
|
||||
</div>
|
||||
<p>Kosong</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// Menampilkan data dalam modal
|
||||
var modal = $(this);
|
||||
modal.find('.activities').html(activitiesHtml);
|
||||
});
|
||||
|
||||
$('#modalFinish').on('show.bs.modal', function(event) {
|
||||
var triggerLink = $(event.relatedTarget);
|
||||
var id = triggerLink.data('id');
|
||||
var activitiesHtml = '';
|
||||
|
||||
var modal = $(this);
|
||||
activitiesHtml += `
|
||||
<a href="#" type="button" class="btn btn-primary" data-id="${id}" id="finishTransaction">Selesaikan Transaksi</a>
|
||||
<a href="#" type="button" class="btn btn-danger" data-id="${id}" id="complain">Ajukan Komplain</a>
|
||||
`;
|
||||
modal.find('.modal-footer').html(activitiesHtml);
|
||||
console.log(id);
|
||||
});
|
||||
|
||||
// selesai
|
||||
$('#modalFinish').on('click', '#finishTransaction', function() {
|
||||
var id = $(this).data('id');
|
||||
console.log(id);
|
||||
});
|
||||
|
||||
// complain
|
||||
$('#modalFinish').on('click', '#complain', function() {
|
||||
var id = $(this).data('id');
|
||||
console.log(id);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
@endsection
|
168
resources/views/User/transaction/penjual/index.blade.php
Normal file
168
resources/views/User/transaction/penjual/index.blade.php
Normal file
@ -0,0 +1,168 @@
|
||||
@extends('layouts.main')
|
||||
@section('content')
|
||||
<div class="main-content">
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h1>Halaman Penjual</h1>
|
||||
<div class="section-header-breadcrumb">
|
||||
<div class="breadcrumb-item active"><a href="{{ route('user.index') }}">Dashboard</a></div>
|
||||
<div class="breadcrumb-item">Transaksi Penjual</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4">
|
||||
<div class="col-12 mb-4">
|
||||
<div class="hero bg-primary text-white">
|
||||
<div class="hero-inner">
|
||||
<h1>Hallo!!</h1>
|
||||
<p class="lead">Selamat Datang {{ Auth::user()->nama_depan }}!</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="table-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">
|
||||
#
|
||||
</th>
|
||||
<th>Order ID</th>
|
||||
<th>Pembeli</th>
|
||||
<th>Total</th>
|
||||
<th>Tanggal Pembuatan</th>
|
||||
<th>Tanggal Update</th>
|
||||
<th>Status</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($transactions as $transaction)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $transaction->id }}</td>
|
||||
<td>{{ $transaction->data_pembeli->nama_depan . ' ' . $transaction->data_pembeli->nama_belakang }}
|
||||
</td>
|
||||
<td>Rp {{ number_format($transaction->total_bayar, 2, ',', '.') }}</td>
|
||||
<td>{{ $transaction->created_at }}</td>
|
||||
<td>{{ $transaction->updated_at }}</td>
|
||||
<td><a href="#" data-toggle="modal"
|
||||
data-target="#modalKeteranganStatus"
|
||||
class="badge {{ in_array($transaction->status, ['pending', 'created'])
|
||||
? 'badge-light'
|
||||
: (in_array($transaction->status, ['settlement', 'capture'])
|
||||
? 'badge-info'
|
||||
: (in_array($transaction->status, ['process', 'sending', 'sended'])
|
||||
? 'badge-warning'
|
||||
: (in_array($transaction->status, ['cancel', 'expire', 'failure', 'refund'])
|
||||
? 'badge-danger'
|
||||
: ($transaction->status == 'finished'
|
||||
? 'badge-success'
|
||||
: '')))) }}">{{ ucwords($transaction->status) }}</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
Action
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item"
|
||||
href="{{ route('user-penjual.show', $transaction->id) }}">Detail</a>
|
||||
</li>
|
||||
@if (!$transaction->transactionDescription->isEmpty())
|
||||
<li><a class="dropdown-item" data-toggle="modal"
|
||||
data-target="#modalTracking"
|
||||
data-transaction="{{ $transaction->transactionDescription }}">Tracking</a>
|
||||
</li>
|
||||
@endif
|
||||
{{-- Setelah dibayar --}}
|
||||
@if ($transaction->status == 'settlement')
|
||||
<li><a class="dropdown-item" href="#">Process</a>
|
||||
</li>
|
||||
@endif
|
||||
{{-- Pengiriman barang --}}
|
||||
@if ($transaction->status == 'progress')
|
||||
<li><a class="dropdown-item" href="#">Kirim
|
||||
Barang</a>
|
||||
</li>
|
||||
@endif
|
||||
@if ($transaction->status == 'sending')
|
||||
<li><a class="dropdown-item" href="#">Barang sudah
|
||||
sampai</a>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@extends('user.transaction.penjual.modal-tracking')
|
||||
@extends('user.transaction.penjual.modal-keterangan-status')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#modalTracking').on('show.bs.modal', function(event) {
|
||||
var triggerLink = $(event.relatedTarget); // Tombol yang memicu modal
|
||||
var transactionDatas = triggerLink.data('transaction'); // Ambil data dari tombol
|
||||
|
||||
// Buat variabel untuk menyimpan HTML aktivitas
|
||||
transactionDatas = transactionDatas.reverse();
|
||||
var activitiesHtml = '';
|
||||
|
||||
// Periksa apakah ada data transaksi
|
||||
if (transactionDatas && transactionDatas.length > 0) {
|
||||
// Iterasi melalui data transaksi dan tambahkan ke activitiesHtml
|
||||
$.each(transactionDatas, function(index, transactionDescription) {
|
||||
activitiesHtml += `
|
||||
<div class="activity">
|
||||
<div class="activity-icon ${transactionDescription.background} text-white shadow-primary">
|
||||
<i class="${transactionDescription.judul}" style="font-size: 36px;"></i>
|
||||
</div>
|
||||
<div class="activity-detail">
|
||||
<div class="mb-2">
|
||||
<span class="text-job text-primary">${new Date(transactionDescription.created_at).toLocaleString()}</span>
|
||||
</div>
|
||||
<p>${transactionDescription.deskripsi}</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
} else {
|
||||
// Tidak ada data transaksi, tambahkan pesan kosong
|
||||
activitiesHtml += `
|
||||
<div class="activity">
|
||||
<div class="activity-icon bg-primary text-white shadow-primary">
|
||||
<i class="fas fa-ban" style="font-size: 36px;"></i>
|
||||
</div>
|
||||
<div class="activity-detail">
|
||||
<div class="mb-2">
|
||||
<span class="text-job text-primary">--, --:--:-- --</span>
|
||||
</div>
|
||||
<p>Kosong</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// Menampilkan data dalam modal
|
||||
var modal = $(this);
|
||||
modal.find('.activities').html(activitiesHtml);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
Loading…
Reference in New Issue
Block a user