mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-21 13:34:24 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange
# Conflicts: # routes/api.php
This commit is contained in:
@@ -96,7 +96,6 @@ class BookingController extends Controller
|
||||
// Bank in amount
|
||||
$bia = round($RMBinMYR + $gst + $sales_tax + $billing, 2);
|
||||
|
||||
|
||||
$booking = new Booking();
|
||||
$booking->account_name = $request->input('account_name');
|
||||
$booking->account_num = $request->input('account_num');
|
||||
@@ -107,30 +106,33 @@ class BookingController extends Controller
|
||||
$booking->rate_id = $rates->id;
|
||||
$booking->rmb_book_amount = $request->input('amount');
|
||||
$booking->bia = $bia;
|
||||
//$booking->user_id = $user-;
|
||||
// $booking->user_id = $user->id;
|
||||
$booking->user()->associate($user);
|
||||
$booking->save();
|
||||
|
||||
|
||||
// The test failed due to ->save() before filling up the information at below
|
||||
|
||||
// TODO : handle RMB, MYR and USD (we can use exchange type: USDtoMYR, RMBtoMYR vise versa to switch case)
|
||||
// $booking->rmb_book_pay_method = $request->input('payment_method');
|
||||
// $booking->rmb_book_account_name = $request->input('rmb_book_account_name');
|
||||
// $booking->rmb_book_acc_no = $request->input('rmb_book_acc_no');
|
||||
// $booking->rmb_book_bank_branch = $request->input('rmb_book_bank_branch');
|
||||
// $booking->company_name = $request->input('company_name');
|
||||
// $booking->company_address = $request->input('company_address');
|
||||
// $booking->bank_address = $request->input('bank_address');
|
||||
// $booking->swift_code = $request->input('swift_code');
|
||||
// $booking->cnap = $request->input('cnap');
|
||||
// $booking->term = $request->input('term');
|
||||
// $booking->company_name = $request->input('company_name');
|
||||
// $booking->company_address = $request->input('company_address');
|
||||
// $booking->bank_address = $request->input('bank_address');
|
||||
// $booking->swift_code = $request->input('swift_code');
|
||||
// $booking->cnap = $request->input('cnap');
|
||||
// $booking->term = $request->input('term');
|
||||
|
||||
// $booking->usd_book_amount = $request->input('usd_book_amount');
|
||||
// $booking->usd_book_pay_method = $request->input('usd_book_pay_method');
|
||||
// $booking->usd_book_company_name = $request->input('usd_book_company_name');
|
||||
// $booking->usd_book_company_address = $request->input('usd_book_company_address');
|
||||
// $booking->usd_book_swift_code = $request->input('usd_book_swift_code');
|
||||
// $booking->usd_book_cnap = $request->input('usd_book_cnap');
|
||||
// $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch');
|
||||
// $booking->verification_status = $request->input('verification_status');
|
||||
// $booking->usd_book_amount = $request->input('usd_book_amount');
|
||||
// $booking->usd_book_pay_method = $request->input('usd_book_pay_method');
|
||||
// $booking->usd_book_company_name = $request->input('usd_book_company_name');
|
||||
// $booking->usd_book_company_address = $request->input('usd_book_company_address');
|
||||
// $booking->usd_book_swift_code = $request->input('usd_book_swift_code');
|
||||
// $booking->usd_book_cnap = $request->input('usd_book_cnap');
|
||||
// $booking->usd_book_bank_branch = $request->input('usd_book_bank_branch');
|
||||
// $booking->verification_status = $request->input('verification_status');
|
||||
$booking->save();
|
||||
return response()->json($booking, 201);
|
||||
}
|
||||
|
||||
@@ -170,12 +172,12 @@ class BookingController extends Controller
|
||||
return response()->json(['message'=>'Incorrect format'],200);
|
||||
}
|
||||
|
||||
|
||||
if(!$bankslip_file = $request->file('file'))
|
||||
{
|
||||
return response()->json(['message' => 'No file detected'], 400);
|
||||
}
|
||||
/* End Validation */
|
||||
|
||||
$filename = $bankslip_file->getClientOriginalName();
|
||||
$ext = $bankslip_file->getClientOriginalExtension();
|
||||
$input['file'] = $filename;
|
||||
@@ -192,6 +194,7 @@ class BookingController extends Controller
|
||||
$user_bankslip->transfer_amount = $request->input('transfer_amount');
|
||||
$user_bankslip->save();
|
||||
|
||||
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
}
|
||||
|
||||
@@ -218,7 +221,7 @@ class BookingController extends Controller
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'image_url' => 'image|mimes:jpg,jpeg,bmp,png'
|
||||
'file' => 'image|mimes:jpg,jpeg,bmp,png'
|
||||
]);
|
||||
|
||||
if($validator->fails())
|
||||
@@ -226,7 +229,7 @@ class BookingController extends Controller
|
||||
return response()->json(['message'=>'Incorrect format'],200);
|
||||
}
|
||||
|
||||
if(!$user_input_file = $request->file('image_url'))
|
||||
if(!$user_input_file = $request->file('file'))
|
||||
{
|
||||
return response()->json(['message' => 'No file detected'], 400);
|
||||
}
|
||||
@@ -235,11 +238,11 @@ class BookingController extends Controller
|
||||
$filename = $user_input_file->getClientOriginalName();
|
||||
$ext = $user_input_file->getClientOriginalExtension();
|
||||
|
||||
$input['image_url'] = $filename;
|
||||
$input['file'] = $filename;
|
||||
$unique_name = 'purchase_order_' . md5($filename. time());
|
||||
$unique_image_url = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
'image_url',/*folder name*/ $user_input_file, $unique_image_url
|
||||
'file',/*folder name*/ $user_input_file, $unique_image_url
|
||||
);
|
||||
|
||||
$user_po = new PurchaseOrder;
|
||||
@@ -335,19 +338,50 @@ class BookingController extends Controller
|
||||
|
||||
public function approveBankSlip(Request $request, $book_id)
|
||||
{
|
||||
if (!$Booking = Booking::where('user_id',Auth::user()->id)->where('id',$book_id)->first())
|
||||
if (!$booking = Booking::where('user_id',Auth::user()->id)->where('id',$book_id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
if(!$userBankSlip = UserBankSlip::where('book_id',$Booking->id)->first())
|
||||
if(!$userBankSlip = UserBankSlip::where('book_id',$booking->id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
// Rejected bankslip cannot be approve again
|
||||
if($userBankSlip->is_reject == 1)
|
||||
{
|
||||
return response()->json(['message'=>'Bankslip already rejected'],200);
|
||||
}
|
||||
|
||||
$userBankSlip->is_approve = 1;
|
||||
$userBankSlip->save();
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function rejectBankSlip(Request $request, $book_id)
|
||||
{
|
||||
if (!$booking = Booking::where('user_id',Auth::user()->id)->where('id',$book_id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
if(!$userBankSlip = UserBankSlip::where('book_id',$booking->id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
// approved bankslip cannot be reject again
|
||||
if($userBankSlip->is_approve == 1)
|
||||
{
|
||||
return response()->json(['message'=>'Bankslip already approved'],200);
|
||||
}
|
||||
|
||||
$userBankSlip->is_reject = 1;
|
||||
$userBankSlip->reject_reason = $request->reject_reason;
|
||||
$userBankSlip->save();
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user