mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
fix conflit
This commit is contained in:
@@ -31,8 +31,7 @@ class BookingController extends Controller
|
||||
// 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'));
|
||||
$difference_in_seconds = ($date1->format('U') + 600) - ($date2->format('U'));
|
||||
$booking->timeout = $difference_in_seconds;
|
||||
|
||||
// TODO : you can make it better
|
||||
@@ -94,7 +93,7 @@ class BookingController extends Controller
|
||||
// TODO : transfer_amount change name to bia
|
||||
$booking->transfer_amount = $booking->bia;
|
||||
|
||||
$booking->track_status = "(". $booking->admin_status ."/6)";
|
||||
$booking->track_status = "(". $booking->admin_status ."/7)";
|
||||
switch ($booking->admin_status) {
|
||||
case 0:
|
||||
$status_desc = "Waiting user to upload bankin slip";
|
||||
@@ -112,10 +111,13 @@ class BookingController extends Controller
|
||||
$status_desc = "Please update supplier booking status.";
|
||||
break;
|
||||
case 5:
|
||||
$status_desc = "Customer has uploaded the invoice, please upload purchase order";
|
||||
$status_desc = "Upload China Bankslip";
|
||||
break;
|
||||
case 6:
|
||||
$status_desc = "Booking completed";
|
||||
$status_desc = "Customer has uploaded the invoice, please upload purchase order";
|
||||
break;
|
||||
case 7:
|
||||
$status_desc = "Booking Completed";
|
||||
break;
|
||||
default:
|
||||
$status_desc = "";
|
||||
@@ -148,7 +150,8 @@ class BookingController extends Controller
|
||||
public function adminShow($id)
|
||||
{
|
||||
$booking = Booking::where('id', $id)->first();
|
||||
return $booking->userBankSlip()->get();
|
||||
$user_bankslip_path = $booking->userBankSlip()->first()->bankslip_path;
|
||||
$booking->user_bankslip_path = Storage::url($user_bankslip_path);
|
||||
|
||||
if($booking){
|
||||
$date1 = new DateTime($booking->created_at);
|
||||
@@ -166,10 +169,15 @@ class BookingController extends Controller
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$rates = Rate::orderby('updated_at','desc')->first();
|
||||
$term = $request->input('term');
|
||||
$amount = $request->input("amount"); // in RMB
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
$rates = Rate::orderby('updated_at','desc')->first();
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
|
||||
if (!$creditLimit){
|
||||
return response()->json("Credit limit not set, please contact admin", 405);
|
||||
}
|
||||
|
||||
if($amount > $creditLimit->rmb_credit_limit){
|
||||
return response()->json("Exceed credit limit, need approved from admin", 401);
|
||||
}
|
||||
@@ -315,29 +323,33 @@ class BookingController extends Controller
|
||||
return response()->json(['message'=>'Image too large, upload files up to 3 MB'], 400);
|
||||
}
|
||||
|
||||
if(!$bankslip_file = $request->file('file'))
|
||||
if($bankslip_file = $request->file('file'))
|
||||
{
|
||||
/* End Validation */
|
||||
$filename = $bankslip_file->getClientOriginalName();
|
||||
$ext = $bankslip_file->getClientOriginalExtension();
|
||||
|
||||
|
||||
$unique_name = 'bank_slip_' . md5($filename. time()); // probably not a good idea
|
||||
$unique_image_path = $unique_name. '.' .$ext;
|
||||
|
||||
$upload_path = Storage::disk('public')->putFileAs(
|
||||
'user_bankslip', $bankslip_file, $unique_image_path
|
||||
);
|
||||
|
||||
$user_bankslip = new UserBankSlip;
|
||||
$user_bankslip->booking_id = $booking->id;
|
||||
$user_bankslip->bankslip_path = $upload_path;
|
||||
$user_bankslip->transfer_amount = $request->input('transfer_amount');
|
||||
$user_bankslip->save();
|
||||
|
||||
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
}
|
||||
else {
|
||||
return response()->json(['message' => 'No file detected'], 400);
|
||||
}
|
||||
/* End Validation */
|
||||
$filename = $bankslip_file->getClientOriginalName();
|
||||
$ext = $bankslip_file->getClientOriginalExtension();
|
||||
$input['file'] = $filename;
|
||||
|
||||
$unique_name = 'bank_slip_' . md5($filename. time()); // probably not a good idea
|
||||
$unique_image_path = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
'user_bankslip', $bankslip_file, $unique_image_path
|
||||
);
|
||||
|
||||
$user_bankslip = new UserBankSlip;
|
||||
$user_bankslip->booking_id = $booking->id;
|
||||
$user_bankslip->bankslip_path = $unique_image_path;
|
||||
$user_bankslip->transfer_amount = $request->input('transfer_amount');
|
||||
$user_bankslip->save();
|
||||
|
||||
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
|
||||
}
|
||||
|
||||
public function updateBankSlipAmount(Request $request, $id){
|
||||
@@ -346,7 +358,13 @@ class BookingController extends Controller
|
||||
|
||||
if(!$user_bankslip){
|
||||
return response()->json(["message"=> "not found"],400);
|
||||
}
|
||||
}
|
||||
|
||||
// update booking status
|
||||
$booking->status = 3;
|
||||
$booking->admin_status = 2;
|
||||
$booking->save();
|
||||
|
||||
$user_bankslip->transfer_amount = $request->input('transfer_amount');
|
||||
$user_bankslip->save();
|
||||
return response()->json(["message"=> "Success"],200);
|
||||
@@ -392,12 +410,12 @@ class BookingController extends Controller
|
||||
$input['file'] = $filename;
|
||||
$unique_name = 'purchase_order_' . md5($filename. time());
|
||||
$unique_image_path = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
'purchase_order',/*folder name*/ $user_input_file, $unique_image_path
|
||||
$upload_path = Storage::disk('public')->putFileAs(
|
||||
'purchase_order',/*folder name*/ $user_input_file, $unique_image_path, 'public'
|
||||
);
|
||||
|
||||
$user_po = new PurchaseOrder;
|
||||
$user_po->image_path = $unique_image_path;
|
||||
$user_po->image_path = $upload_path;
|
||||
$user_po->book_id = $booking->id;
|
||||
$user_po->save();
|
||||
|
||||
@@ -406,11 +424,18 @@ class BookingController extends Controller
|
||||
|
||||
public function confirmPurchaseOrder($id){
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
$booking->status = 5;
|
||||
$booking->status = 6;
|
||||
$booking->save();
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function showPurchaseOrder($id){
|
||||
$booking = Booking::where('id',$id)->first();
|
||||
$user_po = $booking->purchaseOrder()->first();
|
||||
|
||||
return response()->json(['po_path'=> $user_po],200);
|
||||
}
|
||||
|
||||
public function delete(Booking $book_id)
|
||||
{
|
||||
$booking = Booking::where('user_id', Auth::user())->where('id', $book_id)->firstOrFail();
|
||||
@@ -496,14 +521,16 @@ 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())
|
||||
$booking = Booking::where('id',$book_id)->first();
|
||||
|
||||
if (!$booking)
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
return response()->json(['message'=>'Booking not found'], 400);
|
||||
}
|
||||
|
||||
if(!$userBankSlip = UserBankSlip::where('booking_id',$booking->id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
return response()->json(['message'=>'User bankslip not found'], 400);
|
||||
}
|
||||
|
||||
// Rejected bankslip cannot be approve again
|
||||
@@ -515,12 +542,19 @@ class BookingController extends Controller
|
||||
$userBankSlip->is_approve = 1;
|
||||
$userBankSlip->estimated_arrival_time = $request->input('estimated_arrival_time');
|
||||
$userBankSlip->save();
|
||||
|
||||
// update booking status
|
||||
$booking->status = 4;
|
||||
$booking->admin_status = 3;
|
||||
$booking->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())
|
||||
$booking = Booking::where('id',$book_id)->first();
|
||||
if (!$booking)
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
@@ -540,6 +574,12 @@ class BookingController extends Controller
|
||||
$userBankSlip->reject_reason = $request->reject_reason;
|
||||
$userBankSlip->save();
|
||||
|
||||
// TODO : reject user bankinslip
|
||||
// update booking status
|
||||
$booking->status = 0;
|
||||
$booking->admin_status = 0;
|
||||
$booking->save();
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
//upload
|
||||
@@ -583,12 +623,12 @@ class BookingController extends Controller
|
||||
$input['invoice_path'] = $filename;
|
||||
$unique_name = 'invoice' . md5($filename. time());
|
||||
$unique_file_url = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
'invoice',/*folder name*/ $input_file, $unique_file_url
|
||||
$upload_path = Storage::disk('public')->putFileAs(
|
||||
'invoice',/*folder name*/ $input_file, $unique_file_url, 'public'
|
||||
);
|
||||
|
||||
$invoice = new Invoice;
|
||||
$invoice->invoice_path = $unique_file_url;
|
||||
$invoice->invoice_path = $upload_path;
|
||||
$invoice->amount = $request->input('amount');
|
||||
$invoice->booking_id = $booking->id;
|
||||
$invoice->save();
|
||||
|
||||
Reference in New Issue
Block a user