diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 6f8110c2..efd7dc3c 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -24,7 +24,68 @@ class BookingController extends Controller public function index(){ $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') - ->where('user_id', $user->id) + ->where('status', '<', '7') + ->orderby('updated_at','desc') + ->paginate(10); + + // reformat to fit frontend structure + foreach ($bookings as $booking) { + // set timeout + $date1 = new DateTime($booking->created_at); + $date2 = new DateTime(); + $time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit; + $difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U')); + $booking->timeout = $difference_in_seconds; + + // TODO : you can make it better + if($difference_in_seconds < 0 ){ + $booking->timeout = 0; + } + + // TODO : transfer_amount change name to bia + $booking->transfer_amount = $booking->bia; + + $booking->track_status = "(". $booking->status ."/7)"; + switch ($booking->status) { + case 1: + $status_desc = "Order in progress"; + break; + case 2: + $status_desc = "Waiting for payment"; + break; + case 3: + $status_desc = "Waiting verification"; + break; + case 4: + $status_desc = "Processing transfer"; + break; + case 5: + $status_desc = "Transfer Complete, please upload your PO"; + break; + case 6: + $status_desc = "Processing invoice"; + break; + case 7: + $status_desc = "Order Completed"; + break; + default: + $status_desc = ""; + } + $booking->status_desc = $status_desc; + $booking->marking = $booking->user->marking; + } + + return $bookings; + } + + + + + + public function userComplete(){ + $user = Auth::user(); + $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') + ->where('status', '=', '7') ->orderby('updated_at','desc') ->paginate(10); @@ -155,19 +216,76 @@ class BookingController extends Controller return $bookings; } + public function adminBookComplete(){ + $user = Auth::user(); + $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') + ->where('status', '=', '7') + ->orderby('updated_at','desc') + ->paginate(10); + + // reformat to fit frontend structure + foreach ($bookings as $booking) { + // set timeout + $date1 = new DateTime($booking->created_at); + $date2 = new DateTime(); + $time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit; + $difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U')); + $booking->timeout = $difference_in_seconds; + + // TODO : you can make it better + if($difference_in_seconds < 0 ){ + $booking->timeout = 0; + } + + // TODO : transfer_amount change name to bia + $booking->transfer_amount = $booking->bia; + + $booking->track_status = "(". $booking->status ."/7)"; + switch ($booking->status) { + case 1: + $status_desc = "Order in progress"; + break; + case 2: + $status_desc = "Waiting for payment"; + break; + case 3: + $status_desc = "Waiting verification"; + break; + case 4: + $status_desc = "Processing transfer"; + break; + case 5: + $status_desc = "Transfer Complete, please upload your PO"; + break; + case 6: + $status_desc = "Processing invoice"; + break; + case 7: + $status_desc = "Order Completed"; + break; + default: + $status_desc = ""; + } + $booking->status_desc = $status_desc; + $booking->marking = $booking->user->marking; + } + + return $bookings; + } public function show($id) { $booking = Booking::where('user_id',Auth::user()->id)->where('id', $id)->first(); - - $user_bankslip = $booking->userBankSlip()->first(); - $china_bankslip = $booking->chinaBankSlip()->get(); - $po = $booking->purchaseOrder()->first(); - $invoice = $booking->invoice()->first(); + if($booking){ $date1 = new DateTime($booking->created_at); + $user_bankslip = $booking->userBankSlip()->first(); + $china_bankslip = $booking->chinaBankSlip()->get(); + $po = $booking->purchaseOrder()->first(); + $invoice = $booking->invoice()->first(); + if ($user_bankslip){ $booking->user_bankslip_path = Storage::url($user_bankslip->bankslip_path); $booking->reject_reason = $user_bankslip->reject_reason; diff --git a/resources/assets/js/pages/admin/home.vue b/resources/assets/js/pages/admin/home.vue index aa21c45e..e5aae7fe 100644 --- a/resources/assets/js/pages/admin/home.vue +++ b/resources/assets/js/pages/admin/home.vue @@ -5,6 +5,9 @@ + + + @@ -41,11 +44,9 @@ View Status Cancel --> - - - - - + + + Previous @@ -54,7 +55,67 @@ Next - + + + + + + + + + Update + { BookingStatus(scope.row.status, scope.row.id) }"> {{ scope.row.id }} + + + --> + + + + + + + + + + {{ scope.row.status_desc }} + + {{ scope.row.track_status }} + + + + + + + + { BookingStatus(scope.row.status, scope.row.id) }"> View Status + + + + + + Previous + + Page {{completePagination.current_page}} of {{completePagination.last_page}} + + Next + + + + + + + + + + + +
{{ scope.row.status_desc }}