From a449d4f30c1c73a905440b6c85d4f034b50712eb Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Fri, 15 Jun 2018 18:54:03 +0800 Subject: [PATCH] TBD calculation feature updated bookingconfirmationTable frontend --- app/Http/Controllers/BookingController.php | 51 +++++++++- resources/assets/js/pages/home.vue | 103 ++++++++++++++++----- routes/api.php | 1 + 3 files changed, 128 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 47fb2e02..e4bf2c43 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -35,10 +35,10 @@ class BookingController extends Controller $rate = $rates->x2_ba; break; default: - return Response::json(array( + return response()->json([ 'success' => false, 'message' => 'Invalid input', - ), 422); + ], 422); break; } @@ -117,4 +117,51 @@ class BookingController extends Controller } // TODO : cancel booking feature + + + // TODO : get calculation + + public function calculation(Request $request){ + $amount = $request->input('amount'); + $term = $request->input('term'); + $rates = Rate::all()->last(); + + switch ($term) { + case "x1_cash": + $rate = $rates->x1_cash; + break; + case "x1_cheque": + $rate = $rates->x1_cheque; + break; + case "x1_ba": + $rate = $rates->x1_ba; + break; + case "x2_cash": + $rate = $rates->x2_cash; + break; + case "x2_cheque": + $rate = $rates->x2_cheque; + break; + case "x2_ba": + $rate = $rates->x2_ba; + break; + default: + return response()->json([ + 'success' => false, + 'message' => 'Invalid input', + ], 422); + break; + } + return $rate; + + // order number + // date + // customer marking + // payment method + // CNY RMB + + // Service charge + // Rate + // Total before GST + } } diff --git a/resources/assets/js/pages/home.vue b/resources/assets/js/pages/home.vue index d5cf2d23..a5928798 100644 --- a/resources/assets/js/pages/home.vue +++ b/resources/assets/js/pages/home.vue @@ -144,7 +144,7 @@
- + @@ -169,12 +169,58 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date :   123
Customer Marking :   123
Payment Method :   123
CNY/RMB :   123
+ Service Charge :   123
RATE :  123
  RM 12,000
China Beneficiary Acc :   123123
Bank in Amoint :   123123
+ Confirm @@ -248,7 +294,7 @@ data() { return { status: '', - booking:{ + booking: { amount: '' }, bookingForm: { @@ -259,21 +305,31 @@ account_num: '' }, rules: { - amount: [ - { required: true, message: 'Please input amount', trigger: 'change' }, - ], - bank_name: [ - { required: true, message: 'Please input bank name', trigger: 'change' }, - ], - account_name: [ - { required: true, message: 'Please input account name', trigger: 'change' } - ], - bank_branch: [ - { required: true, message: 'Please input branch', trigger: 'change' } - ], - account_num: [ - { required: true, message: 'Please input account number', trigger: 'change' } - ] + amount: [{ + required: true, + message: 'Please input amount', + trigger: 'change' + }, ], + bank_name: [{ + required: true, + message: 'Please input bank name', + trigger: 'change' + }, ], + account_name: [{ + required: true, + message: 'Please input account name', + trigger: 'change' + }], + bank_branch: [{ + required: true, + message: 'Please input branch', + trigger: 'change' + }], + account_num: [{ + required: true, + message: 'Please input account number', + trigger: 'change' + }] }, term: '', options1: [{ @@ -350,9 +406,6 @@ } ], bookingConfirmTable: [{ - data1: 'Order Number :', - data2: '001' - }, { data1: 'Date :', data2: '25/5/2018' }, { @@ -431,7 +484,7 @@ this.term = newterm }, getCalculationValue(formName) { - this.$refs[formName].validate((valid) => { + this.$refs[formName].validate((valid) => { if (valid) { this.dialogFormVisible = false this.dialogFormVisible1 = true @@ -479,13 +532,13 @@ // TODO : Get booking status from server this.status = 6 - + switch (this.status) { case 1: this.$router.push({ name: 'booking.user.upload' }) - + case 2: this.$router.push({ name: 'booking.user.upload' diff --git a/routes/api.php b/routes/api.php index 90ee9b81..669990eb 100644 --- a/routes/api.php +++ b/routes/api.php @@ -27,6 +27,7 @@ Route::get('/booking/{book_id}', 'BookingController@show'); Route::post('/booking', 'BookingController@store'); Route::put('/booking/{book_id}', 'BookingController@update'); Route::delete('/booking/{book_id}', 'BookingController@delete'); +Route::post('/booking/calculation', 'BookingController@calculation'); //Route::middleware('auth:api')->get('/user', function (Request $request) {