perubahan

This commit is contained in:
oktaviaramadani 2023-12-07 10:55:45 +07:00
commit f0588b77fe
58 changed files with 3450 additions and 1207 deletions

View File

@ -17,8 +17,6 @@ class ContactApiController extends Controller
{ {
public function getListContact(Request $request) public function getListContact(Request $request)
{ {
// $token = JWTAuth::getToken();
// $user = JWTAuth::user($token);
$data = DB::table('contacts') $data = DB::table('contacts')
->join('users', 'contacts.relasi_kontak', '=', 'users.email') ->join('users', 'contacts.relasi_kontak', '=', 'users.email')

View File

@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers\API\Notification;
use App\Http\Controllers\Controller;
use App\Models\Notification;
use App\Models\NotificationReceiver;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class NotificationApiController extends Controller
{
public function listNotification(Request $request){
}
public function getDetailNotification(Request $request){
$notification = Notification::where('id', $request->input('id'))->get();
return response()->json([
'data' => $notification
]);
}
public function markAllAsRead(){
$result = NotificationReceiver::where('receiver', auth()->user()->email)->update([
'status' => 'read'
]);
if($result){
return response()->json([
'status' => true,
'message' => 'Berhasil'
]);
}else{
return response()->json([
'status' => false,
'message' => 'Gagal'
]);
Log::error($result);
}
}
}

View File

@ -8,76 +8,369 @@ use Carbon\Carbon;
use App\Models\Transaction; use App\Models\Transaction;
use App\Models\Refund; use App\Models\Refund;
use App\Models\User; use App\Models\User;
use DateInterval;
use DateTime;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class AdminDashboardController extends Controller class AdminDashboardController extends Controller
{ {
public function index() public function index()
{ {
$currentMonth = Carbon::now()->month; $today = new DateTime();
$currentYear = Carbon::now()->year; $todayDate = $today->format('Y-m-d');
$pickDate = new DateTime();
$interval = new DateInterval('P29D');
$start = $pickDate->sub($interval);
$startDate = $start->format('Y-m-d');
$countSuccess = Transaction::where('status_pembayaran', 'settlement') $intervalBefore = new DateInterval('P1D');
->whereMonth('updated_at', $currentMonth) $intervalBeforeStart = new DateInterval('P29D');
->whereYear('updated_at', $currentYear) $endBefore = $pickDate->sub($intervalBefore);
$endBeforeDate = $endBefore->format('Y-m-d');
$startBefore = $pickDate->sub($intervalBeforeStart);
$startBeforeDate = $startBefore->format('Y-m-d');
$countSuccess = Transaction::whereIn('status_transaksi', ['done'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // selesai
$countProcessed = Transaction::whereIn('status_transaksi', ['process', 'sending', 'sent', 'success', 'finished'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // diproses
$countCancelled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); //gagal
$countIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // terindikasi
$countWaiting = Transaction::where('status_transaksi', 'created_at')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // terindikasi
$totalTransaction = Transaction::whereNotIn('status_transaksi', ['refund'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // transaksi
$totalTransactionSebelum = Transaction::whereNotIn('status_transaksi', ['refund', 'created'])
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->count(); // transaksi sebelum
$rateTransaction = floatval((floatval($totalTransaction)-floatval($totalTransactionSebelum))*100)/ ($totalTransactionSebelum == 0 ? 1 : floatval($totalTransactionSebelum));
$countPending = Refund::where('status', 'pending')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); //ajuan
$countApprove = Refund::where('status', 'refund')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // disetujui
$countDeny = Refund::where('status', 'deny')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // ditolak
$totalRefund = Refund::whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); // refund
$totalRefundSebelum = Refund::whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->count(); // refund sebelum
$rateRefund = floatval((floatval($totalRefund)-floatval($totalRefundSebelum))*100)/ ($totalRefundSebelum == 0 ? 1 : floatval($totalRefundSebelum));
$totalUser = User::where('role', 'User')
->where('status', 'Finished')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->count(); ->count();
$countPending = Transaction::where('status_pembayaran', 'pending') $totalUserSebelum = User::where('role', 'User')
->whereMonth('updated_at', $currentMonth) ->where('status', 'Finished')
->whereYear('updated_at', $currentYear) ->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->count(); ->count();
$countCancelled = Transaction::where('status_pembayaran', 'cancel') $rateUser = floatval((floatval($totalUser)-floatval($totalUserSebelum))*100)/ ($totalUserSebelum == 0 ? 1 : floatval($totalUserSebelum));
->whereMonth('updated_at', $currentMonth)
->whereYear('updated_at', $currentYear)
->count();
$countRefund = Transaction::where('status_pembayaran', 'refund') $totalProfit = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereMonth('updated_at', $currentMonth) ->whereDate('created_at', '>=', $startDate)
->whereYear('updated_at', $currentYear) ->whereDate('created_at', '<=', $todayDate)
->count(); ->sum('total_keuntungan');
$totalTransaction = Transaction::whereMonth('updated_at', $currentMonth) $totalProfitSebelum = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereYear('updated_at', $currentYear) ->whereDate('created_at', '>=', $startBeforeDate)
->count(); ->whereDate('created_at', '<=', $endBeforeDate)
->sum('total_keuntungan');
$rateProfit = floatval((floatval($totalProfit)-floatval($totalProfitSebelum))*100)/ ($totalProfitSebelum == 0 ? 1 : floatval($totalProfitSebelum));
$dataChartTransaction = []; $dataChartTransaction = [];
$dataChartRefund = []; $dataChartRefund = [];
$dataChartUser = [];
$dataLabel = [];
$totalRefund = Transaction::where('status_pembayaran', 'refund')->count(); $startDate = $start;
$dataChartTotalRefund = []; $intervalDate = new DateInterval('P1D');
$todayDate = $today;
$endDate = $todayDate->add($intervalDate);
$totalUser = User::where('status', 'Finished')->count(); for ($date = clone $startDate; $date <= $endDate; $date->modify('+1 day')) {
$dataChartTotalUser = []; $transaction = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_keuntungan');
for ($bulan = 1; $bulan <= 12; $bulan++) { $refund = Transaction::where('status_transaksi', 'refund')
$transaction = Transaction::whereMonth('updated_at', $bulan) ->whereDate('created_at', $date->format('Y-m-d'))
->whereYear('updated_at', $currentYear) ->sum('total_keuntungan');
->where('status_pembayaran', 'settlement')
->sum('total_bayar')/100;
$refund = Transaction::whereMonth('updated_at', $bulan) $user = User::where('role', 'User')
->whereYear('updated_at', $currentYear) ->where('status', 'Finished')
->where('status_pembayaran', 'refund') ->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_harga')/100; ->count();
$dataChartTransaction[] = intval($transaction); $dataChartTransaction[] = floatval($transaction) / 1000;
$dataChartRefund[] = intval($refund); $dataChartRefund[] = floatval($refund) / 1000;
$dataChartUser[] = intval($user);
$dataLabel[] = $date->format('d/m/Y');
} }
$transactions = Transaction::latest() $dataTopUsers = Transaction::selectRaw(
"
CONCAT(users.nama_depan,' ',users.nama_belakang) AS nama_lengkap,
COUNT(CASE WHEN transactions.status_transaksi = 'done' OR refunds.status = 'refund' THEN 1 ELSE NULL END) AS jumlah_transaksi,
COUNT(CASE WHEN transactions.status_transaksi = 'done' THEN 1 ELSE NULL END) AS jumlah_transaksi_berhasil,
COUNT(CASE WHEN refunds.status = 'refund' THEN 1 ELSE NULL END) AS jumlah_refund_berhasil,
SUM(CASE WHEN refunds.status = 'refund' THEN refunds.total ELSE 0 END) AS total_refund_berhasil,
SUM(CASE WHEN transactions.status_transaksi = 'done' THEN transactions.total_harga ELSE 0 END) AS total_transaksi_berhasil,
users.foto_profile
",
)
->leftJoin('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->leftJoin('users', 'users.email', '=', 'transactions.pembeli')
->groupBy('nama_lengkap', 'users.foto_profile')
->orderBy('total_transaksi_berhasil', 'DESC')
->orderBy('total_refund_berhasil', 'ASC')
->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $todayDate)
->limit(5)
->get(); ->get();
return view('admin.index', compact('transactions', 'countSuccess', 'countPending', 'countCancelled', 'countRefund', 'totalRefund', 'totalUser', 'totalTransaction', 'dataChartTransaction', 'dataChartRefund', 'dataChartTotalUser', 'dataChartTotalRefund', 'transactions')); return view('admin.index', compact(
'countSuccess',
'countProcessed',
'countCancelled',
'countIndicated',
'countWaiting',
'totalTransaction',
'rateTransaction',
'countPending',
'countApprove',
'countDeny',
'totalRefund',
'rateRefund',
'totalUser',
'rateUser',
'rateProfit',
'dataChartTransaction',
'dataChartRefund',
'dataChartUser',
'dataLabel',
'dataTopUsers'
));
} }
public function getSelectedChart() public function getDataBySearch(Request $request)
{ {
$dataChartLaporan = []; $startDate = $request->startDate; // 0
$tahun = Carbon::now()->year; $endDate = $request->endDate; // 29
$pickDate = new DateTime($request->startDate);
$startDateTime = new DateTime($request->startDate);
$endDateTime = new DateTime($request->endDate);
$interval = $startDateTime->diff($endDateTime);
$intervalBefore = new DateInterval('P1D');
$intervalBeforeStart = new DateInterval('P'.$interval->format('%a').'D');
$endBefore = $pickDate->sub($intervalBefore);
$endBeforeDate = $endBefore->format('Y-m-d'); // -1
$startBefore = $pickDate->sub($intervalBeforeStart);
$startBeforeDate = $startBefore->format('Y-m-d'); // -29
$countSuccess = Transaction::whereIn('status_transaksi', ['done'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // selesai
$countProcessed = Transaction::whereIn('status_transaksi', ['process', 'sending', 'sent', 'success', 'finished'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // diproses
$countCancelled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); //gagal
$countIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // terindikasi
$countWaiting = Transaction::where('status_transaksi', 'created')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // terindikasi
$totalTransaction = Transaction::whereNotIn('status_transaksi', ['refund'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // transaksi
$totalTransactionSebelum = Transaction::whereNotIn('status_transaksi', ['refund'])
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->count(); // transaksi
$rateTransaction = floatval((floatval($totalTransaction)-floatval($totalTransactionSebelum))*100)/ ($totalTransactionSebelum == 0 ? 1 : floatval($totalTransactionSebelum));
$countPending = Refund::where('status', 'pending')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); //ajuan
$countApprove = Refund::where('status', 'refund')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // disetujui
$countDeny = Refund::where('status', 'deny')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // ditolak
$totalRefund = Refund::whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count(); // refund
$totalRefundSebelum = Refund::whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->count();
$rateRefund = floatval((floatval($totalRefund)-floatval($totalRefundSebelum))*100)/ ($totalRefundSebelum == 0 ? 1 : floatval($totalRefundSebelum));
$totalUser = User::where('role', 'User')
->where('status', 'Finished')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->count();
$totalUserSebelum = User::where('role', 'User')
->where('status', 'Finished')
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->count();
$rateUser = floatval((floatval($totalUser)-floatval($totalUserSebelum))*100)/ ($totalUserSebelum == 0 ? 1 : floatval($totalUserSebelum));
$totalProfit = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $endDate)
->sum('total_keuntungan');
$totalProfitSebelum = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->sum('total_keuntungan');
$rateProfit = floatval((floatval($totalProfit)-floatval($totalProfitSebelum))*100)/ ($totalProfitSebelum == 0 ? 1 : floatval($totalProfitSebelum));
$dataChartTransaction = [];
$dataChartRefund = [];
$dataChartUser = [];
$dataLabel = [];
$first = $startDateTime;
$intervalDate = new DateInterval('P1D');
$endPlus1 = $endDateTime;
$last = $endPlus1->add($intervalDate);
for ($date = clone $first; $date <= $last; $date->modify('+1 day')) {
$transaction = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_keuntungan');
$refund = Transaction::where('status_transaksi', 'refund')
->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_keuntungan');
$user = User::where('role', 'User')
->where('status', 'Finished')
->whereDate('created_at', $date->format('Y-m-d'))
->count();
$dataChartTransaction[] = floatval($transaction);
$dataChartRefund[] = floatval($refund);
$dataChartUser[] = intval($user);
$dataLabel[] = $date->format('d/m/Y');
} }
public function getCharByYear() $dataTopUsers = Transaction::selectRaw(
{ "
CONCAT(users.nama_depan,' ',users.nama_belakang) AS nama_lengkap,
COUNT(CASE WHEN transactions.status_transaksi = 'done' OR refunds.status = 'refund' THEN 1 ELSE NULL END) AS jumlah_transaksi,
COUNT(CASE WHEN transactions.status_transaksi = 'done' THEN 1 ELSE NULL END) AS jumlah_transaksi_berhasil,
COUNT(CASE WHEN refunds.status = 'refund' THEN 1 ELSE NULL END) AS jumlah_refund_berhasil,
SUM(CASE WHEN refunds.status = 'refund' THEN refunds.total ELSE 0 END) AS total_refund_berhasil,
SUM(CASE WHEN transactions.status_transaksi = 'done' THEN transactions.total_harga ELSE 0 END) AS total_transaksi_berhasil,
users.foto_profile
",
)
->leftJoin('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->leftJoin('users', 'users.email', 'transactions.pembeli')
->groupBy('nama_lengkap', 'users.foto_profile')
->orderBy('total_transaksi_berhasil', 'DESC')
->orderBy('total_refund_berhasil', 'ASC')
->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $endDate)
->limit(5)
->get();
return response()->json([
'countSuccess' => $countSuccess,
'countProcessed' => $countProcessed,
'countCancelled' => $countCancelled,
'countIndicated' => $countIndicated,
'countWaiting' => $countWaiting,
'totalTransaction' => $totalTransaction,
'rateTransaction' => $rateTransaction,
'countPending' => $countPending,
'countApprove' => $countApprove,
'countDeny' => $countDeny,
'totalRefund' => $totalRefund,
'rateRefund' => $rateRefund,
'totalUser' => $totalUser,
'rateUser' => $rateUser,
'rateProfit' => $rateProfit,
'dataChartTransaction' => $dataChartTransaction,
'dataChartRefund' => $dataChartRefund,
'dataChartUser' => $dataChartUser,
'dataLabel' => $dataLabel,
'dataTopUser' => $dataTopUsers,
'endDate' => $request->endDate,
]);
} }
} }

View File

@ -46,7 +46,7 @@ class AdminNotification extends Controller
public function listNotification(Request $request) public function listNotification(Request $request)
{ {
try { try {
$subQuery = Notification::latest()->select('notifications.id', 'notifications.title', 'notifications.teaser', 'notifications.created_at'); $subQuery = Notification::latest('notifications.updated_at')->select('notifications.id', 'notifications.title', 'notifications.teaser', 'notifications.created_at');
if ($request->has('search') && !empty($request->search['value'])) { if ($request->has('search') && !empty($request->search['value'])) {
$searchNotif = $request->search['value']; $searchNotif = $request->search['value'];
@ -266,6 +266,7 @@ class AdminNotification extends Controller
$email = NotificationReceiver::where('notification_id', $request->id) $email = NotificationReceiver::where('notification_id', $request->id)
->pluck('receiver') ->pluck('receiver')
->toArray(); ->toArray();
return view('admin.notification.edit', compact('notification', 'email')); return view('admin.notification.edit', compact('notification', 'email'));
} }

View File

@ -11,6 +11,8 @@ use App\Models\RefundDescription;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Notification;
use App\Models\NotificationReceiver;
use App\Models\TransactionDescription; use App\Models\TransactionDescription;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
@ -44,6 +46,7 @@ class AdminRefundController extends Controller
public function approveRefund(Request $request) public function approveRefund(Request $request)
{ {
$refund = Refund::where('id', $request->id)->first(); $refund = Refund::where('id', $request->id)->first();
$transactionDetail = Transaction::where('id', $refund->transaction_id)->first();
$params = [ $params = [
'refund_key' => $request->id . '-ref1', 'refund_key' => $request->id . '-ref1',
@ -60,7 +63,7 @@ class AdminRefundController extends Controller
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
'Authorization' => "Basic $auth", 'Authorization' => "Basic $auth",
]) ])
->post('https://api.sandbox.midtrans.com/v2/'.$request->id.'/refund', $params); ->post('https://api.sandbox.midtrans.com/v2/'.$refund->transaction_id.'/refund', $params);
$result = json_decode($response->body(), true); $result = json_decode($response->body(), true);
$code = $result['status_code']; $code = $result['status_code'];
@ -85,11 +88,31 @@ class AdminRefundController extends Controller
'deskripsi' => 'Admin telah menyetujui refund.', 'deskripsi' => 'Admin telah menyetujui refund.',
]); ]);
$url = route('user-transaction.show', ['id' => $transactionDetail->id]);
$notif = Notification::create([
'title' => 'Refund Diterima',
'content' => 'Refund telah diterima dan uang akan dikembalikan ke pembeli. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => 'Refund telah diterima...',
]);
NotificationReceiver::create([
'receiver' => [
$transactionDetail->pembeli,
$transactionDetail->penjual
],
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Refund berhasil dilakukan. Uang akan dikembalikan ke pembeli.', 'message' => 'Refund berhasil dilakukan. Uang akan dikembalikan ke pembeli.',
'receivers' => [
$transactionDetail->pembeli,
$transactionDetail->penjual
]
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -98,7 +121,7 @@ class AdminRefundController extends Controller
return response()->json([ return response()->json([
'status' => false, 'status' => false,
'message' => 'Refund gagal dilakukan', 'message' => 'Refund gagal dilakukan'
]); ]);
} }
}else{ }else{
@ -116,6 +139,7 @@ class AdminRefundController extends Controller
public function denyRefund(Request $request) public function denyRefund(Request $request)
{ {
$refund = Refund::where('id', $request->id)->first(); $refund = Refund::where('id', $request->id)->first();
$transactionDetail = Transaction::where('id', $refund->transaction_id)->first();
try { try {
Transaction::where('id', $refund->transaction_id)->update([ Transaction::where('id', $refund->transaction_id)->update([
@ -136,11 +160,31 @@ class AdminRefundController extends Controller
'deskripsi' => 'Admin telah menolak refund. Transaksi akan diteruskan ke penjual. Alasan: '.$request->complaint, 'deskripsi' => 'Admin telah menolak refund. Transaksi akan diteruskan ke penjual. Alasan: '.$request->complaint,
]); ]);
$url = route('user-transaction.show', ['id' => $transactionDetail->id]);
$notif = Notification::create([
'title' => 'Refund Diterima',
'content' => 'Refund ditolak dan transaksi akan diteruskan ke penjual. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => 'Refund ditolak...',
]);
NotificationReceiver::create([
'receiver' => [
$transactionDetail->pembeli,
$transactionDetail->penjual
],
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Refund berhasil ditolak. Transaksi diselesaikan dan uang disampaikan ke penjual.', 'message' => 'Refund berhasil ditolak. Transaksi diselesaikan dan uang disampaikan ke penjual.',
'receivers' => [
$transactionDetail->pembeli,
$transactionDetail->penjual
]
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -160,7 +204,7 @@ class AdminRefundController extends Controller
$subQuery = Refund::join('transactions', 'refunds.transaction_id', '=', 'transactions.id') $subQuery = Refund::join('transactions', 'refunds.transaction_id', '=', 'transactions.id')
->join('users as b', 'transactions.pembeli', '=', 'b.email') ->join('users as b', 'transactions.pembeli', '=', 'b.email')
->join('users as s', 'transactions.penjual', '=', 's.email') ->join('users as s', 'transactions.penjual', '=', 's.email')
->latest() ->latest('refunds.updated_at')
->select('refunds.id as id', DB::raw("CONCAT(b.nama_depan,' ', b.nama_belakang) as pembeli"), DB::raw("CONCAT(s.nama_depan,' ', s.nama_belakang) as penjual"), 'transactions.nama_barang as nama_barang', 'refunds.total as total', 'refunds.created_at', 'refunds.due_date', 'refunds.status'); ->select('refunds.id as id', DB::raw("CONCAT(b.nama_depan,' ', b.nama_belakang) as pembeli"), DB::raw("CONCAT(s.nama_depan,' ', s.nama_belakang) as penjual"), 'transactions.nama_barang as nama_barang', 'refunds.total as total', 'refunds.created_at', 'refunds.due_date', 'refunds.status');
if ($request->has('search') && !empty($request->search['value'])) { if ($request->has('search') && !empty($request->search['value'])) {

View File

@ -86,7 +86,7 @@ class AdminSettingController extends Controller
public function listSetting(Request $request){ public function listSetting(Request $request){
try{ try{
$subQuery = Setting::latest()->select('id','bulan','tahun','persentase','status'); $subQuery = Setting::select('id','bulan','tahun','persentase','status')->orderBy('tahun', 'DESC')->orderBy('bulan', 'DESC');
if($request->has('search') && !empty($request->search['value'])){ if($request->has('search') && !empty($request->search['value'])){
$searchSetting = $request->search['value']; $searchSetting = $request->search['value'];

View File

@ -4,6 +4,8 @@ namespace App\Http\Controllers\Admin\Transaction;
use App\Models\Transaction; use App\Models\Transaction;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Notification;
use App\Models\NotificationReceiver;
use App\Models\TransactionDescription; use App\Models\TransactionDescription;
use App\Models\TransactionUser; use App\Models\TransactionUser;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -52,6 +54,8 @@ class AdminTransactionController extends Controller
$result = json_decode($response->body(), true); $result = json_decode($response->body(), true);
$code = $result['status_code']; $code = $result['status_code'];
$transactionDetail = Transaction::where('id', $request->id)->first();
if($code == '200'){ if($code == '200'){
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -71,11 +75,33 @@ class AdminTransactionController extends Controller
'deskripsi' => 'Admin telah menerima pembayaran transaksi dan dilanjutkan ke penjual.', 'deskripsi' => 'Admin telah menerima pembayaran transaksi dan dilanjutkan ke penjual.',
]); ]);
$url = route('user-transaction.show', ['id' => $transactionDetail->id]);
$notif = Notification::create([
'title' => 'Transaksi Diterima',
'content' => 'Transaksi telah diterima dan akan dilanjutkan. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => 'Transaksi telah diterima...',
]);
NotificationReceiver::create([
'receiver' => $transactionDetail->penjual,
'notification_id' => $notif->id
]);
NotificationReceiver::create([
'receiver' => $transactionDetail->pembeli,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Transaksi telah diterima.' 'message' => 'Transaksi telah diterima.',
'receivers' => [
$transactionDetail->penjual,
$transactionDetail->pembeli
]
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -111,6 +137,8 @@ class AdminTransactionController extends Controller
$result = json_decode($response->body(), true); $result = json_decode($response->body(), true);
$code = $result['status_code']; $code = $result['status_code'];
$transactionDetail = Transaction::where('id', $request->id)->first();
if($code == '200'){ if($code == '200'){
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -130,11 +158,26 @@ class AdminTransactionController extends Controller
'deskripsi' => 'Admin telah menolak pembayaran. Alasan: '.$request->compaint, 'deskripsi' => 'Admin telah menolak pembayaran. Alasan: '.$request->compaint,
]); ]);
$url = route('user-transaction.show', ['id' => $transactionDetail->id]);
$notif = Notification::create([
'title' => 'Transaksi Ditolak',
'content' => 'Transaksi anda ditolak oleh Admin. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => 'Transaksi anda ditolak...',
]);
NotificationReceiver::create([
'receiver' => $transactionDetail->pembeli,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Transaksi telah ditolak.' 'message' => 'Transaksi telah ditolak.',
'receivers' => $transactionDetail->pembeli
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -159,7 +202,7 @@ class AdminTransactionController extends Controller
try { try {
$subQuery = Transaction::join('users as b', 'transactions.pembeli', '=', 'b.email') $subQuery = Transaction::join('users as b', 'transactions.pembeli', '=', 'b.email')
->join('users as s', 'transactions.penjual', '=', 's.email') ->join('users as s', 'transactions.penjual', '=', 's.email')
->latest() ->latest('transactions.updated_at')
->select('transactions.id', 'transactions.nama_barang', DB::raw("CONCAT(b.nama_depan,' ',b.nama_belakang) as nama_pembeli"), DB::raw("CONCAT(s.nama_depan,' ',s.nama_belakang) as nama_penjual"), 'transactions.total_harga', 'transactions.created_at', 'transactions.status_transaksi'); ->select('transactions.id', 'transactions.nama_barang', DB::raw("CONCAT(b.nama_depan,' ',b.nama_belakang) as nama_pembeli"), DB::raw("CONCAT(s.nama_depan,' ',s.nama_belakang) as nama_penjual"), 'transactions.total_harga', 'transactions.created_at', 'transactions.status_transaksi');
if ($request->has('search') && !empty($request->search['value'])) { if ($request->has('search') && !empty($request->search['value'])) {

View File

@ -4,9 +4,12 @@ namespace App\Http\Controllers\Admin\User;
use App\Models\User; use App\Models\User;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Mail\approveUser;
use App\Mail\denyUser;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Yajra\DataTables\DataTables; use Yajra\DataTables\DataTables;
use Throwable; use Throwable;
@ -59,6 +62,13 @@ class AdminUserController extends Controller
public function approveUser(Request $request) public function approveUser(Request $request)
{ {
$user = User::where('id', $request->id)->first();
$email = $user->email;
$content = [
'email' => $email,
];
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -66,6 +76,8 @@ class AdminUserController extends Controller
'status' => 'Finished', 'status' => 'Finished',
]); ]);
Mail::to($email)->send(new approveUser($content));
DB::commit(); DB::commit();
return response()->json([ return response()->json([
@ -81,6 +93,15 @@ class AdminUserController extends Controller
public function denyUser(Request $request) public function denyUser(Request $request)
{ {
$user = User::where('id', $request->id)->first();
$email = $user->email;
$keterangan = $request->keterangan;
$content = [
'keterangan' => $keterangan,
'email' => $email,
];
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -89,6 +110,8 @@ class AdminUserController extends Controller
'keterangan' => $request->keterangan, 'keterangan' => $request->keterangan,
]); ]);
Mail::to($email)->send(new denyUser($content));
DB::commit(); DB::commit();
return response()->json([ return response()->json([
@ -107,7 +130,7 @@ class AdminUserController extends Controller
try { try {
$subQuery = User::where('role', 'User') $subQuery = 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") ->orderByRaw("CASE WHEN status = 'Progress' THEN 1 WHEN status = 'Finished' THEN 2 WHEN status = 'Rejected' THEN 3 ELSE 4 END ASC")
->latest() ->latest('transactions.updated_at')
->select('users.id', DB::raw("CONCAT(users.nama_depan, ' ', users.nama_belakang) as nama_lengkap"), 'users.email', 'users.foto_profile', 'users.status', 'users.created_at as tanggal_daftar'); ->select('users.id', DB::raw("CONCAT(users.nama_depan, ' ', users.nama_belakang) as nama_lengkap"), 'users.email', 'users.foto_profile', 'users.status', 'users.created_at as tanggal_daftar');
if ($request->has('search') && !empty($request->search['value'])) { if ($request->has('search') && !empty($request->search['value'])) {
@ -146,6 +169,17 @@ class AdminUserController extends Controller
$url . $url .
'">Detail</a> '">Detail</a>
</li> </li>
';
if($row->status == 'Rejected'){
$html_code .= '
<li><a class="dropdown-item"
id="deleteUser"
href="javascript: void(0);"
data-id="'.$row->id.'">Hapus</a>
</li>
';
}
$html_code .= '
</ul> </ul>
</div>'; </div>';
return $html_code; return $html_code;

View File

@ -23,6 +23,7 @@ use Laravolt\Indonesia\Models\City;
use Laravolt\Indonesia\Models\District; use Laravolt\Indonesia\Models\District;
use Laravolt\Indonesia\Models\Province; use Laravolt\Indonesia\Models\Province;
use Laravolt\Indonesia\Models\Village; use Laravolt\Indonesia\Models\Village;
use Pusher\Pusher;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
class LoginController extends Controller class LoginController extends Controller
@ -263,6 +264,19 @@ class LoginController extends Controller
DB::commit(); DB::commit();
$options = [
'cluster' => 'ap1',
'useTLS' => true,
];
$pusher = new Pusher('3e5bdc20dddd7fbc655e', 'f2274c37c616d29ff590', '1659859', $options);
$payload = [
'service' => 'User'
];
$pusher->trigger('chanel-update-notifikasi-untuk-admin', 'event-update-notifikasi-untuk-admin', $payload);
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Akun anda sudah terdaftar dan butuh verifikasi hingga maksimal 1 hari kerja', 'message' => 'Akun anda sudah terdaftar dan butuh verifikasi hingga maksimal 1 hari kerja',

View File

@ -26,15 +26,15 @@ class UserContactController extends Controller
{ {
if($request->input == '' || $request->input == null){ if($request->input == '' || $request->input == null){
$data = DB::table('contacts') $data = DB::table('contacts')
->join('users', 'contacts.relasi_kontak', '=', 'users.email')
->select('contacts.relasi_kontak', 'users.nama_depan', 'users.nama_belakang') ->select('contacts.relasi_kontak', 'users.nama_depan', 'users.nama_belakang')
->where('contacts.pemilik_kontak', '=', Auth::user()->email) ->join('users', 'contacts.relasi_kontak', '=', 'users.email')
->where('contacts.pemilik_kontak', '=', auth()->user()->email)
->paginate(10); ->paginate(10);
}else{ }else{
$data = DB::table('contacts') $data = DB::table('contacts')
->join('users', 'contacts.relasi_kontak', '=', 'users.email') ->join('users', 'contacts.relasi_kontak', '=', 'users.email')
->select('contacts.relasi_kontak', 'users.nama_depan', 'users.nama_belakang') ->select('contacts.relasi_kontak', 'users.nama_depan', 'users.nama_belakang')
->where('contacts.pemilik_kontak', '=', Auth::user()->email) ->where('contacts.pemilik_kontak', '=', auth()->user()->email)
->whereRaw(DB::raw("LOWER(CONCAT(users.nama_depan,' ',users.nama_belakang)) LIKE ?",['%'.strtolower($request->input).'%'])) ->whereRaw(DB::raw("LOWER(CONCAT(users.nama_depan,' ',users.nama_belakang)) LIKE ?",['%'.strtolower($request->input).'%']))
->paginate(10); ->paginate(10);
} }
@ -143,7 +143,8 @@ class UserContactController extends Controller
->select( ->select(
'contacts.id', 'contacts.id',
DB::raw("CONCAT(users.nama_depan, ' ', users.nama_belakang) as nama_lengkap"), DB::raw("CONCAT(users.nama_depan, ' ', users.nama_belakang) as nama_lengkap"),
); )
->orderBy('nama_lengkap');
if($request->has('search') && !empty($request->search['value'])){ if($request->has('search') && !empty($request->search['value'])){
$searchContact = $request->search['value']; $searchContact = $request->search['value'];

View File

@ -5,74 +5,646 @@ namespace App\Http\Controllers\User\Dashboard;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Refund; use App\Models\Refund;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\RefundUser;
use App\Models\Transaction; use App\Models\Transaction;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\Auth; use DateInterval;
use Illuminate\Support\Facades\DB; use DateTime;
use Illuminate\Support\Facades\Log;
use Throwable;
class UserDashboardController extends Controller class UserDashboardController extends Controller
{ {
public function index() public function index()
{ {
$currentMonth = Carbon::now()->month; $today = new DateTime();
$currentYear = Carbon::now()->year; $todayDate = $today->format('Y-m-d');
$currentRole = 'Pembeli'; $pickDate = new DateTime();
$interval = new DateInterval('P29D');
$start = $pickDate->sub($interval);
$startDate = $start->format('Y-m-d');
$countCreated = Transaction::where('status_transaksi', 'created') $intervalBefore = new DateInterval('P1D');
->whereMonth('updated_at', $currentMonth) $intervalBeforeStart = new DateInterval('P29D');
->whereYear('updated_at', $currentYear) $endBefore = $pickDate->sub($intervalBefore);
$endBeforeDate = $endBefore->format('Y-m-d');
$startBefore = $pickDate->sub($intervalBeforeStart);
$startBeforeDate = $startBefore->format('Y-m-d');
// Semua
$countAllFinished = Transaction::whereIn('status_transaksi', ['finished', 'done'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllPending = Transaction::where('status_transaksi', 'created')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllProcessed = Transaction::whereIn('status_transaksi', ['process', 'sending', 'sent'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllCanceled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllRefund = Transaction::where('status_transaksi', 'refund')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
// Pembeli
$countBuyerFinished = Transaction::whereIn('status_transaksi', ['finished', 'done'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email) ->where('pembeli', auth()->user()->email)
->count(); ->count();
$countPending = Transaction::where('status_pembayaran', 'pending') $countBuyerPaid = Transaction::where('status_transaksi', 'success')
->whereMonth('updated_at', $currentMonth) ->whereDate('created_at', '>=', $startDate)
->whereYear('updated_at', $currentYear) ->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email) ->where('pembeli', auth()->user()->email)
->count(); ->count();
$countFailure = Transaction::whereIn('status_pembayaran', ['cancel', 'expire', 'failure']) $countBuyerPending = Transaction::where('status_transaksi', 'created')
->whereMonth('updated_at', $currentMonth) ->whereDate('created_at', '>=', $startDate)
->whereYear('updated_at', $currentYear) ->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email) ->where('pembeli', auth()->user()->email)
->count(); ->count();
$sumRefund = Transaction::join('refunds', 'transactions.id', '=', 'refunds.transaction_id') $countBuyerProcessed = Transaction::whereIn('status_transaksi', ['process', 'sending', 'sent'])
->where('transactions.status_pembayaran', 'refund') ->whereDate('created_at', '>=', $startDate)
->whereMonth('transactions.updated_at', $currentMonth) ->whereDate('created_at', '<=', $todayDate)
->whereYear('transactions.updated_at', $currentYear)
->where('transactions.pembeli', auth()->user()->email)
->sum('refunds.total');
$sumTransaksi = Transaction::whereMonth('updated_at', $currentMonth)
->whereYear('updated_at', $currentYear)
->where('pembeli', auth()->user()->email) ->where('pembeli', auth()->user()->email)
->sum('total_bayar');
$totalTransaction = Transaction::whereMonth('updated_at', $currentMonth)
->whereYear('updated_at', $currentYear)
->count(); ->count();
$totalIncome = Transaction::where('status_transaksi', 'success')->sum('total_bayar'); $countBuyerCancelled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$totalExpense = Transaction::where('status_transaksi', 'updated_at') $countBuyerRefundPending = Transaction::join('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->orWhere('status_transaksi', 'refund') ->where('refunds.status', 'pending')
->sum('total_bayar'); ->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
return view('user.index', compact('currentRole', 'countCreated', 'countPending', 'countFailure', 'sumRefund', 'sumTransaksi', 'totalTransaction', 'totalIncome', 'totalExpense')); $countBuyerRefundApproved = Transaction::join('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->where('refunds.status', 'refund')
->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerRefundDenied = Transaction::join('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->where('refunds.status', 'deny')
->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
// Penjual
$countSellerPending = Transaction::where('status_transaksi', 'success')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerFinished = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerProcessed = Transaction::where('status_transaksi', 'process')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerSending = Transaction::where('status_transaksi', 'sending')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerSent = Transaction::where('status_transaksi', 'sent')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerCancelled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerRefund = Transaction::where('status_transaksi', 'refund')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$totalTransaction = Transaction::whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$totalTransactionSebelum = Transaction::whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$rateTransaction = floatval((floatval($totalTransaction) - floatval($totalTransactionSebelum)) * 100) / ($totalTransactionSebelum == 0 ? 1 : floatval($totalTransactionSebelum));
$totalPemasukan = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->sum('total_harga');
$totalPemasukanSebelum = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where('penjual', auth()->user()->email)
->sum('total_harga');
$ratePemasukan = floatval((floatval($totalPemasukan) - floatval($totalPemasukanSebelum)) * 100) / ($totalPemasukanSebelum == 0 ? 1 : floatval($totalPemasukanSebelum));
$totalPengeluaran = Transaction::whereIn('status_transaksi', ['finished','done'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->sum('total_harga');
$totalPengeluaranSebelum = Transaction::whereIn('status_transaksi', ['finished','done'])
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where('pembeli', auth()->user()->email)
->sum('total_harga');
$ratePengeluaran = floatval(((floatval($totalPengeluaran) - floatval($totalPengeluaranSebelum)) * 100) / ($totalPengeluaranSebelum == 0 ? 1 : floatval($totalPengeluaranSebelum)));
$totalProfit = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_harga');
$totalProfitSebelum = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_harga');
$rateProfit = floatval(((floatval($totalProfit) - floatval($totalProfitSebelum))*100)/($totalProfitSebelum == 0 ? 1 : floatval($totalProfitSebelum)));
$dataLabel = [];
$dataChartTransaction = [];
$dataChartRefund = [];
$dataChartPemasukan = [];
$dataChartPengeluaran = [];
$startDate = $start;
$intervalDate = new DateInterval('P1D');
$todayDate = $today;
$endDate = $todayDate->add($intervalDate);
for ($date = clone $startDate; $date <= $endDate; $date->modify('+1 day')) {
$transaction = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', $date->format('Y-m-d'))
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_keuntungan');
$refund = Transaction::join('refunds','refunds.transaction_id','=','transactions.id')
->where('status_transaksi', 'refund')
->where('status','refund')
->whereDate('transactions.created_at', $date->format('Y-m-d'))
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_keuntungan');
$pemasukan = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->where('penjual', auth()->user()->email)
->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_harga');
$pengeluaran = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->where('pembeli', auth()->user()->email)
->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_harga');
$dataChartTransaction[] = floatval($transaction);
$dataChartRefund[] = floatval($refund);
$dataChartPemasukan[] = floatval($pemasukan);
$dataChartPengeluaran[] = floatval($pengeluaran);
$dataLabel[] = $date->format('d/m/Y');
} }
public function getSelectedChart(){ return view('user.index', compact(
$currentMonth = Carbon::now()->month; 'countAllFinished',
$currentYear = Carbon::now()->year; 'countAllPending',
$currentRole = 'Pembeli'; 'countAllProcessed',
'countAllCanceled',
if($currentRole == 'Pembeli'){ 'countAllRefund',
'countAllIndicated',
}else{ 'countBuyerFinished',
'countBuyerPaid',
'countBuyerPending',
'countBuyerProcessed',
'countBuyerCancelled',
'countBuyerRefundPending',
'countBuyerRefundApproved',
'countBuyerRefundDenied',
'countBuyerIndicated',
'countSellerPending',
'countSellerFinished',
'countSellerProcessed',
'countSellerSending',
'countSellerSent',
'countSellerCancelled',
'countSellerRefund',
'countSellerIndicated',
'totalTransaction',
'rateTransaction',
'totalPemasukan',
'ratePemasukan',
'totalPengeluaran',
'ratePengeluaran',
'rateProfit',
'dataLabel',
'dataChartTransaction',
'dataChartRefund',
'dataChartPemasukan',
'dataChartPengeluaran'
));
} }
public function getDataBySearch(Request $request)
{
$startDate = $request->startDate;
$todayDate = $request->endDate;
$pickDate = new DateTime($startDate);
$start = new DateTime($startDate);
$today = new DateTime($todayDate);
$interval = $start->diff($today);
$intervalBefore = new DateInterval('P1D');
$intervalBeforeStart = new DateInterval('P'.$interval->format('%a').'D');
$endBefore = $pickDate->sub($intervalBefore);
$endBeforeDate = $endBefore->format('Y-m-d');
$startBefore = $pickDate->sub($intervalBeforeStart);
$startBeforeDate = $startBefore->format('Y-m-d');
// Semua
$countAllFinished = Transaction::where('status_transaksi', 'Finished')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllPending = Transaction::where('status_transaksi', 'created')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllProcessed = Transaction::whereIn('status_transaksi', ['process', 'sending', 'sent'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllCanceled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllRefund = Transaction::where('status_transaksi', 'refund')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$countAllIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
// Pembeli
$countBuyerFinished = Transaction::where('status_transaksi', 'finished')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerPaid = Transaction::where('status_transaksi', 'success')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerPending = Transaction::where('status_transaksi', 'created')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerProcessed = Transaction::whereIn('status_transaksi', ['process', 'sending', 'sent'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerCancelled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerRefundPending = Transaction::join('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->where('refunds.status', 'pending')
->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerRefundApproved = Transaction::join('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->where('refunds.status', 'refund')
->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerRefundDenied = Transaction::join('refunds', 'refunds.transaction_id', '=', 'transactions.id')
->where('refunds.status', 'deny')
->whereDate('transactions.created_at', '>=', $startDate)
->whereDate('transactions.created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
$countBuyerIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->count();
// Penjual
$countSellerPending = Transaction::where('status_transaksi', 'success')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerFinished = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerProcessed = Transaction::where('status_transaksi', 'process')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerSending = Transaction::where('status_transaksi', 'sending')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerSent = Transaction::where('status_transaksi', 'sent')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerCancelled = Transaction::where('status_transaksi', 'failure')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerRefund = Transaction::where('status_transaksi', 'refund')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$countSellerIndicated = Transaction::where('status_transaksi', 'challenge')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->count();
$totalTransaction = Transaction::whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$totalTransactionSebelum = Transaction::whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->count();
$rateTransaction = floatval((floatval($totalTransaction) - floatval($totalTransactionSebelum)) * 100) / ($totalTransactionSebelum == 0 ? 1 : floatval($totalTransactionSebelum));
$totalPemasukan = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('penjual', auth()->user()->email)
->sum('total_harga');
$totalPemasukanSebelum = Transaction::where('status_transaksi', 'done')
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where('penjual', auth()->user()->email)
->sum('total_harga');
$ratePemasukan = floatval((floatval($totalPemasukan) - floatval($totalPemasukanSebelum)) * 100) / ($totalPemasukanSebelum == 0 ? 1 : floatval($totalPemasukanSebelum));
$totalPengeluaran = Transaction::whereIn('status_transaksi', ['finished','done'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where('pembeli', auth()->user()->email)
->sum('total_harga');
$totalPengeluaranSebelum = Transaction::whereIn('status_transaksi', ['finished','done'])
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where('pembeli', auth()->user()->email)
->sum('total_harga');
$ratePengeluaran = floatval(((floatval($totalPengeluaran) - floatval($totalPengeluaranSebelum)) * 100) / ($totalPengeluaranSebelum == 0 ? 1 : floatval($totalPengeluaranSebelum)));
$totalProfit = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', '>=', $startDate)
->whereDate('created_at', '<=', $todayDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_harga');
$totalProfitSebelum = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', '>=', $startBeforeDate)
->whereDate('created_at', '<=', $endBeforeDate)
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_harga');
$rateProfit = floatval(((floatval($totalProfit) - floatval($totalProfitSebelum))*100)/($totalProfitSebelum == 0 ? 1 : floatval($totalProfitSebelum)));
$dataLabel = [];
$dataChartTransaction = [];
$dataChartRefund = [];
$dataChartPemasukan = [];
$dataChartPengeluaran = [];
$first = $start;
$intervalDate = new DateInterval('P1D');
$lastDate = $today;
$last = $lastDate->add($intervalDate);
for ($date = clone $first; $date <= $last; $date->modify('+1 day')) {
$transaction = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->whereDate('created_at', $date->format('Y-m-d'))
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_keuntungan');
$refund = Transaction::join('refunds','refunds.transaction_id','=','transactions.id')
->where('status_transaksi', 'refund')
->where('status','refund')
->whereDate('transactions.created_at', $date->format('Y-m-d'))
->where(function ($a) {
$a->where('pembeli', auth()->user()->email)->orWhere('penjual', auth()->user()->email);
})
->sum('total_keuntungan');
$pemasukan = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->where('penjual', auth()->user()->email)
->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_harga');
$pengeluaran = Transaction::whereIn('status_transaksi', ['done', 'finished'])
->where('pembeli', auth()->user()->email)
->whereDate('created_at', $date->format('Y-m-d'))
->sum('total_harga');
$dataChartTransaction[] = floatval($transaction);
$dataChartRefund[] = floatval($refund);
$dataChartPemasukan[] = floatval($pemasukan);
$dataChartPengeluaran[] = floatval($pengeluaran);
$dataLabel[] = $date->format('d/m/Y');
}
return response()->json([
'countAllFinished' => $countAllFinished,
'countAllPending' => $countAllPending,
'countAllProcessed' => $countAllProcessed,
'countAllCanceled' => $countAllCanceled,
'countAllRefund' => $countAllRefund,
'countAllIndicated' => $countAllIndicated,
'countBuyerFinished' => $countBuyerFinished,
'countBuyerPaid' => $countBuyerPaid,
'countBuyerPending' => $countBuyerPending,
'countBuyerProcessed' => $countBuyerProcessed,
'countBuyerCancelled' => $countBuyerCancelled,
'countBuyerRefundPending' => $countBuyerRefundPending,
'countBuyerRefundApproved' => $countBuyerRefundApproved,
'countBuyerRefundDenied' => $countBuyerRefundDenied,
'countBuyerIndicated' => $countBuyerIndicated,
'countSellerPending' => $countSellerPending,
'countSellerFinished' => $countSellerFinished,
'countSellerProcessed' => $countSellerProcessed,
'countSellerSending' => $countSellerSending,
'countSellerSent' => $countSellerSent,
'countSellerCancelled' => $countSellerCancelled,
'countSellerRefund' => $countSellerRefund,
'countSellerIndicated' => $countSellerIndicated,
'totalTransaction' => $totalTransaction,
'rateTransaction' => $rateTransaction,
'totalPemasukan' => $totalPemasukan,
'ratePemasukan' => $ratePemasukan,
'totalPengeluaran' => $totalPengeluaran,
'ratePengeluaran' => $ratePengeluaran,
'rateProfit' => $rateProfit,
'dataLabel' => $dataLabel,
'dataChartTransaction' => $dataChartTransaction,
'dataChartRefund' => $dataChartRefund,
'dataChartPemasukan' => $dataChartPemasukan,
'dataChartPengeluaran' => $dataChartPengeluaran
]);
} }
} }

View File

@ -8,6 +8,7 @@ use App\Models\NotificationReceiver;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Pusher\Pusher;
use Throwable; use Throwable;
use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Facades\DataTables;
@ -23,7 +24,7 @@ class UserNotification extends Controller
try { try {
$subQuery = Notification::join('notification_receivers','notifications.id','=','notification_receivers.notification_id') $subQuery = Notification::join('notification_receivers','notifications.id','=','notification_receivers.notification_id')
->where('notification_receivers.receiver','=',auth()->user()->email) ->where('notification_receivers.receiver','=',auth()->user()->email)
->latest() ->latest('notification_receivers.updated_at')
->select('notifications.id', 'notifications.title', 'notifications.teaser', 'notification_receivers.created_at', 'notification_receivers.status'); ->select('notifications.id', 'notifications.title', 'notifications.teaser', 'notification_receivers.created_at', 'notification_receivers.status');
if ($request->has('search') && !empty($request->search['value'])) { if ($request->has('search') && !empty($request->search['value'])) {
@ -114,13 +115,53 @@ class UserNotification extends Controller
public function markAllAsRead() public function markAllAsRead()
{ {
NotificationReceiver::where('receiver', auth()->user()->email)->update([ $result = NotificationReceiver::where('receiver', auth()->user()->email)->update([
'status' => 'read', 'status' => 'read',
]); ]);
if($result){
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Berhasil', 'message' => 'Berhasil',
]); ]);
}else{
return response()->json([
'status' => false,
'message' => 'Gagal',
]);
Log::error($result);
}
}
public function updateNewNotification(Request $request)
{
$options = [
'cluster' => 'ap1',
'useTLS' => true,
];
$pusher = new Pusher('3e5bdc20dddd7fbc655e', 'f2274c37c616d29ff590', '1659859', $options);
$payload = [
'receivers' => $request->receiver,
];
$pusher->trigger('chanel-update-notifikasi', 'event-update-notifikasi', $payload);
}
public function updateNotificationToAdmin(Request $request)
{
$options = [
'cluster' => 'ap1',
'useTLS' => true,
];
$pusher = new Pusher('3e5bdc20dddd7fbc655e', 'f2274c37c616d29ff590', '1659859', $options);
$payload = [
'service' => $request->service
];
$pusher->trigger('chanel-update-notifikasi-untuk-admin', 'event-update-notifikasi-untuk-admin', $payload);
} }
} }

View File

@ -4,6 +4,8 @@ namespace App\Http\Controllers\User\Pembeli;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Contact; use App\Models\Contact;
use App\Models\Notification;
use App\Models\NotificationReceiver;
use App\Models\Refund; use App\Models\Refund;
use App\Models\Setting; use App\Models\Setting;
use App\Models\Transaction; use App\Models\Transaction;
@ -15,6 +17,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Pusher\Pusher;
use Throwable; use Throwable;
use Yajra\DataTables\DataTables; use Yajra\DataTables\DataTables;
@ -50,6 +53,30 @@ class PembeliController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$request->validate(
[
'nama_barang' => ['required'],
'harga_barang' => ['required'],
'satuan_barang' => ['required'],
'jumlah_barang' => ['required'],
'email_penjual' => ['required'],
'persentase_keuntungan' => ['required'],
'total_keuntungan' => ['required'],
'total_bayar' => ['required'],
'total_harga' => ['required']
],[
'nama_barang.required' => 'Isi nama barang',
'harga_barang.required' => 'Isi harga barang',
'satuan_barang.required' => 'Isi satuan barang',
'jumlah_barang.required' => 'Isi jumlah barang',
'email_penjual.required' => 'Isi email penjual. Bisa dari kontak atau masukan email',
'persentase_keuntungan.required' => 'Terjadi kesalahan di server',
'total_keuntungan.required' => 'Terjadi kesalahan di server',
'total_bayar.required' => 'Terjadi kesalahan di server',
'total_harga.required' => 'Terjadi kesalahan di server'
]
);
$pembeli = auth()->user()->email; $pembeli = auth()->user()->email;
$penjual = $request->email_penjual; $penjual = $request->email_penjual;
$nama_barang = $request->nama_barang; $nama_barang = $request->nama_barang;
@ -84,7 +111,6 @@ class PembeliController extends Controller
$batas_pembayaran = $now->addDays(1)->toTimeString(); $batas_pembayaran = $now->addDays(1)->toTimeString();
$batas_konfirmasi_transaksi = $now->addDays(2)->toDateTimeString(); $batas_konfirmasi_transaksi = $now->addDays(2)->toDateTimeString();
$batas_pengiriman_barang_awal = $now->addDays(3)->toDateTimeString();
$batas_pengiriman_barang_akhir = $now->addDays(4)->toDateTimeString(); $batas_pengiriman_barang_akhir = $now->addDays(4)->toDateTimeString();
$status = 'created'; $status = 'created';
@ -109,7 +135,6 @@ class PembeliController extends Controller
'status_transaksi' => $status, 'status_transaksi' => $status,
'batas_pembayaran' => $batas_pembayaran, 'batas_pembayaran' => $batas_pembayaran,
'batas_konfirmasi_transaksi' => $batas_konfirmasi_transaksi, 'batas_konfirmasi_transaksi' => $batas_konfirmasi_transaksi,
'batas_pengiriman_barang_awal' => $batas_pengiriman_barang_awal,
'batas_pengiriman_barang_akhir' => $batas_pengiriman_barang_akhir, 'batas_pengiriman_barang_akhir' => $batas_pengiriman_barang_akhir,
]); ]);
@ -214,6 +239,8 @@ class PembeliController extends Controller
public function finishTransaction(Request $request) public function finishTransaction(Request $request)
{ {
$transactionDetail = Transaction::where('id', $request->id)->first();
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -231,11 +258,23 @@ class PembeliController extends Controller
'deskripsi' => 'Pesanan telah diselesaikan oleh ' . auth()->user()->nama_depan . '. Uang akan dikirim ke penjual.', 'deskripsi' => 'Pesanan telah diselesaikan oleh ' . auth()->user()->nama_depan . '. Uang akan dikirim ke penjual.',
]); ]);
$notif = Notification::create([
'title' => 'Transaksi Selesai',
'content' => auth()->user()->nama_depan.' telah menyelesaikan transaksi. Silahkan terima uang anda.',
'teaser' => auth()->user()->nama_depan.' telah...'
]);
NotificationReceiver::create([
'receiver' => $transactionDetail->penjual,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Pesanan anda selesai dan uang akan dikirim ke penjual. Terima kasih telah menggunakan Rekber.', 'message' => 'Pesanan anda selesai dan uang akan dikirim ke penjual. Terima kasih telah menggunakan Rekber.',
'receiver' => $transactionDetail->penjual
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -253,6 +292,8 @@ class PembeliController extends Controller
{ {
$auth = base64_encode(env('MIDTRANS_SERVER_KEY')); $auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
$transactionDetail = Transaction::where('id', $request->id)->first();
$response = Http::withOptions([ $response = Http::withOptions([
'verify' => false, 'verify' => false,
]) ])
@ -307,11 +348,25 @@ class PembeliController extends Controller
'user' => auth()->user()->email, 'user' => auth()->user()->email,
]); ]);
$url = route('user-transaction.show', ['id' => $transactionDetail->id]);
$notif = Notification::create([
'title' => 'Pembayaran Sukses',
'content' => auth()->user()->nama_depan.' telah membayar transaksi. Silahkan proses transaksi ini jika memang dituju kepada anda. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => auth()->user()->nama_depan.' telah...'
]);
NotificationReceiver::create([
'receiver' => $transactionDetail->penjual,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Pembayaran sukses', 'message' => 'Pembayaran sukses',
'receiver' => $transactionDetail->penjual
]); ]);
} elseif ($transaction == 'challenge') { } elseif ($transaction == 'challenge') {
TransactionDescription::create([ TransactionDescription::create([
@ -324,6 +379,19 @@ class PembeliController extends Controller
'keterangan' => $result['status_message'], 'keterangan' => $result['status_message'],
]); ]);
$options = [
'cluster' => 'ap1',
'useTLS' => true,
];
$pusher = new Pusher('3e5bdc20dddd7fbc655e', 'f2274c37c616d29ff590', '1659859', $options);
$payload = [
'service' => 'Transaksi'
];
$pusher->trigger('chanel-update-notifikasi-untuk-admin', 'event-update-notifikasi-untuk-admin', $payload);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
@ -471,11 +539,25 @@ class PembeliController extends Controller
'deskripsi' => 'Transaksi dibatalkan oleh ' . auth()->user()->nama_depan . '. Alasan : ' . $request->complaint, 'deskripsi' => 'Transaksi dibatalkan oleh ' . auth()->user()->nama_depan . '. Alasan : ' . $request->complaint,
]); ]);
$url = route('user-transaction.show', ['id' => $transaction->id]);
$notif = Notification::create([
'title' => 'Transaksi Dibatalkan',
'content' => auth()->user()->nama_depan.' telah membatalkan transaksi. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => auth()->user()->nama_depan.' telah...'
]);
NotificationReceiver::create([
'receiver' => $transaction->penjual,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Transaksi telah dibatalkan.', 'message' => 'Transaksi telah dibatalkan.',
'receiver' => $transaction->penjual
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -740,7 +822,8 @@ class PembeliController extends Controller
'transactions.created_at', 'transactions.created_at',
'transactions.status_transaksi', 'transactions.status_transaksi',
'transactions.token' 'transactions.token'
); )
->latest('transactions.updated_at');
if($request->has('search') && !empty($request->search['value'])){ if($request->has('search') && !empty($request->search['value'])){
$searchPembeli = $request->search['value']; $searchPembeli = $request->search['value'];

View File

@ -3,6 +3,8 @@
namespace App\Http\Controllers\User\Penjual; namespace App\Http\Controllers\User\Penjual;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Notification;
use App\Models\NotificationReceiver;
use App\Models\Refund; use App\Models\Refund;
use App\Models\Transaction; use App\Models\Transaction;
use App\Models\TransactionDescription; use App\Models\TransactionDescription;
@ -26,7 +28,8 @@ class PenjualController extends Controller
try { try {
$subQuery = Transaction::join('users', 'transactions.pembeli', '=', 'users.email') $subQuery = Transaction::join('users', 'transactions.pembeli', '=', 'users.email')
->where('transactions.penjual', auth()->user()->email) ->where('transactions.penjual', auth()->user()->email)
->select('transactions.id', DB::raw("CONCAT(users.nama_depan,' ',users.nama_belakang) as nama_pembeli"), 'transactions.nama_barang', 'transactions.total_harga', 'transactions.created_at', 'transactions.status_transaksi'); ->select('transactions.id', DB::raw("CONCAT(users.nama_depan,' ',users.nama_belakang) as nama_pembeli"), 'transactions.nama_barang', 'transactions.total_harga', 'transactions.created_at', 'transactions.status_transaksi')
->latest('transactions.updated_at');
if ($request->has('search') && !empty($request->search['value'])) { if ($request->has('search') && !empty($request->search['value'])) {
$searchPenjual = $request->search['value']; $searchPenjual = $request->search['value'];
@ -103,7 +106,7 @@ class PenjualController extends Controller
'; ';
} }
if ($row->status_transaksi == 'progress') { if ($row->status_transaksi == 'process') {
$html_code .= $html_code .=
' '
<li><a class="dropdown-item" id="sendOrder" <li><a class="dropdown-item" id="sendOrder"
@ -156,6 +159,8 @@ class PenjualController extends Controller
public function acceptTransaction(Request $request) public function acceptTransaction(Request $request)
{ {
$transactionDetail = Transaction::where('id', $request->id)->first();
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -172,11 +177,25 @@ class PenjualController extends Controller
'deskripsi' => 'Transaksi telah diterima oleh ' . auth()->user()->nama_depan, 'deskripsi' => 'Transaksi telah diterima oleh ' . auth()->user()->nama_depan,
]); ]);
$url = route('user-transaction.show', ['id' => $transactionDetail->id]);
$notif = Notification::create([
'title' => 'Transaksi Diproses',
'content' => auth()->user()->nama_depan.' telah menerima dan memproses transaksi. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => auth()->user()->nama_depan.' telah...'
]);
NotificationReceiver::create([
'receiver' => $transactionDetail->pembeli,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Transaksi telah diterima. Siapkan pesanan untuk dikirim ke penjual.', 'message' => 'Transaksi telah diterima. Siapkan pesanan untuk dikirim ke penjual.',
'receiver' => $transactionDetail->pembeli
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -241,11 +260,25 @@ class PenjualController extends Controller
'deskripsi' => 'Transaksi ditolak ' . auth()->user()->nama_depan . ', uang akan dikembalikan ke pembeli. Alasan : ' . $request->complaint, 'deskripsi' => 'Transaksi ditolak ' . auth()->user()->nama_depan . ', uang akan dikembalikan ke pembeli. Alasan : ' . $request->complaint,
]); ]);
$url = route('user-transaction.show', ['id' => $transaction->id]);
$notif = Notification::create([
'title' => 'Transaksi Diproses',
'content' => auth()->user()->nama_depan.' telah menolak transaksi.<a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => auth()->user()->nama_depan.' telah...'
]);
NotificationReceiver::create([
'receiver' => $transaction->pembeli,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Transaksi telah ditolak. Uang akan dikirimkan ke pembeli.', 'message' => 'Transaksi telah ditolak. Uang akan dikirimkan ke pembeli.',
'receiver' => $transaction->pembeli
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();
@ -305,6 +338,8 @@ class PenjualController extends Controller
public function sentOrder(Request $request) public function sentOrder(Request $request)
{ {
$transactionDetail = Transaction::where('id', $request->transaction_id)->first();
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -332,11 +367,25 @@ class PenjualController extends Controller
'bukti_foto' => $bukti_foto, 'bukti_foto' => $bukti_foto,
]); ]);
$url = route('user-transaction.show', ['id' => $transactionDetail->id]);
$notif = Notification::create([
'title' => 'Transaksi Sudah Tiba',
'content' => 'Transaksi sudah tiba dan silahkan periksa terlebih dahulu sebelum menyelesaikan transaksi atau mengajukan refund. <a href="'.$url.'">Klik disini</a> untuk langsung ke detail transaksi.',
'teaser' => 'Transaksi sudah tiba dan silahkan per...',
]);
NotificationReceiver::create([
'receiver' => $transactionDetail->pembeli,
'notification_id' => $notif->id
]);
DB::commit(); DB::commit();
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Pesanan telah sampai di tempat pembeli.', 'message' => 'Pesanan telah sampai di tempat pembeli.',
'receiver' => $transactionDetail->pembeli
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {
DB::rollBack(); DB::rollBack();

View File

@ -83,6 +83,7 @@ class UserRefundController extends Controller
return response()->json([ return response()->json([
'status' => true, 'status' => true,
'message' => 'Permintaan refund anda telah dikirim ke admin untuk direview. Mohon tunggu maksimal 2 hari.', 'message' => 'Permintaan refund anda telah dikirim ke admin untuk direview. Mohon tunggu maksimal 2 hari.',
'service' => 'Refund'
]); ]);
}catch(Throwable $e){ }catch(Throwable $e){
DB::rollback(); DB::rollback();
@ -115,7 +116,8 @@ class UserRefundController extends Controller
'refunds.status', 'refunds.status',
'transactions.nama_barang', 'transactions.nama_barang',
DB::raw("CONCAT(s.nama_depan,' ',s.nama_belakang) as nama_penjual"), DB::raw("CONCAT(s.nama_depan,' ',s.nama_belakang) as nama_penjual"),
); )
->latest('refunds.updated_at');
if($request->has('search') && !empty($request->search['value'])){ if($request->has('search') && !empty($request->search['value'])){
$searchRefund = $request->search['value']; $searchRefund = $request->search['value'];

59
app/Mail/approveUser.php Normal file
View File

@ -0,0 +1,59 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class approveUser extends Mailable
{
use Queueable, SerializesModels;
public $content;
/**
* Create a new message instance.
*/
public function __construct($content)
{
$this->content = $content;
}
/**
* Get the message envelope.
*/
// public function envelope(): Envelope
// {
// return new Envelope(
// subject: 'Approve User',
// );
// }
/**
* Get the message content definition.
*/
// public function content(): Content
// {
// return new Content(
// view: 'view.name',
// );
// }
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
// public function attachments(): array
// {
// return [];
// }
public function build(){
return $this->subject('Pendaftaran Akun Sukses')->view('email.approve-user-email');
}
}

59
app/Mail/denyUser.php Normal file
View File

@ -0,0 +1,59 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class denyUser extends Mailable
{
use Queueable, SerializesModels;
public $content;
/**
* Create a new message instance.
*/
public function __construct($content)
{
$this->content = $content;
}
/**
* Get the message envelope.
*/
// public function envelope(): Envelope
// {
// return new Envelope(
// subject: 'Deny User',
// );
// }
/**
* Get the message content definition.
*/
// public function content(): Content
// {
// return new Content(
// view: 'view.name',
// );
// }
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
// public function attachments(): array
// {
// return [];
// }
public function build(){
return $this->subject('Pendaftaran Akun Gagal')->view('email.deny-user-email');
}
}

View File

@ -30,7 +30,6 @@ class Transaction extends Model
'status_transaksi', 'status_transaksi',
'status_pembayaran', 'status_pembayaran',
'batas_pembayaran', 'batas_pembayaran',
'batas_pengiriman_barang_awal',
'batas_pengiriman_barang_akhir', 'batas_pengiriman_barang_akhir',
'nama_bank_penjual', 'nama_bank_penjual',
'no_rek_penjual' 'no_rek_penjual'

View File

@ -34,7 +34,8 @@ class UserFactory extends Factory
'status'=> $this->faker->randomElement(['Progress', 'Finished', 'Rejected']), 'status'=> $this->faker->randomElement(['Progress', 'Finished', 'Rejected']),
'gender' => $this->faker->randomElement(['Laki-laki', 'Perempuan']), 'gender' => $this->faker->randomElement(['Laki-laki', 'Perempuan']),
'kode_kelurahan' => '1101012002', 'kode_kelurahan' => '1101012002',
'keterangan' => $this->faker->sentence 'keterangan' => $this->faker->sentence,
'foto_profile' => 'face'.random_int(1,10).'.jpg'
]; ];
} }

View File

@ -32,8 +32,8 @@ return new class extends Migration
$table->enum('status_transaksi',['success','challenge','failure','process','sending','sent','finished','created', 'refund', 'done'])->default('created'); // transaction_status $table->enum('status_transaksi',['success','challenge','failure','process','sending','sent','finished','created', 'refund', 'done'])->default('created'); // transaction_status
$table->enum('status_pembayaran',['settlement','capture','pending','expire','failure','cancel','refund'])->nullable(); // status transaksi dari midtrans $table->enum('status_pembayaran',['settlement','capture','pending','expire','failure','cancel','refund'])->nullable(); // status transaksi dari midtrans
$table->timestamp('batas_pembayaran')->nullable(); $table->timestamp('batas_pembayaran')->nullable();
$table->timestamp('batas_pembatalan_transaksi')->nullable();
$table->timestamp('batas_konfirmasi_transaksi')->nullable(); $table->timestamp('batas_konfirmasi_transaksi')->nullable();
$table->timestamp('batas_pengiriman_barang_awal');
$table->timestamp('batas_pengiriman_barang_akhir'); $table->timestamp('batas_pengiriman_barang_akhir');
$table->timestamp('tanggal_transaksi')->nullable(); $table->timestamp('tanggal_transaksi')->nullable();
$table->string('nama_bank_penjual'); $table->string('nama_bank_penjual');

View File

@ -50,6 +50,7 @@ class DatabaseSeeder extends Seeder
'persentase_kemiripan' => 100, 'persentase_kemiripan' => 100,
'gender' => $faker->randomElement(['Laki-laki', 'Perempuan']), 'gender' => $faker->randomElement(['Laki-laki', 'Perempuan']),
'kode_kelurahan' => '1101012002', 'kode_kelurahan' => '1101012002',
'foto_profile' => 'face1.jpg'
]); ]);
$user1 = User::factory()->create([ $user1 = User::factory()->create([
@ -71,7 +72,8 @@ class DatabaseSeeder extends Seeder
'kode_kelurahan' => '1101012002', 'kode_kelurahan' => '1101012002',
'nama_bank' => 'mandiri', 'nama_bank' => 'mandiri',
'no_rek' => '019809210873', 'no_rek' => '019809210873',
'keterangan' => $faker->sentence() 'keterangan' => $faker->sentence(),
'foto_profile' => 'face2.jpg'
]); ]);
$user2 = User::factory()->create([ $user2 = User::factory()->create([
@ -93,7 +95,8 @@ class DatabaseSeeder extends Seeder
'kode_kelurahan' => '1101012002', 'kode_kelurahan' => '1101012002',
'nama_bank' => 'bca', 'nama_bank' => 'bca',
'no_rek' => '01980921', 'no_rek' => '01980921',
'keterangan' => $faker->sentence() 'keterangan' => $faker->sentence(),
'foto_profile' => 'face3.jpg'
]); ]);
User::factory(100)->create(); User::factory(100)->create();
@ -125,7 +128,6 @@ class DatabaseSeeder extends Seeder
'token' => 'asda', 'token' => 'asda',
'status_transaksi' => 'created', 'status_transaksi' => 'created',
'batas_pembayaran' => now(), 'batas_pembayaran' => now(),
'batas_pengiriman_barang_awal' => now(),
'batas_pengiriman_barang_akhir' => now(), 'batas_pengiriman_barang_akhir' => now(),
'nama_bank_penjual' => $user2->nama_bank, 'nama_bank_penjual' => $user2->nama_bank,
'no_rek_penjual' => $user2->no_rek, 'no_rek_penjual' => $user2->no_rek,
@ -140,6 +142,36 @@ class DatabaseSeeder extends Seeder
'deskripsi' => $user1->nama_depan . ' telah membuat transaksi baru dengan ' . $user2->nama_depan, 'deskripsi' => $user1->nama_depan . ' telah membuat transaksi baru dengan ' . $user2->nama_depan,
]); ]);
$transaction = Transaction::create([
'id' => Str::uuid(),
'pembeli' => $user2->email,
'penjual' => $user1->email,
'nama_barang' => 'hah',
'deskripsi_transaksi' => null,
'satuan_barang' => 'barang',
'harga_barang' => 2000,
'jumlah_barang' => 2,
'persentase_keuntungan' => 2,
'total_keuntungan' => 2,
'total_harga' => 2,
'total_bayar' => 2,
'token' => 'asda',
'status_transaksi' => 'created',
'batas_pembayaran' => now(),
'batas_pengiriman_barang_akhir' => now(),
'nama_bank_penjual' => $user1->nama_bank,
'no_rek_penjual' => $user1->no_rek,
]);
TransactionDescription::create([
'transaction_id' => $transaction->id,
'status' => 'pending',
'user' => $user2->email,
'judul' => 'fa fa-plus',
'background' => 'bg-buyer',
'deskripsi' => $user2->nama_depan . ' telah membuat transaksi baru dengan ' . $user1->nama_depan,
]);
$transactionRefund = Transaction::create([ $transactionRefund = Transaction::create([
'id' => Str::uuid(), 'id' => Str::uuid(),
'pembeli' => $user1->email, 'pembeli' => $user1->email,
@ -157,7 +189,6 @@ class DatabaseSeeder extends Seeder
'status_transaksi' => 'success', 'status_transaksi' => 'success',
'status_pembayaran' => 'refund', 'status_pembayaran' => 'refund',
'batas_pembayaran' => now(), 'batas_pembayaran' => now(),
'batas_pengiriman_barang_awal' => now(),
'batas_pengiriman_barang_akhir' => now(), 'batas_pengiriman_barang_akhir' => now(),
'nama_bank_penjual' => $user2->nama_bank, 'nama_bank_penjual' => $user2->nama_bank,
'no_rek_penjual' => $user2->no_rek, 'no_rek_penjual' => $user2->no_rek,

View File

@ -1271,9 +1271,9 @@ select.form-control:not([size]):not([multiple]) {
margin-bottom: -15px; margin-bottom: -15px;
} }
.card.card-statistic-2 .card-chart canvas { /* .card.card-statistic-2 .card-chart canvas {
height: 90px !important; height: 90px !important;
} } */
.card .card-stats { .card .card-stats {
width: 100%; width: 100%;

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

View File

@ -4,109 +4,123 @@
<div class="main-content"> <div class="main-content">
<section class="section"> <section class="section">
<div class="row"> <div class="row">
<div class="col-lg-4 col-md-4 col-sm-12"> <div class="col-lg-4 col-md-12 col-sm-12">
<div class="card card-statistic-2"> <div class="card card-statistic-2">
<div class="card-stats"> <div class="card-stats">
<div class="card-stats-title">List Transaction - <div class="card-stats-title">
<div class="dropdown d-inline"> <h4>Transaksi</h4>
<a class="font-weight-600 dropdown-toggle" data-toggle="dropdown" href="#"
id="orders-month">August</a>
<ul class="dropdown-menu dropdown-menu-sm">
<li class="dropdown-title">Select Month</li>
<li><a href="#" class="dropdown-item">January</a></li>
<li><a href="#" class="dropdown-item">February</a></li>
<li><a href="#" class="dropdown-item">March</a></li>
<li><a href="#" class="dropdown-item">April</a></li>
<li><a href="#" class="dropdown-item">May</a></li>
<li><a href="#" class="dropdown-item">June</a></li>
<li><a href="#" class="dropdown-item">July</a></li>
<li><a href="#" class="dropdown-item active">August</a></li>
<li><a href="#" class="dropdown-item">September</a></li>
<li><a href="#" class="dropdown-item">October</a></li>
<li><a href="#" class="dropdown-item">November</a></li>
<li><a href="#" class="dropdown-item">December</a></li>
</ul>
</div> </div>
</div> <div class="card-stats-items mt-2">
<div class="card-stats-items">
<div class="card-stats-item"> <div class="card-stats-item">
<div class="card-stats-item-count">{{ $countSuccess }}</div> <div class="card-stats-item-count" id="countSuccess">{{ $countSuccess }}</div>
<div class="card-stats-item-label">Success</div> <div class="card-stats-item-label">Selesai</div>
</div> </div>
<div class="card-stats-item"> <div class="card-stats-item">
<div class="card-stats-item-count">{{ $countPending }}</div> <div class="card-stats-item-count" id="countCancelled">{{ $countCancelled }}</div>
<div class="card-stats-item-label">Pending</div> <div class="card-stats-item-label">Gagal</div>
</div> </div>
<div class="card-stats-item"> <div class="card-stats-item">
<div class="card-stats-item-count">{{ $countCancelled }}</div> <div class="card-stats-item-count" id="countProcessed">{{ $countProcessed }}</div>
<div class="card-stats-item-label">Canceled</div> <div class="card-stats-item-label">Diproses</div>
</div> </div>
<div class="card-stats-item"> <div class="card-stats-item">
<div class="card-stats-item-count">{{ $countRefund }}</div> <div class="card-stats-item-count" id="countIndicated">{{ $countIndicated }}</div>
<div class="card-stats-item-label">Refund</div> <div class="card-stats-item-label">Diterindikasi</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countWaiting">{{ $countWaiting }}</div>
<div class="card-stats-item-label">Menunggu</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card-wrap">
<div class="card-header">
<h4>Total Transaksi</h4>
</div>
<div class="card-icon shadow-primary bg-primary"> <div class="card-icon shadow-primary bg-primary">
<i class="fas fa-exchange-alt"></i> <i class="fas fa-exchange-alt"></i>
</div> </div>
<div class="card-wrap"> <div class="card-body" id="totalTransaction">
<div class="card-header"> {{ $totalTransaction }} Transaksi
<h4>Total Transaction</h4>
</div>
<div class="card-body">
{{ $totalTransaction }}
</div> </div>
</div> </div>
<p class="mb-0 text-muted"> <p class="mb-0 text-muted" id="rateTransaction">
<span class="text-success me-2"><span class="mdi mdi-arrow-up-bold"></span> <span
1.08%</span> class="text-{{ $rateTransaction == 0 ? 'secondary text-black-50' : ($rateTransaction > 0 ? 'success' : 'danger') }} me-2"><span
<span class="text-nowrap">Since last week</span> class="mdi {{ $rateTransaction == 0 ? 'mdi-equal' : ($rateTransaction > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ abs($rateTransaction) }}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
</p> </p>
</div> </div>
</div> </div>
<div class="col-lg-4 col-md-4 col-sm-12"> <div class="col-lg-4 col-md-12 col-sm-12">
<div class="card card-statistic-2"> <div class="card card-statistic-2">
<div class="card-chart"> <div class="card-stats">
<canvas id="balance-chart" height="80"></canvas> <div class="card-stats-title">
<h4>Refund</h4>
</div>
<div class="card-stats-items mt-2">
<div class="card-stats-item">
<div class="card-stats-item-count" id="countPending">{{ $countPending }}</div>
<div class="card-stats-item-label">Menunggu</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countApprove">{{ $countApprove }}</div>
<div class="card-stats-item-label">Disetujui</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countDeny">{{ $countDeny }}</div>
<div class="card-stats-item-label">Ditolak</div>
</div>
</div> </div>
<div class="card-icon shadow-primary bg-primary">
<i class="fas fa-money-check"></i>
</div> </div>
<div class="card-wrap"> <div class="card-wrap">
<div class="card-header"> <div class="card-header">
<h4>Total Refund</h4> <h4>Total Refund</h4>
</div> </div>
<div class="card-body"> <div class="card-icon shadow-primary bg-primary">
{{ $totalRefund }} <i class="fas fa-exchange-alt"></i>
</div>
<div class="card-body" id="totalRefund">
{{ $totalRefund }} Pengajuan
</div> </div>
</div> </div>
<p class="mb-0 text-muted"> <p class="mb-0 text-muted" id="rateRefund">
<span class="text-success me-2"><span class="mdi mdi-arrow-up-bold"></span> <span
5.27%</span> class="text-{{ $rateRefund == 0 ? 'secondary text-black-50' : ($rateRefund > 0 ? 'success' : 'danger') }} me-2"><span
<span class="text-nowrap">Since last month</span> class="mdi {{ $rateRefund == 0 ? 'mdi-equal' : ($rateRefund > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ abs($rateRefund) }}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
</p> </p>
</div> </div>
</div> </div>
<div class="col-lg-4 col-md-4 col-sm-12"> <div class="col-lg-4 col-md-12 col-sm-12">
<div class="card card-statistic-2"> <div class="card card-statistic-2">
<div class="card-stats">
<div class="card-stats-title">
<h4>Pengguna</h4>
</div>
</div>
<div class="card-chart"> <div class="card-chart">
<canvas id="sales-chart" height="80"></canvas> <canvas id="users-chart" height="80"></canvas>
</div>
<div class="card-wrap">
<div class="card-header">
<h4>Total Pengguna</h4>
</div> </div>
<div class="card-icon shadow-primary bg-primary"> <div class="card-icon shadow-primary bg-primary">
<i class="fas fa-user"></i> <i class="fas fa-user"></i>
</div> </div>
<div class="card-wrap"> <div class="card-body" id="totalUser">
<div class="card-header"> {{ $totalUser }} Pengguna
<h4>Total user</h4>
</div> </div>
<div class="card-body">
{{ $totalUser }}</div>
</div> </div>
<p class="mb-0 text-muted"> <p class="mb-0 text-muted" id="rateUser">
<span class="text-danger me-2"><span class="mdi mdi-arrow-down-bold"></span> <span
1.08%</span> class="text-{{ $rateUser == 0 ? 'secondary text-black-50' : ($rateUser > 0 ? 'success' : 'danger') }} me-2"><span
<span class="text-nowrap">Since previous week</span> class="mdi {{ $rateUser == 0 ? 'mdi-equal' : ($rateUser > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ abs($rateUser) }}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
</p> </p>
</div> </div>
</div> </div>
@ -115,18 +129,17 @@
<div class="row"> <div class="row">
<div class="col-lg-8"> <div class="col-lg-8">
<div class="card"> <div class="card">
<div class="alert alert-primary alert-dismissible fade show mb-3" role="alert"> <div id="rateProfit">
Pendapatan Hari Ini meningkat <span class="mdi mdi-arrow-up-bold"></span> <div class="alert alert-{{ $rateProfit == 0 ? 'secondary text-black-50' : ($rateProfit > 0 ? 'success' : 'error') }} alert-dismissible fade show mb-3"
5.27%</span> role="alert">
Pendapatan {{ $rateProfit == 0 ? 'sama' : ($rateProfit > 0 ? 'meningkat' : 'menurun') }}
<span
class="mdi {{ $rateProfit == 0 ? 'mdi-equal' : ($rateProfit > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ $rateProfit }}%
</div>
</div> </div>
<div class="card-header"> <div class="card-header">
<h4>Statistics</h4> <h4>Pendapatan</h4>
<div class="card-header-action">
<div class="btn-group">
<a href="#" class="btn btn-primary">Week</a>
<a href="#" class="btn">Month</a>
</div>
</div>
</div> </div>
<div class="card-body"> <div class="card-body">
<canvas id="myChart1"></canvas> <canvas id="myChart1"></canvas>
@ -136,137 +149,60 @@
<div class="col-lg-4"> <div class="col-lg-4">
<div class="input-group mt-4"> <div class="input-group mt-4">
<input type="text" name="from-to" class="form-control" id="date-range"> <input type="text" name="from-to" class="form-control" id="date-range">
<label class="input-group-text bg-primary text-white align-items-center" for="date-range"> <span class="input-group-text bg-primary text-white align-items-center">
<i class="mdi mdi-calendar-range font-13"></i> <i class="mdi mdi-calendar-range font-13"></i>
</label> </span>
</div> </div>
<div class="card gradient-bottom"> <div class="card gradient-bottom">
<div class="card-header"> <div class="card-header">
<h4>Top 5 Users</h4> <h4>Top 5 Users</h4>
<div class="card-header-action dropdown">
<a href="#" data-toggle="dropdown"
class="btn btn-primary dropdown-toggle">Month</a>
<ul class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
<li class="dropdown-title">Select Period</li>
<li><a href="#" class="dropdown-item">Today</a></li>
<li><a href="#" class="dropdown-item">Week</a></li>
<li><a href="#" class="dropdown-item active">Month</a></li>
<li><a href="#" class="dropdown-item">This Year</a></li>
</ul>
</div>
</div> </div>
<div class="card-body" id="top-5-scroll"> <div class="card-body" id="top-5-scroll">
<ul class="list-unstyled list-unstyled-border"> <ul class="list-unstyled list-unstyled-border" id="listTopUser">
@forelse ($dataTopUsers as $user)
<li class="media"> <li class="media">
<img class="mr-3 rounded" width="55" <img class="mr-3 rounded" width="55"
src="{{ asset('assets/img/avatar/avatar-6.png') }}" alt="product"> src="{{ $user->foto_profile == null ? asset('storage/foto-profile/face1.jpg') : asset('storage/foto-profile/' . $user->foto_profile) }}"
alt="product">
<div class="media-body"> <div class="media-body">
<div class="float-right"> <div class="float-right">
<div class="font-weight-600 text-muted text-small">86 Sales</div> <div class="font-weight-600 text-muted text-small">
{{ $user->jumlah_transaksi }} transaksi
</div> </div>
<div class="media-title">Jilhan Haura</div> </div>
<div class="media-title">{{ $user->nama_lengkap }}</div>
<div class="mt-1"> <div class="mt-1">
<div class="budget-price"> <div class="budget-price">
<div class="budget-price-square bg-primary" data-width="64%"></div> <div class="budget-price-square bg-primary"
<div class="budget-price-label">$68,714</div> data-width="{{ (floatval($user->total_transaksi_berhasil) * 100) / (floatval($user->total_transaksi_berhasil) + floatval($user->total_refund_berhasil)) / 1.5 }}%">
</div>
<div class="budget-price-label">Rp
{{ number_format($user->total_transaksi_berhasil, 2, ',', '.') }}
</div>
</div> </div>
<div class="budget-price"> <div class="budget-price">
<div class="budget-price-square bg-danger" data-width="43%"></div> <div class="budget-price-square bg-danger"
<div class="budget-price-label">$38,700</div> data-width="{{ (floatval($user->total_refund_berhasil) * 100) / (floatval($user->total_transaksi_berhasil) + floatval($user->total_refund_berhasil)) / 1.5 }}%">
</div> </div>
</div> <div class="budget-price-label">Rp
</div> {{ number_format($user->total_refund_berhasil, 2, ',', '.') }}
</li> </div>
<li class="media">
<img class="mr-3 rounded" width="55"
src="{{ asset('assets/img/avatar/avatar-1.png') }}" alt="product">
<div class="media-body">
<div class="float-right">
<div class="font-weight-600 text-muted text-small">67 Sales</div>
</div>
<div class="media-title">Nurul Prima</div>
<div class="mt-1">
<div class="budget-price">
<div class="budget-price-square bg-primary" data-width="84%"></div>
<div class="budget-price-label">$107,133</div>
</div>
<div class="budget-price">
<div class="budget-price-square bg-danger" data-width="60%"></div>
<div class="budget-price-label">$91,455</div>
</div>
</div>
</div>
</li>
<li class="media">
<img class="mr-3 rounded" width="55"
src="{{ asset('assets/img/avatar/avatar-2.png') }}" alt="product">
<div class="media-body">
<div class="float-right">
<div class="font-weight-600 text-muted text-small">63 Sales</div>
</div>
<div class="media-title">Muhammad Raihan</div>
<div class="mt-1">
<div class="budget-price">
<div class="budget-price-square bg-primary" data-width="34%"></div>
<div class="budget-price-label">$3,717</div>
</div>
<div class="budget-price">
<div class="budget-price-square bg-danger" data-width="28%"></div>
<div class="budget-price-label">$2,835</div>
</div>
</div>
</div>
</li>
<li class="media">
<img class="mr-3 rounded" width="55"
src="{{ asset('assets/img/avatar/avatar-3.png') }}" alt="product">
<div class="media-body">
<div class="float-right">
<div class="font-weight-600 text-muted text-small">28 Sales</div>
</div>
<div class="media-title">Hantu</div>
<div class="mt-1">
<div class="budget-price">
<div class="budget-price-square bg-primary" data-width="45%"></div>
<div class="budget-price-label">$13,972</div>
</div>
<div class="budget-price">
<div class="budget-price-square bg-danger" data-width="30%"></div>
<div class="budget-price-label">$9,660</div>
</div>
</div>
</div>
</li>
<li class="media">
<img class="mr-3 rounded" width="55"
src="{{ asset('assets/img/avatar/avatar-4.png') }}" alt="product">
<div class="media-body">
<div class="float-right">
<div class="font-weight-600 text-muted text-small">19 Sales</div>
</div>
<div class="media-title">Testing</div>
<div class="mt-1">
<div class="budget-price">
<div class="budget-price-square bg-primary" data-width="35%"></div>
<div class="budget-price-label">$7,391</div>
</div>
<div class="budget-price">
<div class="budget-price-square bg-danger" data-width="28%"></div>
<div class="budget-price-label">$5,472</div>
</div> </div>
</div> </div>
</div> </div>
</li> </li>
@empty
@endforelse
</ul> </ul>
</div> </div>
<div class="card-footer pt-3 d-flex justify-content-center"> <div class="pt-3 d-flex justify-content-center">
<div class="budget-price justify-content-center"> <div class="budget-price justify-content-center">
<div class="budget-price-square bg-primary" data-width="20"></div> <div class="budget-price-square bg-primary" data-width="20"></div>
<div class="budget-price-label">Sukses</div> <div class="budget-price-label">Transaksi Selesai</div>
</div> </div>
<div class="budget-price justify-content-center"> <div class="budget-price justify-content-center">
<div class="budget-price-square bg-danger" data-width="20"></div> <div class="budget-price-square bg-danger" data-width="20"></div>
<div class="budget-price-label">Refund</div> <div class="budget-price-label">Refund Selesai</div>
</div> </div>
</div> </div>
</div> </div>
@ -275,61 +211,15 @@
</section> </section>
</div> </div>
@include('admin.transaction.modal-tracking') @include('admin.transaction.modal-tracking')
@endsection
@section('tambahan-js')
<script> <script>
let dataChartTransaction = {{ json_encode($dataChartTransaction) }}; let dataChartTransaction = {{ json_encode($dataChartTransaction) }};
let dataChartRefund = {{ json_encode($dataChartRefund) }}; let dataChartRefund = {{ json_encode($dataChartRefund) }};
let labels = ''; let dataChartUser = {{ json_encode($dataChartUser) }};
let dataChartTotalRefund = {{ json_encode($dataChartTotalRefund) }}; let dataLabel = {!! json_encode($dataLabel) !!};
let dataChartTotalUser = {{ json_encode($dataChartTotalUser) }};
</script> </script>
<script> <script>
// Date picker range
$(document).ready(function() {
let searchParams = new URLSearchParams(window.location.search);
let dateInterval = searchParams.get('from-to');
let start = moment().subtract(29, 'days');
let end = moment();
if (dateInterval) {
dateInterval = dateInterval.split(' - ');
start = moment(dateInterval[0]);
end = moment(dateInterval[1]);
}
$('#date-range').daterangepicker({
"showDropdowns": true,
"showWeekNumbers": true,
"alwaysShowCalendars": true,
startDate: start,
endDate: end,
locale: {
format: 'YYYY-MM-DD',
firstDay: 1,
},
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1,
'month').endOf(
'month')],
'This Year': [moment().startOf('year'), moment().endOf('year')],
'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year')
.endOf(
'year')
],
'All time': [moment().subtract(30, 'year').startOf('month'), moment().endOf('month')],
}
}, function(start, end, label) {
// Menangkap rentang tanggal yang dipilih dan menampilkan di console
console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format(
'YYYY-MM-DD'));
});
});
// Set new default font family and font color to mimic Bootstrap's default styling
Chart.defaults.global.defaultFontFamily = 'Nunito', Chart.defaults.global.defaultFontFamily = 'Nunito',
'-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif'; '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
Chart.defaults.global.defaultFontColor = '#858796'; Chart.defaults.global.defaultFontColor = '#858796';
@ -338,12 +228,10 @@
var myChart = new Chart(ctx, { var myChart = new Chart(ctx, {
type: 'line', type: 'line',
data: { data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Agu", "Sep", labels: dataLabel,
"Okt", "Nov", "Des"
],
datasets: [{ datasets: [{
label: 'Transaction', label: 'Transaction',
data: {{ json_encode($dataChartTransaction) }}, data: dataChartTransaction,
borderWidth: 2, borderWidth: 2,
backgroundColor: 'rgba(63,82,227,.8)', backgroundColor: 'rgba(63,82,227,.8)',
borderWidth: 0, borderWidth: 0,
@ -355,7 +243,7 @@
}, },
{ {
label: 'Refund', label: 'Refund',
data: [2207, 3403, 220000, 5025, 2302, 4208, 3880, 4880, 5000], data: dataChartRefund,
borderWidth: 2, borderWidth: 2,
backgroundColor: 'rgba(254,86,83,.7)', backgroundColor: 'rgba(254,86,83,.7)',
borderWidth: 0, borderWidth: 0,
@ -381,26 +269,22 @@
scales: { scales: {
yAxes: [{ yAxes: [{
gridLines: { gridLines: {
// display: false,
drawBorder: false, drawBorder: false,
color: '#f2f2f2', color: '#f2f2f2',
}, },
ticks: { ticks: {
beginAtZero: true, beginAtZero: true,
stepSize: 15000, // stepSize: 1000,
callback: function(value, index, values) { // callback: function(value, index, values) {
// return 'Rp.' + value; // return value;
return new Intl.NumberFormat('id-ID', { // },
style: 'currency',
currency: 'IDR',
}).format(value);
},
fontSize: 14, fontSize: 14,
maxTicksLimit: 6,
}, },
scaleLabel: { scaleLabel: {
display: true, display: true,
labelString: 'Dalam Ratusan Juta', // Label khusus untuk sumbu Y labelString: 'Dalam Rupiah (Rp)',
fontSize: 16 // Ukuran font untuk label sumbu Y fontSize: 16,
}, },
}], }],
xAxes: [{ xAxes: [{
@ -409,91 +293,28 @@
tickMarkLength: 15, tickMarkLength: 15,
}, },
ticks: { ticks: {
fontSize: 16, display: false,
} maxTicksLimit: 8,
},
offset: true,
}] }]
}, },
} }
}); });
var balance_chart = document.getElementById("balance-chart").getContext('2d'); var users_chart = document.getElementById("users-chart").getContext('2d');
var balance_chart_bg_color = balance_chart.createLinearGradient(0, 0, 0, 70); var users_chart_bg_color = users_chart.createLinearGradient(0, 0, 0, 80);
balance_chart_bg_color.addColorStop(0, 'rgba(63,82,227,.2)');
balance_chart_bg_color.addColorStop(1, 'rgba(63,82,227,0)');
var myChart = new Chart(balance_chart, { var myChartUser = new Chart(users_chart, {
type: 'line', type: 'line',
data: { data: {
labels: ['16-07-2018', '17-07-2018', '18-07-2018', '19-07-2018', '20-07-2018', '21-07-2018', labels: dataLabel,
'22-07-2018', '23-07-2018', '24-07-2018', '25-07-2018', '26-07-2018', '27-07-2018',
'28-07-2018', '29-07-2018', '30-07-2018', '31-07-2018'
],
datasets: [{
label: 'Balance',
data: [50, 61, 80, 50, 72, 52, 60, 41, 30, 45, 70, 40, 93, 63, 50, 62],
backgroundColor: balance_chart_bg_color,
borderWidth: 3,
borderColor: 'rgba(63,82,227,1)',
pointBorderWidth: 0,
pointBorderColor: 'transparent',
pointRadius: 3,
pointBackgroundColor: 'transparent',
pointHoverBackgroundColor: 'rgba(63,82,227,1)',
}]
},
options: {
layout: {
padding: {
bottom: -1,
left: -1
}
},
legend: {
display: false
},
scales: {
yAxes: [{
gridLines: {
display: false,
drawBorder: false,
},
ticks: {
beginAtZero: true,
display: false
}
}],
xAxes: [{
gridLines: {
drawBorder: false,
display: false,
},
ticks: {
display: false
}
}]
},
}
});
var sales_chart = document.getElementById("sales-chart").getContext('2d');
var sales_chart_bg_color = sales_chart.createLinearGradient(0, 0, 0, 80);
balance_chart_bg_color.addColorStop(0, 'rgba(63,82,227,.2)');
balance_chart_bg_color.addColorStop(1, 'rgba(63,82,227,0)');
var myChart = new Chart(sales_chart, {
type: 'line',
data: {
labels: ['16-07-2018', '17-07-2018', '18-07-2018', '19-07-2018', '20-07-2018', '21-07-2018',
'22-07-2018', '23-07-2018', '24-07-2018', '25-07-2018', '26-07-2018', '27-07-2018',
'28-07-2018', '29-07-2018', '30-07-2018', '31-07-2018'
],
datasets: [{ datasets: [{
label: 'Sales', label: 'Sales',
data: [70, 62, 44, 40, 21, 63, 82, 52, 50, 31, 70, 50, 91, 63, 51, 60], data: dataChartUser,
borderWidth: 2, borderWidth: 2,
backgroundColor: balance_chart_bg_color, backgroundColor: users_chart_bg_color,
borderWidth: 3, borderWidth: 3,
borderColor: 'rgba(63,82,227,1)', borderColor: 'rgba(63,82,227,1)',
pointBorderWidth: 0, pointBorderWidth: 0,
@ -506,8 +327,8 @@
options: { options: {
layout: { layout: {
padding: { padding: {
bottom: -1, bottom: 0,
left: -1 left: 0
} }
}, },
legend: { legend: {
@ -518,23 +339,264 @@
gridLines: { gridLines: {
display: false, display: false,
drawBorder: false, drawBorder: false,
color: '#f2f2f2',
}, },
ticks: { ticks: {
beginAtZero: true, beginAtZero: true,
display: false display: false,
maxTicksLimit: 6,
} }
}], }],
xAxes: [{ xAxes: [{
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
display: false, display: true,
}, },
ticks: { ticks: {
display: false display: false,
} maxTicksLimit: 8,
},
offset: true,
}] }]
}, },
} }
}); });
</script> </script>
<script>
$(document).ready(function() {
const csrfToken = $('meta[name="csrf-token"]').attr('content');
let searchParams = new URLSearchParams(window.location.search);
let dateInterval = searchParams.get('from-to');
let start = moment().subtract(29, 'days');
let end = moment();
if (dateInterval) {
dateInterval = dateInterval.split(' - ');
start = moment(dateInterval[0]);
end = moment(dateInterval[1]);
}
$('#date-range').daterangepicker({
"showDropdowns": true,
"showWeekNumbers": true,
"alwaysShowCalendars": true,
startDate: start,
endDate: end,
locale: {
format: 'YYYY-MM-DD',
firstDay: 1,
},
minDate: "2023-01-01",
maxDate: "2025-12-31",
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1,
'month').endOf(
'month')],
'This Year': [moment().startOf('year'), moment().endOf('year')],
'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year')
.endOf(
'year')
]
}
}).on('apply.daterangepicker', function(ev, picker) {
var startDate = picker.startDate.format('YYYY-MM-DD');
var endDate = picker.endDate.format('YYYY-MM-DD');
console.log('Rentang tanggal dipilih:', startDate, 'sampai',
endDate);
Swal.fire({
html: '<div class="mt-3"><lord-icon src="https://cdn.lordicon.com/etwtznjn.json" trigger="loop" colors="primary:#0ab39c,secondary:#405189" style="width:120px;height:120px"></lord-icon><div class="mt-4 pt-2 fs-15"><h4>Form Anda sedang diproses!</h4><p class="text-muted mx-4 mb-0">Mohon tunggu...</p></div></div>',
allowEscapeKey: false,
allowOutsideClick: false,
didOpen: () => {
Swal.showLoading();
}
});
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': csrfToken
}
});
$.ajax({
url: "{{ route('admin.get-data-dashboard') }}",
type: 'GET',
data: {
startDate: startDate,
endDate: endDate
},
success: function(response) {
Swal.close();
myChart.data.datasets[0].data = response.dataChartTransaction;
myChart.data.datasets[1].data = response.dataChartRefund;
myChart.data.labels = response.dataLabel;
myChart.update();
myChartUser.data.datasets[0].data = response.dataChartUser;
myChartUser.data.labels = response.dataLabel;
myChartUser.update();
$('#countSuccess').html(response.countSuccess);
$('#countCancelled').html(response.countCancelled);
$('#countProcessed').html(response.countProcessed);
$('#countIndicated').html(response.countIndicated);
$('#countWaiting').html(response.countWaiting);
$('#totalTransaction').html(response.totalTransaction);
var activitiesRateTransaction = '';
var rateTransactionClass = response.rateTransaction == 0 ?
"secondary text-black-50" : (response.rateTransaction > 0 ?
"success" : "danger");
var rateTransactionClassIcon = response.rateTransaction == 0 ?
"mdi-equal" : (response.rateTransaction > 0 ?
"mdi-arrow-up-bold" : "mdi-arrow-down-bold");
activitiesRateTransaction = `
<span class="text-${rateTransactionClass} me-2"><span
class="mdi ${rateTransactionClassIcon}"></span>
${Math.abs(response.rateTransaction)}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
`;
$('#rateTransaction').html(activitiesRateTransaction);
$('#countPending').html(response.countPending);
$('#countApprove').html(response.countApprove);
$('#countDeny').html(response.countDeny);
$('#totalRefund').html(response.totalRefund);
var activitiesRateRefund = '';
var rateRefundClass = response.rateRefund == 0 ?
"secondary text-black-50" : (response.rateRefund > 0 ?
"success" : "danger");
var rateRefundClassIcon = response.rateRefund == 0 ?
"mdi-equal" : (response.rateRefund > 0 ?
"mdi-arrow-up-bold" : "mdi-arrow-down-bold");
activitiesRateRefund = `
<span class="text-${rateRefundClass} me-2"><span
class="mdi ${rateRefundClassIcon}"></span>
${Math.abs(response.rateRefund)}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
`;
$('#rateRefund').html(activitiesRateRefund);
$('#totalUser').html(response.totalUser);
var activitiesRateUser = '';
var rateUserClass = response.rateUser == 0 ?
"secondary text-black-50" : (response.rateUser > 0 ?
"success" : "danger");
var rateUserClassIcon = response.rateUser == 0 ?
"mdi-equal" : (response.rateUser > 0 ?
"mdi-arrow-up-bold" : "mdi-arrow-down-bold");
activitiesRateUser = `
<span class="text-${rateUserClass} me-2"><span
class="mdi ${rateUserClassIcon}"></span>
${Math.abs(response.rateUser)}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
`;
$('#rateUser').html(activitiesRateUser);
var activitiesRateProfit = '';
var rateProfitClass = response.rateProfit == 0 ?
"secondary text-black-50" : (response.rateProfit > 0 ?
"success" : "danger");
var rateProfitMention = response.rateProfit == 0 ? "sama" : (response
.rateProfit > 0 ? "meningkat" : "menurun");
var rateProfitClassIcon = response.rateProfit == 0 ?
"sama" : (response.rateProfit > 0 ?
"meningkat" : "menurun");
activitiesRateProfit = `
<div class="alert alert-${rateProfitClass} alert-dismissible fade show mb-3"
role="alert">
Pendapatan ${rateProfitMention}
<span
class="mdi ${rateProfitClassIcon}"></span>
${Math.abs(response.rateProfit)}%
</div>
`;
$('#rateProfit').html(activitiesRateProfit);
// ListTopUser
var activitiesHtml = '';
response.dataTopUser.forEach(user => {
let fotoProfile = user.foto_profile == null ?
"{{ asset('storage/foto-profile/face1.jpg') }}" :
"{{ asset('storage/foto-profile') }}/" + user
.foto_profile;
let totalTransaction = new Intl.NumberFormat('id-ID', {
style: 'currency',
currency: 'IDR'
}).format(user.total_transaksi_berhasil);
let totalRefund = new Intl.NumberFormat('id-ID', {
style: 'currency',
currency: 'IDR'
}).format(user.total_refund_berhasil);
let transactionWidth = ((parseFloat(user
.total_transaksi_berhasil) *
100) / (parseFloat(user
.total_transaksi_berhasil) +
parseFloat(user.total_refund_berhasil))) / 1.5;
let refundWidth = ((parseFloat(user.total_refund_berhasil) *
100) / (
parseFloat(user.total_transaksi_berhasil) +
parseFloat(user.total_refund_berhasil))) / 1.5;
activitiesHtml += `
<li class="media">
<img class="mr-3 rounded" width="55"
src="${fotoProfile}"
alt="product">
<div class="media-body">
<div class="float-right">
<div class="font-weight-600 text-muted text-small">
${user.jumlah_transaksi} transaksi
</div>
</div>
<div class="media-title">${user.nama_lengkap}</div>
<div class="mt-1">
<div class="budget-price">
<div class="budget-price-square bg-primary"
data-width="${transactionWidth}%" style="width:${transactionWidth}%">
</div>
<div class="budget-price-label">
${totalTransaction}
</div>
</div>
<div class="budget-price">
<div class="budget-price-square bg-danger"
data-width="${refundWidth}%" style="width:${refundWidth}%">
</div>
<div class="budget-price-label">
${totalRefund}
</div>
</div>
</div>
</div>
</li>
`;
});
$('#listTopUser').html(activitiesHtml);
},
error: function(error) {
Swal.close();
console.log(error);
}
});
});
});
</script>
@endsection @endsection

View File

@ -1,5 +1,5 @@
@extends('layouts.main') @extends('layouts.main')
@section('content') @section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let selected = []; let selected = [];
@ -126,6 +126,13 @@
icon: result.status ? 'success' : 'error' icon: result.status ? 'success' : 'error'
}).then(function() { }).then(function() {
if (result.status) { if (result.status) {
$.ajax({
url: "{{ route('admin-notification.update-new-notification') }}",
data: formData,
type: 'POST',
processData: false,
contentType: false,
});
location.href = location.href =
"{{ route('admin-notification.index') }}"; "{{ route('admin-notification.index') }}";
} }
@ -150,6 +157,8 @@
}); });
}); });
</script> </script>
@endsection
@section('content')
<div class="main-content"> <div class="main-content">
<section class="section"> <section class="section">
<div class="section-header"> <div class="section-header">

View File

@ -1,5 +1,5 @@
@extends('layouts.main') @extends('layouts.main')
@section('content') @section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let selected = {!! json_encode($email) !!}; let selected = {!! json_encode($email) !!};
@ -145,8 +145,8 @@
processData: false, processData: false,
contentType: false, contentType: false,
}); });
// location.href = location.href =
// "{{ route('admin-notification.index') }}"; "{{ route('admin-notification.index') }}";
} }
}); });
}, },
@ -170,6 +170,8 @@
}); });
</script> </script>
@endsection
@section('content')
<div class="main-content"> <div class="main-content">
<section class="section"> <section class="section">
<div class="section-header"> <div class="section-header">

View File

@ -1,5 +1,5 @@
@extends('layouts.main') @extends('layouts.main')
@section('content') @section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let listNotifikasi = $('#table-notifikasi').DataTable({ let listNotifikasi = $('#table-notifikasi').DataTable({
@ -67,6 +67,8 @@
}); });
}); });
</script> </script>
@endsection
@section('content')
<div class="main-content"> <div class="main-content">
<section class="section"> <section class="section">
<div class="section-header"> <div class="section-header">

View File

@ -1,5 +1,5 @@
@extends('layouts.main') @extends('layouts.main')
@section('content') @section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let listUser = $('#table-user').DataTable({ let listUser = $('#table-user').DataTable({
@ -65,6 +65,8 @@
}); });
}); });
</script> </script>
@endsection
@section('content')
<div class="main-content"> <div class="main-content">
<section class="section"> <section class="section">
<div class="section-header"> <div class="section-header">
@ -83,7 +85,7 @@
</div> </div>
<div class="d-flex justify-content-start mb-3"> <div class="d-flex justify-content-start mb-3">
{{ $notification->content }} {!! $notification->content !!}
</div> </div>
<div class="d-flex justify-content-center mt-5 mb-3"> <div class="d-flex justify-content-center mt-5 mb-3">

View File

@ -99,6 +99,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#accept').on('click', function() { $('#accept').on('click', function() {
@ -143,6 +145,14 @@
icon: response.status ? 'success' : 'error' icon: response.status ? 'success' : 'error'
}).then(function() { }).then(function() {
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('admin-notification.update-new-notification') }}",
data: {
receivers: response
.receivers,
},
type: 'GET',
});
location.reload(); location.reload();
} }
}); });
@ -181,11 +191,11 @@
if (result.isConfirmed) { if (result.isConfirmed) {
Swal.fire({ Swal.fire({
title: 'Tolak Refund?', title: 'Tolak Refund?',
text: 'Berikan alasan menolak refund ini' text: 'Berikan alasan menolak refund ini',
input: 'text', input: 'text',
inputPlaceholder: 'Cth. Bukti foto tidak sesuai', inputPlaceholder: 'Cth. Bukti foto tidak sesuai',
confirmButtonText: 'Kirim', confirmButtonText: 'Kirim',
showCancelButton: true showCancelButton: true,
cancelButtonText: 'Batal' cancelButtonText: 'Batal'
}).then((a) => { }).then((a) => {
if (a.isConfirmed) { if (a.isConfirmed) {
@ -213,6 +223,14 @@
'success' : 'error' 'success' : 'error'
}).then(function() { }).then(function() {
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('admin-notification.update-new-notification') }}",
data: {
receivers: response
.receivers,
},
type: 'GET',
});
location.reload(); location.reload();
} }
}); });

View File

@ -40,6 +40,9 @@
</section> </section>
</div> </div>
@include('admin.refund.modal-keterangan-status') @include('admin.refund.modal-keterangan-status')
@include('admin.transaction.modal-keterangan-status')
@endsection
@section('tambahan-js')
<script> <script>
$(function() { $(function() {
let listRefund = $('#table-refund').DataTable({ let listRefund = $('#table-refund').DataTable({
@ -147,5 +150,4 @@
}); });
}); });
</script> </script>
@extends('admin.transaction.modal-keterangan-status')
@endsection @endsection

View File

@ -97,6 +97,14 @@
</address> </address>
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-12">
<address>
<strong>Deskripsi:</strong><br>
{!! $transaction->deskripsi_transaksi !!}<br>
</address>
</div>
</div>
{{-- batas pembayaran dan pengiriman --}} {{-- batas pembayaran dan pengiriman --}}
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
@ -107,20 +115,8 @@
</div> </div>
<div class="col-md-6 text-md-right"> <div class="col-md-6 text-md-right">
<address> <address>
<strong>Estimasi Pengiriman:</strong><br> <strong>Batas Pengiriman:</strong><br>
{{ date('Y', strtotime($transaction->batas_pengiriman_barang_awal)) == {{ date('d F Y', strtotime($transaction->batas_pengiriman_barang_akhir)) }}<br>
date('Y', strtotime($transaction->batas_pengiriman_barang_akhir))
? (date('F', strtotime($transaction->batas_pengiriman_barang_awal)) ==
date('F', strtotime($transaction->batas_pengiriman_barang_akhir))
? date('d', strtotime($transaction->batas_pengiriman_barang_awal)) .
'-' .
date('d F Y', strtotime($transaction->batas_pengiriman_barang_akhir))
: date('F', strtotime($transaction->batas_pengiriman_barang_awal)) .
'-' .
date('d F Y', strtotime($transaction->batas_pengiriman_barang_akhir)))
: date('d F', strtotime($transaction->batas_pengiriman_barang_awal)) .
'-' .
date('d F Y', strtotime($transaction->batas_pengiriman_barang_akhir)) }}<br>
</address> </address>
</div> </div>
</div> </div>
@ -139,13 +135,12 @@
</address> </address>
</div> </div>
</div> </div>
{{-- Keterangan --}} {{-- Keterangan --}}
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<address> <address>
<strong>Status Indikasi Penipuan:</strong><br> <strong>Status Indikasi Penipuan:</strong><br>
{{ $transaction->fraud_status == null ? 'Tidak ada' : 'Ada' }} {{ $transaction->fraud_status == null ? 'Tidak ada' : ucwords($transaction->fraud_status) }}
</address> </address>
</div> </div>
<div class="col-md-6 text-md-right"> <div class="col-md-6 text-md-right">
@ -245,6 +240,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#acceptTransaction').on('click', function() { $('#acceptTransaction').on('click', function() {
@ -289,6 +286,14 @@
icon: response.status ? 'success' : 'error' icon: response.status ? 'success' : 'error'
}).then(function() { }).then(function() {
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('admin-notification.update-new-notification') }}",
data: {
receivers: response
.receivers
},
type: 'GET',
});
location.reload(); location.reload();
} }
}); });
@ -368,6 +373,14 @@
'success' : 'error' 'success' : 'error'
}).then(function() { }).then(function() {
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('admin-notification.update-new-notification') }}",
data: {
receivers: response
.receivers
},
type: 'GET',
});
location.reload(); location.reload();
} }
}); });

View File

@ -40,6 +40,8 @@
</div> </div>
@include('admin.transaction.modal-tracking') @include('admin.transaction.modal-tracking')
@include('admin.transaction.modal-keterangan-status') @include('admin.transaction.modal-keterangan-status')
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let listTransaction = $('#table-transaction').DataTable({ let listTransaction = $('#table-transaction').DataTable({

View File

@ -153,6 +153,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#tampilKTP').on('click', function() { $('#tampilKTP').on('click', function() {
@ -218,18 +220,18 @@
icon: response.status ? 'success' : 'error', icon: response.status ? 'success' : 'error',
confirmButtonText: 'OK' confirmButtonText: 'OK'
}).then(function() { }).then(function() {
if (response.status) {
location.reload(); location.reload();
}
}); });
}, },
error: function(error) { error: function(error) {
Swal.fire({ Swal.fire({
title: 'Gagal!', title: 'Gagal!',
text: 'Tidak ada data yang dihapus, karena ' + text: 'Terjadi Kesalahan di server',
error,
icon: 'error' icon: 'error'
}).then(function() {
location.reload();
}); });
console.log(error);
} }
}); });
} else { } else {
@ -298,16 +300,18 @@
'success' : 'error', 'success' : 'error',
confirmButtonText: 'OK' confirmButtonText: 'OK'
}).then(function() { }).then(function() {
if (response.status) {
location.reload(); location.reload();
}
}); });
}, },
error: function(error) { error: function(error) {
Swal.fire({ Swal.fire({
title: 'Gagal!', title: 'Gagal!',
text: 'Gagal mengubah status akun, karena ' + text: 'Terjadi Kesalahan di server',
error,
icon: 'info' icon: 'info'
}); });
console.log(error);
} }
}); });
} else { } else {

View File

@ -35,6 +35,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script> <script>
$(function() { $(function() {
let listUser = $('#table-user').DataTable({ let listUser = $('#table-user').DataTable({
@ -108,6 +110,54 @@
className: 'text-center' className: 'text-center'
}], }],
}); });
$('#table-user').on('click', '#deleteUser', function() {
const id = $(this).data('id');
const csrfToken = $('meta[name="csrf-token"]').attr('content');
Swal.fire({
html: '<div class="mt-3"><lord-icon src="https://cdn.lordicon.com/etwtznjn.json" trigger="loop" colors="primary:#0ab39c,secondary:#405189" style="width:120px;height:120px"></lord-icon><div class="mt-4 pt-2 fs-15"><h4>Form Anda sedang diproses!</h4><p class="text-muted mx-4 mb-0">Mohon tunggu...</p></div></div>',
allowEscapeKey: false,
allowOutsideClick: false,
didOpen: () => {
Swal.showLoading();
}
});
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': csrfToken
}
});
$.ajax({
url: "{{ route('admin-user.destroy') }}",
type: "DELETE",
data: {
id: id,
},
success: function(response) {
Swal.fire({
title: response.status ? 'Berhasil hapus akun' :
'Gagal hapus akun',
text: response.message,
icon: response.status ? 'success' : 'error'
}).then(function() {
if (response.status) {
listUser.ajax.reload();
}
});
},
error: function(error) {
Swal.fire({
title: 'Error',
text: 'Terjadi kesalahan di server',
icon: 'error'
});
console.log(error);
}
});
})
}); });
</script> </script>
@endsection @endsection

View File

@ -44,6 +44,8 @@
</div> </div>
@include('user.contact.modal-detail-contact') @include('user.contact.modal-detail-contact')
@include('user.contact.modal-add-contact') @include('user.contact.modal-add-contact')
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let check = false; let check = false;

View File

@ -1,79 +1,196 @@
@extends('layouts.main') @extends('layouts.main')
@section('css-tambahan')
<style>
.select2-container .select2-selection--single {
border: none;
background: none;
outline: none;
box-shadow: none;
padding: 0;
}
.select2-container .select2-selection--single:focus {
border: none;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
color: #900c3e;
line-height: 28px;
}
.select2-container .select2-selection--single .select2-selection__arrow {
border: none;
background: none;
}
.select2-container--default.select2-container--open .select2-selection--single {
border: none;
}
.select2-results {
border-bottom: 1px solid #aaa;
}
.select2-results__option {
padding: 10px;
color: #333;
background-color: white;
}
.select2-container--default .select2-results>.select2-results__options .select2-results__option--highlighted {
background-color: #900c3e !important;
color: #fff !important;
}
</style>
@endsection
@section('content') @section('content')
<!-- Main Content --> <!-- Main Content -->
<div class="main-content"> <div class="main-content">
<section class="section"> <section class="section">
<div class="row"> <div class="row">
<div class="col-lg-4 col-md-4 col-sm-12"> <div class="col-lg-4 col-md-12 col-sm-12">
<div class="card card-statistic-2"> <div class="card card-statistic-2">
<div class="card-stats"> <div class="card-stats">
<div class="card-stats-title">List Transaction - <div class="card-stats-title">
<div class="dropdown d-inline"> <h4>
<a class="font-weight-600 dropdown-toggle" data-toggle="dropdown" href="#" Transaksi - <select class="input" style="width: 40%;" name="filterRole" id="filterRole">
id="orders-month">August</a> <option value="1" selected>Semua</option>
<ul class="dropdown-menu dropdown-menu-sm" aria-labelledby="orders-month" <option value="2">Pembeli</option>
id="dropdownMenu1"> <option value="3">Penjual</option>
<li class="dropdown-title">Pilih Bulan</li> </select>
<li><a href="#" class="dropdown-item">Januari</a></li> </h4>
<li><a href="#" class="dropdown-item">Februari</a></li>
<li><a href="#" class="dropdown-item">Maret</a></li>
<li><a href="#" class="dropdown-item">April</a></li>
<li><a href="#" class="dropdown-item">May</a></li>
<li><a href="#" class="dropdown-item">Juni</a></li>
<li><a href="#" class="dropdown-item">Juli</a></li>
<li><a href="#" class="dropdown-item">Agustus</a></li>
<li><a href="#" class="dropdown-item">September</a></li>
<li><a href="#" class="dropdown-item">Oktober</a></li>
<li><a href="#" class="dropdown-item">November</a></li>
<li><a href="#" class="dropdown-item">Desember</a></li>
</ul>
</div> </div>
<div class="dropdown d-inline"> <div id="semua">
<a class="font-weight-600 dropdown-toggle" data-toggle="dropdown" href="#" <div class="card-stats-items">
id="orders-year">2023</a> <div class="card-stats-item">
<ul class="dropdown-menu dropdown-menu-sm" aria-labelledby="orders-year" <div class="card-stats-item-count" id="countAllFinished">{{ $countAllFinished }}
id="dropdownMenu2">
<li class="dropdown-title">Pilih Tahun</li>
<li><a href="#" class="dropdown-item">2019</a></li>
<li><a href="#" class="dropdown-item">2020</a></li>
<li><a href="#" class="dropdown-item">2021</a></li>
<li><a href="#" class="dropdown-item">2022</a></li>
<li><a href="#" class="dropdown-item">2023</a></li>
</ul>
</div> </div>
Sebagai - <div class="card-stats-item-label">Selesai</div>
<div class="dropdown d-inline"> </div>
<a class="font-weight-600 dropdown-toggle" data-toggle="dropdown" href="#" <div class="card-stats-item">
id="orders-role">Semua</a> <div class="card-stats-item-count" id="countAllPending">{{ $countAllPending }}</div>
<ul class="dropdown-menu dropdown-menu-sm" aria-labelledby="orders-role" <div class="card-stats-item-label">Menunggu</div>
id="dropdownMenu3"> </div>
<li class="dropdown-title">Pilih Peran</li> <div class="card-stats-item">
<li><a href="#" class="dropdown-item">Semua</a></li> <div class="card-stats-item-count" id="countAllProcessed">{{ $countAllProcessed }}
<li><a href="#" class="dropdown-item">Pembeli</a></li> </div>
<li><a href="#" class="dropdown-item">Penjual</a></li> <div class="card-stats-item-label">Diproses</div>
</ul>
</div> </div>
</div> </div>
<div class="card-stats-items"> <div class="card-stats-items">
<div class="card-stats-item"> <div class="card-stats-item">
<div class="card-stats-item-count">{{ $countCreated }}</div> <div class="card-stats-item-count" id="countAllCanceled">{{ $countAllCanceled }}
<div class="card-stats-item-label">Dibuat</div>
</div> </div>
<div class="card-stats-item">
<div class="card-stats-item-count">{{ $countPending }}</div>
<div class="card-stats-item-label">Pending</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count">{{ $countFailure }}</div>
<div class="card-stats-item-label">Gagal</div> <div class="card-stats-item-label">Gagal</div>
</div> </div>
<div class="card-stats-item"> <div class="card-stats-item">
<div class="card-stats-item-count">{{ $sumRefund }}</div> <div class="card-stats-item-count" id="countAllRefund">{{ $countAllRefund }}</div>
<div class="card-stats-item-label">Refund</div> <div class="card-stats-item-label">Refund</div>
</div> </div>
<div class="card-stats-item"> <div class="card-stats-item">
<div class="card-stats-item-count">{{ $sumTransaksi }}</div> <div class="card-stats-item-count" id="countAllIndicated">{{ $countAllIndicated }}
<div class="card-stats-item-label">Transaksi</div> </div>
<div class="card-stats-item-label">Tertunda</div>
</div>
</div>
</div>
<div id="pembeli" hidden>
<div class="card-stats-items mt-3">
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerFinished">{{ $countBuyerFinished }}
</div>
<div class="card-stats-item-label">Selesai</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerPaid">{{ $countBuyerPaid }}
</div>
<div class="card-stats-item-label">Dibayar</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerProcessed">
{{ $countBuyerProcessed }}
</div>
<div class="card-stats-item-label">Diproses</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerPending">{{ $countBuyerPending }}
</div>
<div class="card-stats-item-label">Menunggu</div>
</div>
</div>
<div class="card-stats-items">
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerCancelled">
{{ $countBuyerCancelled }}</div>
<div class="card-stats-item-label">Gagal</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerIndicated">
{{ $countBuyerIndicated }}
</div>
<div class="card-stats-item-label">Tertunda</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerRefundPending">
{{ $countBuyerRefundPending }}</div>
<div class="card-stats-item-label">Pengajuan Refund</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerRefundApproved">
{{ $countBuyerRefundApproved }}</div>
<div class="card-stats-item-label">Disetujui</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countBuyerRefundDenied">
{{ $countBuyerRefundDenied }}</div>
<div class="card-stats-item-label">Ditolak</div>
</div>
</div>
</div>
<div id="penjual" hidden>
<div class="card-stats-items mt-3">
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerFinished">
{{ $countSellerFinished }}</div>
<div class="card-stats-item-label">selesai</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerProcessed">
{{ $countSellerProcessed }}</div>
<div class="card-stats-item-label">Diproses</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerSending">
{{ $countSellerSending }}</div>
<div class="card-stats-item-label">Dikirim</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerSent">{{ $countSellerSent }}
</div>
<div class="card-stats-item-label">Sampai</div>
</div>
</div>
<div class="card-stats-items">
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerPending">
{{ $countSellerPending }}</div>
<div class="card-stats-item-label">Menunggu</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerCancelled">
{{ $countSellerCancelled }}</div>
<div class="card-stats-item-label">Gagal</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerRefund">
{{ $countSellerRefund }}</div>
<div class="card-stats-item-label">Refund</div>
</div>
<div class="card-stats-item">
<div class="card-stats-item-count" id="countSellerIndicated">
{{ $countSellerIndicated }}</div>
<div class="card-stats-item-label">Tertunda</div>
</div>
</div> </div>
</div> </div>
@ -85,16 +202,23 @@
<div class="card-header"> <div class="card-header">
<h4>Jumlah Transaction</h4> <h4>Jumlah Transaction</h4>
</div> </div>
<div class="card-body"> <div class="card-body" id="totalTransaction">
{{ $totalTransaction }} {{ $totalTransaction }} Transaksi
</div> </div>
</div> </div>
<p class="mb-0 text-muted" id="rateTransaction">
<span
class="text-{{ $rateTransaction == 0 ? 'secondary text-black-50' : ($rateTransaction > 0 ? 'success' : 'danger') }} me-2"><span
class="mdi {{ $rateTransaction == 0 ? 'mdi-equal' : ($rateTransaction > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ abs($rateTransaction) }}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
</p>
</div> </div>
</div> </div>
<div class="col-lg-4 col-md-4 col-sm-12"> <div class="col-lg-4 col-md-12 col-sm-12">
<div class="card card-statistic-2"> <div class="card card-statistic-2">
<div class="card-chart"> <div class="card-chart">
<canvas id="balance-chart" height="80"></canvas> <canvas id="pemasukan-chart" height="100"></canvas>
</div> </div>
<div class="card-icon shadow-primary bg-primary"> <div class="card-icon shadow-primary bg-primary">
<i class="fas fa-dollar-sign"></i> <i class="fas fa-dollar-sign"></i>
@ -103,16 +227,23 @@
<div class="card-header"> <div class="card-header">
<h4>Pemasukan</h4> <h4>Pemasukan</h4>
</div> </div>
<div class="card-body"> <div class="card-body" id="totalPemasukan">
Rp. {{ number_format($totalIncome, 2) }} Rp {{ number_format($totalPemasukan, 2, ',', '.') }}
</div> </div>
</div> </div>
<p class="mb-0 text-muted" id="ratePemasukan">
<span
class="text-{{ $ratePemasukan == 0 ? 'secondary text-black-50' : ($ratePemasukan > 0 ? 'success' : 'danger') }} me-2"><span
class="mdi {{ $ratePemasukan == 0 ? 'mdi-equal' : ($ratePemasukan > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ abs($ratePemasukan) }}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
</p>
</div> </div>
</div> </div>
<div class="col-lg-4 col-md-4 col-sm-12"> <div class="col-lg-4 col-md-12 col-sm-12">
<div class="card card-statistic-2"> <div class="card card-statistic-2">
<div class="card-chart"> <div class="card-chart">
<canvas id="sales-chart" height="80"></canvas> <canvas id="pengeluaran-chart" height="100"></canvas>
</div> </div>
<div class="card-icon shadow-primary bg-primary"> <div class="card-icon shadow-primary bg-primary">
<i class="fas fa-shopping-bag"></i> <i class="fas fa-shopping-bag"></i>
@ -121,35 +252,62 @@
<div class="card-header"> <div class="card-header">
<h4>Pengeluaran</h4> <h4>Pengeluaran</h4>
</div> </div>
<div class="card-body">Rp. {{ number_format($totalExpense, 2) }}</div> <div class="card-body" id="totalPengeluaran">Rp
{{ number_format($totalPengeluaran, 2, ',', '.') }}
</div> </div>
</div> </div>
<p class="mb-0 text-muted" id="ratePengeluaran">
<span
class="text-{{ $ratePengeluaran == 0 ? 'secondary text-black-50' : ($ratePengeluaran > 0 ? 'success' : 'danger') }} me-2"><span
class="mdi {{ $ratePengeluaran == 0 ? 'mdi-equal' : ($ratePengeluaran > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ abs($ratePengeluaran) }}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
</p>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="input-group">
<input type="text" name="from-to" class="form-control" id="date-range">
<span class="input-group-text bg-primary text-white align-items-center">
<i class="mdi mdi-calendar-range font-13"></i>
</span>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="card"> <div class="card">
<div class="alert alert-primary alert-dismissible fade show mb-3" role="alert"> <div id="rateProfit">
Pendapatan Hari Ini meningkat <span class="mdi mdi-arrow-up-bold"></span> <div class="alert alert-{{ $rateProfit == 0 ? 'secondary text-black-50' : ($rateProfit > 0 ? 'success' : 'error') }} alert-dismissible fade show mb-3"
5.27%</span> role="alert">
Transaksi {{ $rateProfit == 0 ? 'sama' : ($rateProfit > 0 ? 'meningkat' : 'menurun') }}
<span
class="mdi {{ $rateProfit == 0 ? 'mdi-equal' : ($rateProfit > 0 ? 'mdi-arrow-up-bold' : 'mdi-arrow-down-bold') }}"></span>
{{ $rateProfit }}%
</div>
</div> </div>
<div class="card-header"> <div class="card-header">
<h4 style="font-size: 36px;">Transaksi</h4> <h4>Transaksi</h4>
<div class="card-header-action">
<div class="btn-group">
<a href="#" class="btn btn-primary">Week</a>
<a href="#" class="btn">Month</a>
</div>
</div>
</div> </div>
<div class="card-body"> <div class="card-body">
<canvas id="myChart" height="150"></canvas> <canvas id="myChart" height="120"></canvas>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script>
let dataLabel = {!! json_encode($dataLabel) !!}
let dataChartTransaction = {{ json_encode($dataChartTransaction) }}
let dataChartRefund = {{ json_encode($dataChartRefund) }}
let dataChartPemasukan = {{ json_encode($dataChartPemasukan) }}
let dataChartPengeluaran = {{ json_encode($dataChartPengeluaran) }}
</script>
<script> <script>
// Set new default font family and font color to mimic Bootstrap's default styling // Set new default font family and font color to mimic Bootstrap's default styling
Chart.defaults.global.defaultFontFamily = 'Nunito', Chart.defaults.global.defaultFontFamily = 'Nunito',
@ -157,15 +315,13 @@
Chart.defaults.global.defaultFontColor = '#858796'; Chart.defaults.global.defaultFontColor = '#858796';
var ctx = document.getElementById("myChart").getContext('2d'); var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, { var myChartTransaksi = new Chart(ctx, {
type: 'line', type: 'line',
data: { data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Agu", "Sep", labels: dataLabel,
"Okt", "Nov", "Des"
],
datasets: [{ datasets: [{
label: 'Transaksi', label: 'Transaksi',
data: [3200, 18009, 4305, 3022, 6310, 5120, 5880, 6154, 0], data: dataChartTransaction,
borderWidth: 2, borderWidth: 2,
backgroundColor: 'rgba(63,82,227,.8)', backgroundColor: 'rgba(63,82,227,.8)',
borderWidth: 0, borderWidth: 0,
@ -177,7 +333,7 @@
}, },
{ {
label: 'Refund', label: 'Refund',
data: [2207, 3403, 2200, 5025, 2302, 4208, 3880, 4880, 5000], data: dataChartRefund,
borderWidth: 2, borderWidth: 2,
backgroundColor: 'rgba(254,86,83,.7)', backgroundColor: 'rgba(254,86,83,.7)',
borderWidth: 0, borderWidth: 0,
@ -209,19 +365,12 @@
}, },
ticks: { ticks: {
beginAtZero: true, beginAtZero: true,
stepSize: 15000,
callback: function(value, index, values) {
// return 'Rp.' + value;
return new Intl.NumberFormat('id-ID', {
style: 'currency',
currency: 'IDR',
}).format(value);
},
fontSize: 14, fontSize: 14,
maxTicksLimit: 6,
}, },
scaleLabel: { scaleLabel: {
display: true, display: true,
labelString: 'Dalam Ratusan Juta', // Label khusus untuk sumbu Y labelString: 'Dalam Rupiah (Rp)', // Label khusus untuk sumbu Y
fontSize: 16 // Ukuran font untuk label sumbu Y fontSize: 16 // Ukuran font untuk label sumbu Y
}, },
}], }],
@ -231,30 +380,32 @@
tickMarkLength: 15, tickMarkLength: 15,
}, },
ticks: { ticks: {
fontSize: 16, display: false,
} maxTicksLimit: 8,
},
offset: true,
}] }]
}, },
} }
}); });
var balance_chart = document.getElementById("balance-chart").getContext('2d'); var pemasukan_chart = document.getElementById("pemasukan-chart").getContext('2d');
var balance_chart_bg_color = balance_chart.createLinearGradient(0, 0, 0, 70); var pemasukan_chart_bg_color = pemasukan_chart.createLinearGradient(0, 0, 0, 70);
balance_chart_bg_color.addColorStop(0, 'rgba(63,82,227,.2)');
balance_chart_bg_color.addColorStop(1, 'rgba(63,82,227,0)');
var myChart = new Chart(balance_chart, { pemasukan_chart_bg_color.addColorStop(0, 'rgba(63,82,227,.2)');
pemasukan_chart_bg_color.addColorStop(1, 'rgba(63,82,227,0)');
var myChartPemasukan = new Chart(
pemasukan_chart, {
type: 'line', type: 'line',
data: { data: {
labels: ['16-07-2018', '17-07-2018', '18-07-2018', '19-07-2018', '20-07-2018', '21-07-2018', labels: dataLabel,
'22-07-2018', '23-07-2018', '24-07-2018', '25-07-2018', '26-07-2018', '27-07-2018',
'28-07-2018', '29-07-2018', '30-07-2018', '31-07-2018'
],
datasets: [{ datasets: [{
label: 'Balance', label: 'Pemasukan',
data: [50, 61, 80, 50, 72, 52, 60, 41, 30, 45, 70, 40, 93, 63, 50, 62], data: dataChartPemasukan,
backgroundColor: balance_chart_bg_color, backgroundColor: pemasukan_chart_bg_color,
borderWidth: 3, borderWidth: 3,
borderColor: 'rgba(63,82,227,1)', borderColor: 'rgba(63,82,227,1)',
pointBorderWidth: 0, pointBorderWidth: 0,
@ -266,10 +417,7 @@
}, },
options: { options: {
layout: { layout: {
padding: { padding: 10
bottom: -1,
left: -1
}
}, },
legend: { legend: {
display: false display: false
@ -282,40 +430,41 @@
}, },
ticks: { ticks: {
beginAtZero: true, beginAtZero: true,
display: false display: false,
maxTicksLimit: 4,
} }
}], }],
xAxes: [{ xAxes: [{
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
display: false, display: true,
}, },
ticks: { ticks: {
display: false display: false,
} maxTicksLimit: 8,
},
offset: true,
}] }]
}, },
} }
}); });
var sales_chart = document.getElementById("sales-chart").getContext('2d'); var pengeluaran = document.getElementById("pengeluaran-chart");
var pengeluaran_chart = pengeluaran.getContext('2d');
var sales_chart_bg_color = sales_chart.createLinearGradient(0, 0, 0, 80); var pengeluaran_chart_bg_color = pengeluaran_chart.createLinearGradient(0, 0, 0, 80);
balance_chart_bg_color.addColorStop(0, 'rgba(63,82,227,.2)'); pengeluaran_chart_bg_color.addColorStop(0, 'rgba(63,82,227,.2)');
balance_chart_bg_color.addColorStop(1, 'rgba(63,82,227,0)'); pengeluaran_chart_bg_color.addColorStop(1, 'rgba(63,82,227,0)');
var myChart = new Chart(sales_chart, { var myChartPengeluaran = new Chart(pengeluaran_chart, {
type: 'line', type: 'line',
data: { data: {
labels: ['16-07-2018', '17-07-2018', '18-07-2018', '19-07-2018', '20-07-2018', '21-07-2018', labels: dataLabel,
'22-07-2018', '23-07-2018', '24-07-2018', '25-07-2018', '26-07-2018', '27-07-2018',
'28-07-2018', '29-07-2018', '30-07-2018', '31-07-2018'
],
datasets: [{ datasets: [{
label: 'Sales', label: 'Pengeluaran',
data: [70, 62, 44, 40, 21, 63, 82, 52, 50, 31, 70, 50, 91, 63, 51, 60], data: dataChartPengeluaran,
borderWidth: 2, borderWidth: 2,
backgroundColor: balance_chart_bg_color, backgroundColor: pengeluaran_chart_bg_color,
borderWidth: 3, borderWidth: 3,
borderColor: 'rgba(63,82,227,1)', borderColor: 'rgba(63,82,227,1)',
pointBorderWidth: 0, pointBorderWidth: 0,
@ -327,10 +476,7 @@
}, },
options: { options: {
layout: { layout: {
padding: { padding: 10
bottom: -1,
left: -1
}
}, },
legend: { legend: {
display: false display: false
@ -343,20 +489,244 @@
}, },
ticks: { ticks: {
beginAtZero: true, beginAtZero: true,
display: false display: false,
maxTicksLimit: 4,
} }
}], }],
xAxes: [{ xAxes: [{
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
display: false, display: true,
}, },
ticks: { ticks: {
display: false display: false,
} maxTicksLimit: 8,
},
offset: true,
}] }]
}, },
} }
}); });
</script> </script>
<script>
$(document).ready(function() {
const csrfToken = $('meta[name="csrf-token"]').attr('content');
let searchParams = new URLSearchParams(window.location.search);
let dateInterval = searchParams.get('from-to');
let start = moment().subtract(29, 'days');
let end = moment();
$('#filterRole').select2();
$('#filterRole').change(function() {
let id = $(this).val();
if (id == "1") {
$('#semua').removeAttr('hidden');
$('#pembeli').attr('hidden', true);
$('#penjual').attr('hidden', true);
} else if (id == "2") {
$('#semua').attr('hidden', true);
$('#pembeli').removeAttr('hidden');
$('#penjual').attr('hidden', true);
} else {
$('#semua').attr('hidden', true);
$('#pembeli').attr('hidden', true);
$('#penjual').removeAttr('hidden');
}
});
if (dateInterval) {
dateInterval = dateInterval.split(' - ');
start = moment(dateInterval[0]);
end = moment(dateInterval[1]);
}
$('#date-range').daterangepicker({
"showDropdowns": true,
"showWeekNumbers": true,
"alwaysShowCalendars": true,
startDate: start,
endDate: end,
locale: {
format: 'YYYY-MM-DD',
firstDay: 1,
},
minDate: "2023-01-01",
maxDate: "2025-12-31",
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1,
'month').endOf(
'month')],
'This Year': [moment().startOf('year'), moment().endOf('year')],
'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year')
.endOf(
'year')
]
}
}).on('apply.daterangepicker', function(ev, picker) {
var startDate = picker.startDate.format('YYYY-MM-DD');
var endDate = picker.endDate.format('YYYY-MM-DD');
Swal.fire({
html: '<div class="mt-3"><lord-icon src="https://cdn.lordicon.com/etwtznjn.json" trigger="loop" colors="primary:#0ab39c,secondary:#405189" style="width:120px;height:120px"></lord-icon><div class="mt-4 pt-2 fs-15"><h4>Form Anda sedang diproses!</h4><p class="text-muted mx-4 mb-0">Mohon tunggu...</p></div></div>',
allowEscapeKey: false,
allowOutsideClick: false,
didOpen: () => {
Swal.showLoading();
}
});
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': csrfToken
}
});
$.ajax({
url: "{{ route('user.get-data-dashboard') }}",
type: 'GET',
data: {
startDate: startDate,
endDate: endDate
},
success: function(response) {
Swal.close();
myChartTransaksi.data.datasets[0].data = response.dataChartTransaction;
myChartTransaksi.data.datasets[1].data = response.dataChartRefund;
myChartTransaksi.data.labels = response.dataLabel;
myChartTransaksi.update();
myChartPemasukan.data.datasets[0].data = response.dataChartUser;
myChartPemasukan.data.labels = response.dataLabel;
myChartPemasukan.update();
myChartPengeluaran.data.datasets[0].data = response.dataChartUser;
myChartPengeluaran.data.labels = response.dataLabel;
myChartPengeluaran.update();
// Semua
$('#countAllFinished').html(response.countAllFinished);
$('#countAllPending').html(response.countAllPending);
$('#countAllProcessed').html(response.countAllProcessed);
$('#countAllCanceled').html(response.countAllCanceled);
$('#countAllRefund').html(response.countAllRefund);
$('#countAllIndicated').html(response.countAllIndicated);
// Pembeli
$('#countBuyerFinished').html(response.countBuyerFinished);
$('#countBuyerPaid').html(response.countBuyerPaid);
$('#countBuyerPending').html(response.countBuyerPending);
$('#countBuyerProcessed').html(response.countBuyerProcessed);
$('#countBuyerCancelled').html(response.countBuyerCancelled);
$('#countBuyerRefundPending').html(response.countBuyerRefundPending);
$('#countBuyerRefundApproved').html(response.countBuyerRefundApproved);
$('#countBuyerRefundDenied').html(response.countBuyerRefundDenied);
$('#countBuyerIndicated').html(response.countBuyerIndicated);
// Penjual
$('#countSellerPending').html(response.countSellerPending);
$('#countSellerFinished').html(response.countSellerFinished);
$('#countSellerProcessed').html(response.countSellerProcessed);
$('#countSellerSending').html(response.countSellerSending);
$('#countSellerSent').html(response.countSellerSent);
$('#countSellerCancelled').html(response.countSellerCancelled);
$('#countSellerRefund').html(response.countSellerRefund);
$('#countSellerIndicated').html(response.countSellerIndicated);
$('#totalTransaction').html(response.totalTransaction);
var activitiesRateTransaction = '';
var rateTransactionClass = response.rateTransaction == 0 ?
"secondary text-black-50" : (response.rateTransaction > 0 ?
"success" : "danger");
var rateTransactionClassIcon = response.rateTransaction == 0 ?
"mdi-equal" : (response.rateTransaction > 0 ?
"mdi-arrow-up-bold" : "mdi-arrow-down-bold");
activitiesRateTransaction = `
<span class="text-${rateTransactionClass} me-2"><span
class="mdi ${rateTransactionClassIcon}"></span>
${Math.abs(response.rateTransaction)}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
`;
$('#rateTransaction').html(activitiesRateTransaction);
// Pemasukan
$('#totalPemasukan').html(response.totalPemasukan);
var activitiesratePemasukan = '';
var ratePemasukanClass = response.ratePemasukan == 0 ?
"secondary text-black-50" : (response.ratePemasukan > 0 ?
"success" : "danger");
var ratePemasukanClassIcon = response.ratePemasukan == 0 ?
"mdi-equal" : (response.ratePemasukan > 0 ?
"mdi-arrow-up-bold" : "mdi-arrow-down-bold");
activitiesratePemasukan = `
<span class="text-${ratePemasukanClass} me-2"><span
class="mdi ${ratePemasukanClassIcon}"></span>
${Math.abs(response.ratePemasukan)}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
`;
$('#ratePemasukan').html(activitiesratePemasukan);
// Pengeluaran
$('#totalPengeluaran').html(response.totalPengeluaran);
var activitiesRatePengeluaran = '';
var ratePengeluaranClass = response.ratePengeluaran == 0 ?
"secondary text-black-50" : (response.ratePengeluaran > 0 ?
"success" : "danger");
var ratePengeluaranClassIcon = response.ratePengeluaran == 0 ?
"mdi-equal" : (response.ratePengeluaran > 0 ?
"mdi-arrow-up-bold" : "mdi-arrow-down-bold");
activitiesRatePengeluaran = `
<span class="text-${ratePengeluaranClass} me-2"><span
class="mdi ${ratePengeluaranClassIcon}"></span>
${Math.abs(response.ratePengeluaran)}%</span>
<span class="text-nowrap">Dibandingkan sebelumnya</span>
`;
$('#ratePengeluaran').html(activitiesRatePengeluaran);
// Profit
var activitiesRateProfit = '';
var rateProfitClass = response.rateProfit == 0 ?
"secondary text-black-50" : (response.rateProfit > 0 ?
"success" : "danger");
var rateProfitMention = response.rateProfit == 0 ? "sama" : (response
.rateProfit > 0 ? "meningkat" : "menurun");
var rateProfitClassIcon = response.rateProfit == 0 ?
"sama" : (response.rateProfit > 0 ?
"meningkat" : "menurun");
activitiesRateProfit = `
<div class="alert alert-${rateProfitClass} alert-dismissible fade show mb-3"
role="alert">
Pendapatan ${rateProfitMention}
<span
class="mdi ${rateProfitClassIcon}"></span>
${Math.abs(response.rateProfit)}%
</div>
`;
$('#rateProfit').html(activitiesRateProfit);
},
error: function(error) {
Swal.close();
console.log(error);
}
});
});
});
</script>
@endsection @endsection

View File

@ -18,7 +18,7 @@
</div> </div>
<div class="d-flex justify-content-start mb-3"> <div class="d-flex justify-content-start mb-3">
{{ $notification->content }} {!! $notification->content !!}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,12 +1,5 @@
@extends('layouts.main') @extends('layouts.main')
@section('content') @section('tambahan-js')
<style>
.unread {
background-color: #a3194e;
font-weight: bold;
color: #ffffff;
}
</style>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let listUser = $('#table-notifikasi').DataTable({ let listUser = $('#table-notifikasi').DataTable({
@ -62,6 +55,14 @@
}); });
}); });
</script> </script>
@endsection
@section('content')
<style>
.unread {
font-weight: bold;
color: #000000;
}
</style>
<div class="main-content"> <div class="main-content">
<section class="section"> <section class="section">
<div class="section-header"> <div class="section-header">

View File

@ -42,6 +42,8 @@
</section> </section>
</div> </div>
@include('user.refund.modal-keterangan-status') @include('user.refund.modal-keterangan-status')
@endsection
@section('tambahan-js')
<script> <script>
$(function() { $(function() {
let listRefund = $('#table-refund').DataTable({ let listRefund = $('#table-refund').DataTable({

View File

@ -1,56 +0,0 @@
<div class="modal fade" id="awaldetailrefund" role="dialog">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
</div>
<div class="d-flex justify-content-center">
<h4 class="modal-title" id="myModalLabel">Detail Refund</h4>
</div>
<div class="modal-body">
<p class="statusMsg"></p>
<div class="card-body">
<div class="form-group">
<label for="inputOrderId">Order ID</label>
<p class="form-control-static" id="orderid">1452667</p>
</div>
<div class="form-group">
<label for="inputCustomer">Customer</label>
<p class="form-control-static" id="customer">Nurul Prima</p>
</div>
<div class="form-group">
<label for="inputEmail">Email Customer</label>
<p class="form-control-static" id="inputEmail">npannisa@gmail.com</p>
</div>
<div class="form-group">
<label for="inputSeller">Seller Name</label>
<p class="form-control-static" id="sellername">Zakiaa</p>
</div>
<div class="form-group">
<label for="inputDueDate">Due Date</label>
<p class="form-control-static" id="duedate">29 Januari 2002</p>
</div>
<div class="form-group">
<label for="inputComplaint">Reason Complaint</label>
<p class="form-control-static" id="reasoncomplaint">Pengembalian product dikarenakan tidak
sesuai dengan aslinya</p>
</div>
<div class="form-group">
<label for="inputBukti">Bukti</label>
<p class="form-control-static" id="inputbukti"></p>
<img class="mr-3 rounded" width="200" src="assets/img/avatar/rusak.jpeg">
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -51,7 +51,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#formPengajuan').on('submit', function(e) { $('#formPengajuan').on('submit', function(e) {
@ -95,6 +96,14 @@
icon: response.status ? 'success' : 'error', icon: response.status ? 'success' : 'error',
}).then(function() { }).then(function() {
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('user-notification.update-notification-to-admin') }}",
type: 'GET',
data: {
service: response
.service,
}
});
location.href = location.href =
"{{ route('user-refund.index') }}"; "{{ route('user-refund.index') }}";
} }

View File

@ -8,6 +8,9 @@
<div class="d-flex justify-content-center"> <div class="d-flex justify-content-center">
<h2 class="mb-4"> Informasi Pesanan</h2> <h2 class="mb-4"> Informasi Pesanan</h2>
</div> </div>
<div class="d-flex justify-content-center">
<p>#{{ $transaction->id }}</p>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -98,6 +101,58 @@
</address> </address>
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-12">
<address>
<strong>Deskripsi:</strong><br>
{!! $transaction->deskripsi_transaksi !!}<br>
</address>
</div>
</div>
<div class="row">
<div class="col-md-6">
<address>
<strong>Batas Pembayaran:</strong><br>
{{ date('d F Y', strtotime($transaction->batas_pembayaran)) }}<br>
</address>
</div>
<div class="col-md-6 text-md-right">
<address>
<strong>Batas Pengiriman:</strong><br>
{{ date('d F Y', strtotime($transaction->batas_pengiriman_barang_akhir)) }}<br>
</address>
</div>
</div>
<div class="row">
<div class="col-md-6">
<address>
<strong>Status Transaksi:</strong><br>
{{ ucwords($transaction->status_transaksi) }}
</address>
</div>
<div class="col-md-6 text-md-right">
<address>
<strong>Status Pembayaran:</strong><br>
{{ ucwords($transaction->status_pembayaran) }}
</address>
</div>
</div>
@if ($transaction->fraud_status != null)
<div class="row">
<div class="col-md-6">
<address>
<strong>Status Indikasi Penipuan:</strong><br>
{{ $transaction->fraud_status == null ? 'Tidak ada' : ucwords($transaction->fraud_status) }}
</address>
</div>
<div class="col-md-6 text-md-right">
<address>
<strong>Keterangan:</strong><br>
{{ $transaction->keterangan }}
</address>
</div>
</div>
@endif
</div> </div>
</div> </div>
@ -119,11 +174,11 @@
<td>1</td> <td>1</td>
<td>{{ $transaction->nama_barang }}</td> <td>{{ $transaction->nama_barang }}</td>
<td class="text-center"> <td class="text-center">
Rp.{{ number_format($transaction->harga_barang, 2, ',', '.') }} Rp {{ number_format($transaction->harga_barang, 2, ',', '.') }}
</td> </td>
<td class="text-center">{{ $transaction->jumlah_barang }}</td> <td class="text-center">{{ $transaction->jumlah_barang }}</td>
<td class="text-right"> <td class="text-right">
Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }} Rp {{ number_format($transaction->total_harga, 2, ',', '.') }}
</td> </td>
</tr> </tr>
</table> </table>
@ -142,21 +197,22 @@
<div class="col-lg-4 text-right"> <div class="col-lg-4 text-right">
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Subtotal</div> <div class="invoice-detail-name">Subtotal</div>
<div class="invoice-detail-value">Rp <div class="invoice-detail-value">
Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }} Rp {{ number_format($transaction->total_harga, 2, ',', '.') }}
</div> </div>
</div> </div>
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Biaya Admin</div> <div class="invoice-detail-name">Biaya Admin</div>
<div class="invoice-detail-value"> <div class="invoice-detail-value">
Rp.{{ number_format($transaction->total_keuntungan, 2, ',', '.') }} Rp
{{ number_format($transaction->total_keuntungan, 2, ',', '.') }}
</div> </div>
</div> </div>
<hr class="mt-2 mb-2"> <hr class="mt-2 mb-2">
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Total</div> <div class="invoice-detail-name">Total</div>
<div class="invoice-detail-value invoice-detail-value-lg"> <div class="invoice-detail-value invoice-detail-value-lg">
Rp.{{ number_format($transaction->total_bayar, 2, ',', '.') }} Rp {{ number_format($transaction->total_bayar, 2, ',', '.') }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -59,7 +59,9 @@
@include('user.transaction.pembeli.modal-end-transaction') @include('user.transaction.pembeli.modal-end-transaction')
@include('user.transaction.pembeli.modal-tracking') @include('user.transaction.pembeli.modal-tracking')
@include('user.transaction.pembeli.modal-keterangan-status') @include('user.transaction.pembeli.modal-keterangan-status')
@endsection
@section('tambahan-js')
<script type="text/javascript" src="https://app.sandbox.midtrans.com/snap/snap.js" <script type="text/javascript" src="https://app.sandbox.midtrans.com/snap/snap.js"
data-client-key="SB-Mid-client-lEMALcmIPviksRRe"></script> data-client-key="SB-Mid-client-lEMALcmIPviksRRe"></script>
<script> <script>
@ -203,6 +205,14 @@
'error' 'error'
}).then(function() { }).then(function() {
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('user-notification.update-new-notification') }}",
type: 'GET',
data: {
receiver: response
.receiver,
}
});
listPembeli.ajax.reload(); listPembeli.ajax.reload();
} }
}); });
@ -469,6 +479,14 @@
}).then(function() { }).then(function() {
Swal.close(); Swal.close();
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('user-notification.update-new-notification') }}",
type: 'GET',
data: {
receiver: response
.receiver
}
});
listPembeli.ajax listPembeli.ajax
.reload(); .reload();
} }
@ -624,6 +642,13 @@
icon: response.status ? 'success' : 'error', icon: response.status ? 'success' : 'error',
}).then(function() { }).then(function() {
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('user-notification.update-new-notification') }}",
type: 'GET',
data: {
receiver: response.receiver,
}
});
location.reload(); location.reload();
} }
}); });

View File

@ -14,20 +14,25 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="activities"> <div class="activities">
<p>asdasdasdsad</p> <p style="text-align: justify;">
Silahkan konfirmasi barang anda sebelum menyelesaikan
transaksi atau mengajukan
refund. Harap diminta kesadaran penuh anda sebelum memilih selesaikan transaksi atau
ajukan
komplain.</p>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row m-4">
<div class="col-12"> <div class="col-12">
<div class="activities"> <div class="activities">
<div class="col-6 d-flex justify-content-center"> <div class="col-6 d-flex justify-content-center">
<img src="{{ asset('assets/img/avatar/avatar-1.png') }}" <img src="{{ asset('assets/img/modal-end/approve.png') }}" style="width:100%;"
style="max-width:200px; max-height: 150px;" alt=""> alt="approve">
</div> </div>
<div class="col-6 d-flex justify-content-center"> <div class="col-6 d-flex justify-content-center">
<img src="{{ asset('assets/img/avatar/avatar-1.png') }}" <img src="{{ asset('assets/img/modal-end/refund.png') }}" style="width:100%;"
style="max-width:200px; max-height: 150px;" alt=""> alt="refund">
</div> </div>
</div> </div>
</div> </div>

View File

@ -9,16 +9,18 @@
<div class="card-body"> <div class="card-body">
<div class="card" <div class="card"
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);"> 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);">
<form action="javascript:void(0);" method="POST" id="formTambahTransaksi"
enctype="multipart/form-data">
<div class="card-header d-flex justify-content-center"> <div class="card-header d-flex justify-content-center">
<h2>Form Transaksi</h2> <h2>Form Transaksi</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="inputpembeli"> <label for="inputPembeli">
<h5>Nama Pembeli</h5> <h5>Nama Pembeli</h5>
</label> </label>
<input type="email" class="form-control" id="inputpembeli" <input type="email" class="form-control" id="inputPembeli" name="pembeli"
placeholder="Masukkan nama pembeli" placeholder="Masukkan nama pembeli"
value="{{ Auth::user()->nama_depan . ' ' . Auth::user()->nama_belakang }}" value="{{ Auth::user()->nama_depan . ' ' . Auth::user()->nama_belakang }}"
disabled> disabled>
@ -31,11 +33,12 @@
</label> </label>
<h6>Pilih dari kontak</h6> <h6>Pilih dari kontak</h6>
<div class="input-group"> <div class="input-group">
<select class="form-control" id="selectContact" name="select_penjual" <select class="form-control col-lg-10 col-md-10 col-sm-12"
style="width: 89%"> id="selectContact" name="select_penjual">
</select> </select>
<button class="btn btn-danger" type="button" id="deleteOption">Hapus</button> <button class="btn btn-danger col-md-2 col-md-2 col-sm-12" type="button"
id="deleteOption">Hapus</button>
</div> </div>
</div> </div>
@ -67,15 +70,15 @@
<label for="hargaBarang"> <label for="hargaBarang">
<h5>Satuan</h5> <h5>Satuan</h5>
</label> </label>
<input type="text" class="form-control" name="satuan_barang" id="satuanBarang" <input type="text" class="form-control" name="satuan_barang"
placeholder="Buah/Kg/Karung/Jutaan dll."> id="satuanBarang" placeholder="Buah/Kg/Karung/Jutaan dll.">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="jumlahBarang"> <label for="jumlahBarang">
<h5>Jumlah Satuan</h5> <h5>Jumlah Satuan</h5>
</label> </label>
<input type="text" class="form-control" name="jumlah_barang" id="jumlahBarang" <input type="text" class="form-control" name="jumlah_barang"
placeholder="Jumlah satuan" id="jumlahBarang" placeholder="Jumlah satuan"
oninput="this.value = this.value.replace(/[^0-9.]/g, '').substring(0, 10);"> oninput="this.value = this.value.replace(/[^0-9.]/g, '').substring(0, 10);">
</div> </div>
@ -88,30 +91,39 @@
<div class="dashed-line"></div> <div class="dashed-line"></div>
<div class="form-row">
<label style="margin-right: 200px;" id="jumlah">Nominal</label>
<div style="display: inline-block;" id="totalBiaya">Rp 0,00</div>
</div>
<div class="form-row"> <div class="form-group">
<label style="margin-right: 200px;" id="biayaAdmin" data-admin="">Biaya Admin <div class="input-group">
<label class="col-6" id="jumlah">Nominal</label>
<div class="col-6 text-right" id="totalBiaya">
Rp 0,00
</div>
</div>
</div>
<div class="form-group">
<div class="input-group">
<label class="col-6" id="biayaAdmin">Biaya Admin
({{ $persentase_keuntungan }}%)</label> ({{ $persentase_keuntungan }}%)</label>
<div style="display: inline-block;" id="totalBiayaAdmin">Rp 0,00</div> <div class="col-6 text-right" id="totalBiayaAdmin">Rp 0,00</div>
</div>
</div> </div>
<div class="form-row"> <div class="form-group">
<h6 style="margin-right: 200px;">Total Biaya</h6> <div class="input-group">
<div style="display: inline-block;"> <h6 class="col-6">Total Biaya</h6>
<div class="col-6 text-right">
<h6 id="totalBayar">Rp 0,00</h6> <h6 id="totalBayar">Rp 0,00</h6>
</div> </div>
</div> </div>
</div>
<div class="dashed-line"></div> <div class="dashed-line"></div>
<div class="card-footer d-flex justify-content-center"> <div class="card-footer d-flex justify-content-center">
<button type="button" class="btn btn-primary" id="save">Buat</button> <button type="submit" class="btn btn-primary" id="save">Buat</button>
</div> </div>
</div> </div>
</form>
</div> </div>
</div> </div>
</div> </div>
@ -119,6 +131,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script> <script>
var persentaseKeuntungan = {{ $persentase_keuntungan }}; var persentaseKeuntungan = {{ $persentase_keuntungan }};
@ -260,18 +274,18 @@
}); });
$.ajax({ $.ajax({
url: "{{ route('user-contact.email', ':email') }}".replace( url: "{{ route('user-contact.email') }}",
":email", data: {
email email: email
), },
type: "GET", type: "GET",
success: function(response) { success: function(response) {
if ( if (
response.status && response.status &&
(response.message.nama_bank == null || (response.message.nama_bank != null ||
response.message.nama_bank == "") && response.message.nama_bank != "") &&
(response.message.no_rek == null || (response.message.no_rek != null ||
response.message.no_rek == "") response.message.no_rek != "")
) { ) {
Swal.fire({ Swal.fire({
title: "Berhasil", title: "Berhasil",
@ -285,6 +299,7 @@
icon: "error", icon: "error",
}); });
} }
console.log(response.message.nama_bank);
}, },
error: function(error) { error: function(error) {
Swal.fire({ Swal.fire({
@ -304,71 +319,21 @@
} }
}); });
$("#save").on("click", function() { $('#formTambahTransaksi').on('submit', function(e) {
const csrfToken = $('meta[name="csrf-token"]').attr("content"); e.preventDefault();
const csrfToken = $('meta[name="csrf-token"]').attr('content');
let form = this;
let email_kontak = $('#selectContact').val();
let email_input = $('#inputPenjual').val();
let penjual = email_kontak != null ? email_kontak : email_input;
let opsiKontak = document.querySelector( const formData = new FormData(this);
'[name="select_penjual"]' formData.append("email_penjual", penjual);
).value; formData.append("persentase_keuntungan", biayaAdmin);
let inputKontak = document.querySelector( formData.append("total_keuntungan", totalBiayaAdmin);
'[name="input_penjual"]' formData.append("total_harga", totalHarga);
).value; formData.append("total_bayar", totalBayar);
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 {
Swal.fire({ Swal.fire({
html: '<div class="mt-3"><lord-icon src="https://cdn.lordicon.com/etwtznjn.json" trigger="loop" colors="primary:#0ab39c,secondary:#405189" style="width:120px;height:120px"></lord-icon><div class="mt-4 pt-2 fs-15"><h4>Form Anda sedang diproses!</h4><p class="text-muted mx-4 mb-0">Mohon tunggu...</p></div></div>', html: '<div class="mt-3"><lord-icon src="https://cdn.lordicon.com/etwtznjn.json" trigger="loop" colors="primary:#0ab39c,secondary:#405189" style="width:120px;height:120px"></lord-icon><div class="mt-4 pt-2 fs-15"><h4>Form Anda sedang diproses!</h4><p class="text-muted mx-4 mb-0">Mohon tunggu...</p></div></div>',
allowEscapeKey: false, allowEscapeKey: false,
@ -378,18 +343,6 @@
} }
}); });
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("deskripsi", deskripsi);
formData.append("persentase_keuntungan", biayaAdmin);
formData.append("total_keuntungan", totalBiayaAdmin);
formData.append("total_harga", totalHarga);
formData.append("total_bayar", totalBayar);
$.ajaxSetup({ $.ajaxSetup({
headers: { headers: {
"X-CSRF-TOKEN": csrfToken, "X-CSRF-TOKEN": csrfToken,
@ -416,14 +369,31 @@
}); });
}, },
error: function(error) { error: function(error) {
if (error.responseJSON && error.responseJSON.errors) {
let errorMessage = "Terdapat beberapa kesalahan:<br>";
const errors = error.responseJSON.errors;
for (let key in errors) {
errorMessage += `${errors[key].join(', ')}<br>`;
}
Swal.fire({ Swal.fire({
title: "Gagal", title: "Gagal",
text: "Gagal mengirimkan data karena " + error, html: errorMessage,
icon: "error", icon: "error",
}); });
}, } else {
Swal.fire({
title: "Gagal",
text: "Gagal mengirimkan data karena " + error
.statusText,
icon: "error",
}); });
} }
console.log(error);
},
});
}); });
}); });
</script> </script>

View File

@ -53,6 +53,8 @@
@include('user.transaction.penjual.modal-tracking') @include('user.transaction.penjual.modal-tracking')
@include('user.transaction.penjual.modal-pengiriman-selesai') @include('user.transaction.penjual.modal-pengiriman-selesai')
@include('user.transaction.penjual.modal-keterangan-status') @include('user.transaction.penjual.modal-keterangan-status')
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
let listPenjual = $('#table-penjual').DataTable({ let listPenjual = $('#table-penjual').DataTable({
@ -274,6 +276,14 @@
}).then(function() { }).then(function() {
Swal.close(); Swal.close();
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('user-notification.update-new-notification') }}",
type: 'GET',
data: {
receiver: response
.receiver,
}
});
listPenjual.ajax.reload(); listPenjual.ajax.reload();
} }
}); });
@ -349,6 +359,14 @@
}).then(function() { }).then(function() {
Swal.close(); Swal.close();
if (response.status) { if (response.status) {
$.ajax({
url: "{{ route('user-notification.update-new-notification') }}",
type: 'GET',
data: {
receiver: response
.receiver,
}
});
listPenjual.ajax listPenjual.ajax
.reload(); .reload();
} }
@ -516,6 +534,13 @@
if (response.status) { if (response.status) {
$('#formBukti').trigger('reset'); $('#formBukti').trigger('reset');
$('#modalOrderSent').modal('hide'); $('#modalOrderSent').modal('hide');
$.ajax({
url: "{{ route('user-notification.update-new-notification') }}",
type: 'GET',
data: {
receiver: response.receiver,
}
});
listPenjual.ajax.reload(); listPenjual.ajax.reload();
} }
}); });

View File

@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Arial", sans-serif;
background-color: #f4f4f4;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.card {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
max-width: 400px;
width: 100%;
}
.card-rekber {
text-align: center;
margin-bottom: 20px;
}
.large-text {
font-size: 3.5em;
font-weight: bold;
color: #b61754;
}
.small-text {
font-size: 0.8em;
color: #888;
}
.code-verifikasi,
.code,
.masa-berlaku {
margin-bottom: 15px;
}
.code-pendaftaran {
background-color: #b61754;
color: #fff;
text-align: center;
padding: 10px;
border-radius: 4px;
font-size: 3.5em;
margin: 10px 0;
font-weight: bold;
}
@media only screen and (max-width: 600px) {
.card {
max-width: 100%;
}
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="card-rekber">
<p class="large-text">Rekber</p>
<span class="small-text">Pendaftaran Akun Sukses</span>
</div>
<div class="code-verifikasi">
<p>Selamat, anda dengan email</p>
<p><b>{{ $content['email'] }}</b></p>
</div>
<div class="code">
<p>dinyatakan</p>
</div>
<div class="code-pendaftaran">
<p>Berhasil</p>
</div>
<div class="masa-berlaku">
<p>Selamat bergabung di Rekber dan bertransaksi.</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Arial", sans-serif;
background-color: #f4f4f4;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.card {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
max-width: 400px;
width: 100%;
}
.card-rekber {
text-align: center;
margin-bottom: 20px;
}
.large-text {
font-size: 3.5em;
font-weight: bold;
color: #b61754;
}
.small-text {
font-size: 0.8em;
color: #888;
}
.code-verifikasi,
.code,
.masa-berlaku {
margin-bottom: 15px;
}
.code-pendaftaran {
background-color: #b61754;
color: #fff;
text-align: center;
padding: 10px;
border-radius: 4px;
font-size: 3.5em;
margin: 10px 0;
font-weight: bold;
}
@media only screen and (max-width: 600px) {
.card {
max-width: 100%;
}
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="card-rekber">
<p class="large-text">Rekber</p>
<span class="small-text">Pendaftaran Akun Gagal</span>
</div>
<div class="code-verifikasi">
<p>Maaf, Anda dengan email</p>
<p><b>{{ $content['email'] }}</b></p>
</div>
<div class="code">
<p>dinyatakan</p>
</div>
<div class="code-pendaftaran">
<p>Gagal</p>
</div>
<div class="masa-berlaku">
<p>Dengan alasan {{ $content['keterangan'] }}</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -4,7 +4,6 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style> <style>
* { * {
box-sizing: border-box; box-sizing: border-box;

View File

@ -97,7 +97,7 @@
<!-- ======= END SIGN IN FORM ======= --> <!-- ======= END SIGN IN FORM ======= -->
<!-- ======= SIGN UP FORM ======= --> <!-- ======= SIGN UP FORM ======= -->
<form action="javascript:void(0)" class="sign-up-form" id="msform" enctype="multipart/form-data" <form action="javascript:void(0);" class="sign-up-form" id="msform" enctype="multipart/form-data"
method="POST"> method="POST">
@csrf @csrf
<h2 class="title">Daftar</h2> <h2 class="title">Daftar</h2>
@ -394,6 +394,7 @@
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="{{ asset('assets/js/login_register/app.js') }}"></script> <script src="{{ asset('assets/js/login_register/app.js') }}"></script>
<script src="{{ asset('assets/js/login_register/script.js') }}"></script> <script src="{{ asset('assets/js/login_register/script.js') }}"></script>
@if (Session::has('message')) @if (Session::has('message'))
<script> <script>
Swal.fire({ Swal.fire({

View File

@ -33,19 +33,28 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12">
<address>
<strong>Deskripsi:</strong><br>
{!! $transaction->deskripsi_transaksi !!}<br>
</address>
</div>
</div>
<div class="row">
@if (in_array($transaction->status_pembayaran, ['settlement', 'capture']))
<div class="col-md-6"> <div class="col-md-6">
<address> <address>
<strong>Payment Method:</strong><br> <strong>Status Pembayaran:</strong><br>
Visa ending **** 4242<br> {{ ucwords($transaction->status_pembayaran) }}<br>
npannisa@gmail.com
</address> </address>
</div> </div>
<div class="col-md-6 text-md-right"> <div class="col-md-6 text-md-right">
<address> <address>
<strong>Tanggal Transaksi:</strong><br> <strong>Tanggal Pembayaran:</strong><br>
{{ $transaction->created_at->format('d M Y, g:i') }}<br><br> {{ $transaction->created_at->format('d M Y, g:i') }}<br><br>
</address> </address>
</div> </div>
@endif
</div> </div>
</div> </div>
</div> </div>
@ -67,10 +76,10 @@
<td>1</td> <td>1</td>
<td>{{ $transaction->nama_barang }}</td> <td>{{ $transaction->nama_barang }}</td>
<td class="text-center"> <td class="text-center">
Rp.{{ number_format($transaction->harga_barang, 2, ',', '.') }}</td> Rp {{ number_format($transaction->harga_barang, 2, ',', '.') }}</td>
<td class="text-center">{{ $transaction->jumlah_barang }}</td> <td class="text-center">{{ $transaction->jumlah_barang }}</td>
<td class="text-right"> <td class="text-right">
Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }} Rp {{ number_format($transaction->total_harga, 2, ',', '.') }}
</td> </td>
</tr> </tr>
</table> </table>
@ -90,20 +99,20 @@
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Subtotal</div> <div class="invoice-detail-name">Subtotal</div>
<div class="invoice-detail-value"> <div class="invoice-detail-value">
Rp.{{ number_format($transaction->total_harga, 2, ',', '.') }} Rp {{ number_format($transaction->total_harga, 2, ',', '.') }}
</div> </div>
</div> </div>
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Biaya Admin</div> <div class="invoice-detail-name">Biaya Admin</div>
<div class="invoice-detail-value"> <div class="invoice-detail-value">
Rp.{{ number_format($transaction->total_keuntungan, 2, ',', '.') }} Rp {{ number_format($transaction->total_keuntungan, 2, ',', '.') }}
</div> </div>
</div> </div>
<hr class="mt-2 mb-2"> <hr class="mt-2 mb-2">
<div class="invoice-detail-item"> <div class="invoice-detail-item">
<div class="invoice-detail-name">Total</div> <div class="invoice-detail-name">Total</div>
<div class="invoice-detail-value invoice-detail-value-lg"> <div class="invoice-detail-value invoice-detail-value-lg">
Rp.{{ number_format($transaction->total_bayar, 2, ',', '.') }} Rp {{ number_format($transaction->total_bayar, 2, ',', '.') }}
</div> </div>
</div> </div>
</div> </div>
@ -120,6 +129,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
@section('tambahan-js')
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#btnPDF').on('click', function() { $('#btnPDF').on('click', function() {

View File

@ -22,14 +22,14 @@ $new = NotificationReceiver::where('receiver', auth()->user()->email)
<div class="dropdown-menu dropdown-list dropdown-menu-right"> <div class="dropdown-menu dropdown-list dropdown-menu-right">
<div class="dropdown-header">Notifikasi <div class="dropdown-header">Notifikasi
<div class="float-right"> <div class="float-right">
<a href="javascript: void(0);" id="markAllAsRead">Mark All As Read</a> <a href="javascript: void(0);" id="markAllAsRead">Tandai semua telah dibaca</a>
</div> </div>
</div> </div>
<div class="dropdown-list-content dropdown-list-icons" id="notifContent"> <div class="dropdown-list-content dropdown-list-icons" id="notifContent">
</div> </div>
<div class="dropdown-footer text-center"> <div class="dropdown-footer text-center">
<a href="{{ route('user-notification.index') }}">View All <i <a href="{{ route('user-notification.index') }}">Lihat semua<i
class="fas fa-chevron-right"></i></a> class="fas fa-chevron-right"></i></a>
</div> </div>
</div> </div>
@ -55,12 +55,17 @@ $new = NotificationReceiver::where('receiver', auth()->user()->email)
</li> </li>
</ul> </ul>
</nav> </nav>
<script> @section('js-header')
<script>
$(document).ready(function() { $(document).ready(function() {
var notifBtn = $('#notifBtn'); var notifBtn = $('#notifBtn');
function updateNotif() { function updateNotif() {
notifBtn.toggleClass("beep"); notifBtn.addClass("beep");
}
function removeNotif() {
notifBtn.removeClass("beep");
} }
$('#notifBtn').on('click', function() { $('#notifBtn').on('click', function() {
@ -95,7 +100,8 @@ $new = NotificationReceiver::where('receiver', auth()->user()->email)
var minutes = date.getMinutes(); var minutes = date.getMinutes();
var formattedDate = day + ' ' + month + ' ' + year + var formattedDate = day + ' ' + month + ' ' + year +
" | " + hours + ":" + +(minutes < 10 ? '0' : '') + " | " + hours + ":" + +(minutes < 10 ? '0' :
'') +
minutes; minutes;
activitiesHtml += ` activitiesHtml += `
@ -130,11 +136,11 @@ $new = NotificationReceiver::where('receiver', auth()->user()->email)
console.log(error); console.log(error);
} }
}); });
}); });
$('#markAllAsRead').on('click', function() { $('#markAllAsRead').on('click', function() {
const csrfToken = $('meta[name="csrf-token"]').attr('content'); const csrfToken = $('meta[name="csrf-token"]').attr('content');
console.log("Berhasil");
$.ajaxSetup({ $.ajaxSetup({
headers: { headers: {
@ -147,8 +153,7 @@ $new = NotificationReceiver::where('receiver', auth()->user()->email)
type: 'GET', type: 'GET',
success: function(response) { success: function(response) {
if (response.status) { if (response.status) {
updateNotif(); removeNotif();
console.log(response);
} else { } else {
console.log(response); console.log(response);
} }
@ -159,7 +164,7 @@ $new = NotificationReceiver::where('receiver', auth()->user()->email)
}); });
}); });
Pusher.logToConsole = true; // Pusher.logToConsole = true;
var pusher = new Pusher('3e5bdc20dddd7fbc655e', { var pusher = new Pusher('3e5bdc20dddd7fbc655e', {
cluster: 'ap1' cluster: 'ap1'
}); });
@ -169,11 +174,19 @@ $new = NotificationReceiver::where('receiver', auth()->user()->email)
channel.bind('event-update-notifikasi', function(data) { channel.bind('event-update-notifikasi', function(data) {
let receivers = data.receivers; let receivers = data.receivers;
let userEmail = "{{ auth()->user()->email }}"; let userEmail = "{{ auth()->user()->email }}";
if (Array.isArray(receivers)) {
receivers.forEach(email => { receivers.forEach(email => {
if (email == userEmail) { if (email == userEmail) {
updateNotif(); updateNotif();
} }
}); });
} else {
if (receivers == userEmail) {
updateNotif();
}
}
console.log(data);
}); });
}); });
</script> </script>
@endsection

View File

@ -9,6 +9,8 @@
@include('layouts.css') @include('layouts.css')
@yield('css-tambahan')
@include('layouts.js') @include('layouts.js')
</head> </head>
@ -29,8 +31,16 @@
@include('layouts.footer') @include('layouts.footer')
</footer> </footer>
@yield('js-khusus')
@include('layouts.js-bawah') @include('layouts.js-bawah')
@yield('js-header')
@yield('js-sidebar')
@yield('tambahan-js')
</body> </body>
</html> </html>

View File

@ -17,14 +17,14 @@
@if (Auth::user()->role == 'Admin') @if (Auth::user()->role == 'Admin')
<li><a class="nav-link {{ request()->routeIs('admin-user.index') ? 'active' : '' }}" <li><a class="nav-link {{ request()->routeIs('admin-user.index') ? 'active' : '' }}"
href="{{ route('admin-user.index') }}"><i class="far fa-user"></i> href="{{ route('admin-user.index') }}" id="clickUser"><i class="far fa-user"></i>
<span>User</span></a></li> <span id="userBeep">User</span></a></li>
<li><a class="nav-link {{ request()->routeIs('admin-transaction.index') ? 'active' : '' }}" <li><a class="nav-link {{ request()->routeIs('admin-transaction.index') ? 'active' : '' }}"
href="{{ route('admin-transaction.index') }}"><i href="{{ route('admin-transaction.index') }}" id="clickTransaction"><i
class="fas fa-columns"></i><span>Transaction</span></a></li> class="fas fa-columns"></i><span id="transactionBeep">Transaction</span></a></li>
<li><a class="nav-link {{ request()->routeIs('admin-refund.index') ? 'active' : '' }}" <li><a class="nav-link {{ request()->routeIs('admin-refund.index') ? 'active' : '' }}"
href="{{ route('admin-refund.index') }}"><i class="far fa-square"></i> href="{{ route('admin-refund.index') }}" id="clickRefund"><i class="far fa-square"></i>
<span>Refund</span></a> <span id="refundBeep">Refund</span></a>
</li> </li>
<li><a class="nav-link {{ request()->routeIs('admin-setting.index') ? 'active' : '' }}" <li><a class="nav-link {{ request()->routeIs('admin-setting.index') ? 'active' : '' }}"
href="{{ route('admin-setting.index') }}"><i class="fas fa-cog"></i> href="{{ route('admin-setting.index') }}"><i class="fas fa-cog"></i>
@ -73,4 +73,52 @@
</ul> </ul>
</aside> </aside>
</div> </div>
<script src="{{ asset('assets/modules/nicescroll/jquery.nicescroll.min.js') }}"></script> @section('js-khusus')
<script src="{{ asset('assets/modules/nicescroll/jquery.nicescroll.min.js') }}"></script>
@endsection
@section('js-sidebar')
<script>
$(document).ready(function() {
function updateNotifSideBar(layanan) {
layanan.addClass("beep");
}
function removeNotifSideBar(layanan) {
layanan.removeClass("beep");
}
$('#clickRefund').on('click', function() {
removeNotifSideBar($('#refundBeep'));
});
$('#clickTransaction').on('click', function() {
removeNotifSideBar($('#transactionBeep'));
});
$('#clickUser').on('click', function() {
removeNotifSideBar($('#userBeep'));
});
var pusher = new Pusher('3e5bdc20dddd7fbc655e', {
cluster: 'ap1'
});
var channel = pusher.subscribe('chanel-update-notifikasi-untuk-admin');
channel.bind('event-update-notifikasi-untuk-admin', function(data) {
let service = data.service;
let userEmail = "{{ auth()->user()->email }}";
if ("{{ auth()->user()->role }}" == 'Admin') {
if (service == 'Refund') {
updateNotifSideBar($('#refundBeep'));
} else if (service == 'Transaksi') {
updateNotifSideBar($('#transactionBeep'));
} else if (service == 'User') {
updateNotifSideBar($('#userBeep'));
}
}
});
});
</script>
@endsection

View File

@ -351,8 +351,8 @@
</div> </div>
</section> </section>
</div> </div>
@endsection
{{-- profile --}} @section('tambahan-js')
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script> <script>
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
@ -683,5 +683,4 @@
}); });
}); });
</script> </script>
{{-- profile --}}
@endsection @endsection

View File

@ -9,6 +9,7 @@ use App\Http\Controllers\API\Penjual\PenjualApiController;
use App\Http\Controllers\API\Profile\ProfileApiController; use App\Http\Controllers\API\Profile\ProfileApiController;
use App\Http\Controllers\API\Transaction\TransactionApiController; use App\Http\Controllers\API\Transaction\TransactionApiController;
use App\Http\Controllers\API\Invoice\InvoiceApiController; use App\Http\Controllers\API\Invoice\InvoiceApiController;
use App\Http\Controllers\API\Notification\NotificationApiController;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
/* /*
@ -103,6 +104,12 @@ Route::middleware(['auth:api'])->group(function () {
Route::get('get-invoice', 'getInvoice')->name('invoice.get-invoice'); // Bisa Route::get('get-invoice', 'getInvoice')->name('invoice.get-invoice'); // Bisa
Route::get('export-invoice', 'exportInvoice')->name('invoice.export-invoice'); // Bisa Route::get('export-invoice', 'exportInvoice')->name('invoice.export-invoice'); // Bisa
}); // sudah }); // sudah
Route::controller(NotificationApiController::class)->group(function(){
Route::get('list-notification','listNotification')->name('notification.list-notification');
Route::get('get-detail-notification','getDetailNotification')->name('notification.get-detail-notification');
Route::get('mark-all-as-read','markAllAsRead')->name('notification.mark-all-as-read');
});
}); });
}); });
}); });

View File

@ -89,6 +89,7 @@ Route::middleware(['auth'])->group(function(){
// Tampilan dashboard admin beserta perhitungan // Tampilan dashboard admin beserta perhitungan
Route::controller(AdminDashboardController::class)->group(function(){ Route::controller(AdminDashboardController::class)->group(function(){
Route::get('/','index')->name('admin.index'); Route::get('/','index')->name('admin.index');
Route::get('admin-dashboard/get-data-dashboard','getDataBySearch')->name('admin.get-data-dashboard');
}); });
// Tampilan, aprove atau deny dan hapus user // Tampilan, aprove atau deny dan hapus user
@ -96,7 +97,7 @@ Route::middleware(['auth'])->group(function(){
Route::get('admin-user','index')->name('admin-user.index'); Route::get('admin-user','index')->name('admin-user.index');
Route::get('admin-user/list-user','listUser')->name('admin-user.list-user'); Route::get('admin-user/list-user','listUser')->name('admin-user.list-user');
Route::get('admin-user/{id}','show')->name('admin-user.show'); Route::get('admin-user/{id}','show')->name('admin-user.show');
Route::delete('admin-user/hapus-user','delete')->name('admin-user.destroy'); Route::delete('admin-user/hapus-user','destroy')->name('admin-user.destroy');
Route::put('admin-user/approve-user', 'approveUser')->name('admin-user.approve'); Route::put('admin-user/approve-user', 'approveUser')->name('admin-user.approve');
Route::put('admin-user/deny-user', 'denyUser')->name('admin-user.deny'); Route::put('admin-user/deny-user', 'denyUser')->name('admin-user.deny');
}); });
@ -137,7 +138,7 @@ Route::middleware(['auth'])->group(function(){
Route::get('admin-notification/list-user-for-create-edit','listUserForCreateEdit')->name('admin-notification.list-user-for-create-edit'); Route::get('admin-notification/list-user-for-create-edit','listUserForCreateEdit')->name('admin-notification.list-user-for-create-edit');
Route::get('admin-notification/select-all-user','selectAllUser')->name('admin-notification.select-all-user'); Route::get('admin-notification/select-all-user','selectAllUser')->name('admin-notification.select-all-user');
Route::get('admin-notification/edit','edit')->name('admin-notification.edit'); Route::get('admin-notification/edit','edit')->name('admin-notification.edit');
Route::post('admin-notification/update-new-notification','updateNewNotification')->name('admin-notification.update-new-notification'); Route::get('admin-notification/update-new-notification','updateNewNotification')->name('admin-notification.update-new-notification');
Route::post('admin-notification/store','store')->name('admin-notification.store'); Route::post('admin-notification/store','store')->name('admin-notification.store');
Route::post('admin-notification/update','update')->name('admin-notification.update'); Route::post('admin-notification/update','update')->name('admin-notification.update');
Route::delete('admin-notification/delete','delete')->name('admin-notification.delete'); Route::delete('admin-notification/delete','delete')->name('admin-notification.delete');
@ -152,6 +153,7 @@ Route::middleware(['auth'])->group(function(){
// Tampilan dashboard user beserta perhitungan // Tampilan dashboard user beserta perhitungan
Route::controller(UserDashboardController::class)->group(function(){ Route::controller(UserDashboardController::class)->group(function(){
Route::get('/','index')->name('user.index'); Route::get('/','index')->name('user.index');
Route::get('user-dashboard/get-data-dashboard','getDataBySearch')->name('user.get-data-dashboard');
}); });
// Tampilan, tambah dan hapus kontak // Tampilan, tambah dan hapus kontak
@ -201,7 +203,7 @@ Route::middleware(['auth'])->group(function(){
Route::controller(UserRefundController::class)->group(function(){ Route::controller(UserRefundController::class)->group(function(){
Route::get('user-refund','index')->name('user-refund.index'); Route::get('user-refund','index')->name('user-refund.index');
Route::get('user-refund/list-refund','listRefund')->name('user-refund.list-refund'); Route::get('user-refund/list-refund','listRefund')->name('user-refund.list-refund');
Route::get('user-refund/ajukan-komplain','create')->name('user-refund.create'); Route::get('user-refund/ajukan-komplain/{id}','create')->name('user-refund.create');
Route::get('user-refund/detail-refund/{id}','show')->name('user-refund.show'); Route::get('user-refund/detail-refund/{id}','show')->name('user-refund.show');
Route::post('user-refund','store')->name('user-refund.store'); Route::post('user-refund','store')->name('user-refund.store');
}); });
@ -212,6 +214,8 @@ Route::middleware(['auth'])->group(function(){
Route::get('user-notification/detail-notification/{id}','show')->name('user-notifiaction.detail-notification'); Route::get('user-notification/detail-notification/{id}','show')->name('user-notifiaction.detail-notification');
Route::get('user-notification/latest-notification','latestNotification')->name('user-notification.latest-notification'); Route::get('user-notification/latest-notification','latestNotification')->name('user-notification.latest-notification');
Route::get('user-notification/mark-all-as-read','markAllAsRead')->name('user.notification.mark-all-as-read'); Route::get('user-notification/mark-all-as-read','markAllAsRead')->name('user.notification.mark-all-as-read');
Route::get('user-notification/update-new-notification','updateNewNotification')->name('user-notification.update-new-notification');
Route::get('user-notification/update-notification-to-admin','updateNotificationToAdmin')->name('user-notification.update-notification-to-admin');
}); });
}); });
}); });