mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-24 14:54:38 +00:00
Showing Completed Orders Task Done
This commit is contained in:
@@ -46,7 +46,8 @@ class RegisterController extends Controller
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'name' => 'required|name|max:255',
|
||||
'marking' => 'required|max:255|unique:markings',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|min:6|confirmed',
|
||||
]);
|
||||
@@ -61,21 +62,27 @@ class RegisterController extends Controller
|
||||
protected function create(Request $data)
|
||||
{
|
||||
$marking = Marking::Where('email',$data['email'])->first();
|
||||
|
||||
if(!$marking){
|
||||
return response()->json('Access Denied', 401);
|
||||
return response()->json(["message"=>"Marking does not exist, please contact sales team to get one"], 400);
|
||||
}
|
||||
if($marking->marking != $data['marking']){
|
||||
return response()->json('Wrong Marking', 400);
|
||||
return response()->json(["message"=>"Incorrect marking"], 400);
|
||||
}
|
||||
|
||||
if(User::Where('email',$data['email'])->first()){
|
||||
return response()->json(["message"=>"Email already exist in the system"], 400);
|
||||
}
|
||||
|
||||
$role = Role::where('name','=','member')->first();
|
||||
$user = new User();
|
||||
$user->name = $data['name'];
|
||||
$user->email = $data['email'];
|
||||
$user->marking = $marking->marking;
|
||||
$user->password = bcrypt($data['password']);
|
||||
|
||||
$user->save();
|
||||
$user->attachRole($role);
|
||||
|
||||
return response()->json($user, 201);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,11 @@ class BookingController extends Controller
|
||||
|
||||
public function index(){
|
||||
$user = Auth::user();
|
||||
$bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
$bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
->where('user_id', $user->id)
|
||||
->orderby('updated_at','desc')
|
||||
->paginate(10);
|
||||
|
||||
|
||||
// reformat to fit frontend structure
|
||||
foreach ($bookings as $booking) {
|
||||
// set timeout
|
||||
@@ -42,7 +41,7 @@ class BookingController extends Controller
|
||||
|
||||
// TODO : transfer_amount change name to bia
|
||||
$booking->transfer_amount = $booking->bia;
|
||||
|
||||
|
||||
$booking->track_status = "(". $booking->status ."/7)";
|
||||
switch ($booking->status) {
|
||||
case 1:
|
||||
@@ -69,15 +68,15 @@ class BookingController extends Controller
|
||||
default:
|
||||
$status_desc = "";
|
||||
}
|
||||
$booking->status_desc = $status_desc;
|
||||
$booking->marking = $booking->user->marking;
|
||||
}
|
||||
|
||||
|
||||
return $bookings;
|
||||
}
|
||||
|
||||
public function adminIndex(){
|
||||
$user = Auth::user();
|
||||
$bookings = Booking::select('id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
$bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
->orderby('updated_at','desc')
|
||||
->get();
|
||||
|
||||
@@ -126,7 +125,8 @@ class BookingController extends Controller
|
||||
break;
|
||||
default:
|
||||
$status_desc = "";
|
||||
}
|
||||
}
|
||||
$booking->marking = $booking->user->marking;
|
||||
$booking->status_desc = $status_desc;
|
||||
}
|
||||
return $bookings;
|
||||
@@ -169,6 +169,7 @@ class BookingController extends Controller
|
||||
$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;
|
||||
$booking->marking = $booking->user->marking;
|
||||
|
||||
if (!$booking){
|
||||
return response()->json(['success'=>false, 'message'=>'not found'], 404);
|
||||
@@ -214,6 +215,7 @@ class BookingController extends Controller
|
||||
$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;
|
||||
$booking->marking = $booking->user->marking;
|
||||
|
||||
if (!$booking){
|
||||
return response()->json(['success'=>false, 'message'=>'not found'], 404);
|
||||
@@ -350,7 +352,7 @@ class BookingController extends Controller
|
||||
|
||||
return response()->json(['book_id'=>$book_id],200);
|
||||
}
|
||||
//upload
|
||||
|
||||
public function uploadbankslip(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
@@ -410,8 +412,7 @@ class BookingController extends Controller
|
||||
}
|
||||
else {
|
||||
return response()->json(['message' => 'No file detected'], 400);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updateBankSlipAmount(Request $request, $id){
|
||||
@@ -487,7 +488,6 @@ class BookingController extends Controller
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
|
||||
public function showPurchaseOrder($id){
|
||||
$booking = Booking::where('id',$id)->first();
|
||||
@@ -526,6 +526,7 @@ class BookingController extends Controller
|
||||
$term = $request->input('term');
|
||||
$china_beneficiary = $request->input('china_beneficiary');
|
||||
$rates = Rate::orderby('updated_at','desc')->first();
|
||||
$marking = $user = Auth::user()->marking;
|
||||
|
||||
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
|
||||
|
||||
@@ -536,9 +537,7 @@ class BookingController extends Controller
|
||||
if($amount > $creditLimit->rmb_credit_limit){
|
||||
return response()->json(["message" => "Exceed credit limit, please contact our sales team for larger quantitiy"], 400);
|
||||
}
|
||||
|
||||
// TODO : get marking
|
||||
$marking = "123X";
|
||||
|
||||
|
||||
switch ($term) {
|
||||
case "x1_cash":
|
||||
@@ -656,7 +655,7 @@ class BookingController extends Controller
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
//upload
|
||||
|
||||
public function uploadInvoice(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::where('id',$id)->first();
|
||||
@@ -756,10 +755,9 @@ class BookingController extends Controller
|
||||
|
||||
public function adminShowCompletedOrders()
|
||||
{
|
||||
$bookings = Booking::select('id', 'company_name','company_address','created_at', 'rmb_book_amount', 'admin_status')
|
||||
->where('admin_status', 1)
|
||||
$bookings = Booking::select('id', 'company_name','company_address','created_at','rate','amount', 'rmb_book_amount', 'admin_status')
|
||||
->where('admin_status', 7)
|
||||
->orderBy('id', 'desc')
|
||||
->take(10)
|
||||
->get();
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
@@ -767,6 +765,8 @@ class BookingController extends Controller
|
||||
$booking->company_name;
|
||||
$booking->company_address;
|
||||
$booking->created_at;
|
||||
$booking->rate;
|
||||
$booking->amount;
|
||||
$booking->rmb_book_amount;
|
||||
$booking->admin_status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\SettingActiveBank;
|
||||
|
||||
class SettingActiveBankController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$active_bank_setting = SettingActiveBank::latest()->first();
|
||||
return response()->json($active_bank_setting, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
if($active_bank_setting = SettingActiveBank::latest()->first())
|
||||
$active_bank_setting->update($request->all());
|
||||
else
|
||||
$active_bank_setting = SettingActiveBank::create($request->all());
|
||||
|
||||
return response()->json($active_bank_setting, 200);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@ class SettingCreditController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return SettingCredit::all();
|
||||
$credit_setting = SettingCredit::latest()->first();
|
||||
return response()->json($credit_setting, 201);
|
||||
}
|
||||
|
||||
public function show(SettingCredit $credit)
|
||||
@@ -24,11 +25,12 @@ class SettingCreditController extends Controller
|
||||
return response()->json($credit, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, SettingCredit $credit)
|
||||
public function update(Request $request)
|
||||
{
|
||||
$credit->update($request->all());
|
||||
$credit_setting = SettingCredit::latest()->first();
|
||||
$credit_setting->update($request->all());
|
||||
|
||||
return response()->json($credit, 200);
|
||||
return response()->json($credit_setting, 200);
|
||||
}
|
||||
|
||||
public function delete(SettingCredit $credit)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\SettingMalaysiaBank;
|
||||
|
||||
class SettingMalaysiaBankController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return SettingMalaysiaBank::all();
|
||||
}
|
||||
|
||||
public function show(SettingMalaysiaBank $malaysiaBank)
|
||||
{
|
||||
return $malaysiaBank;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$malaysiaBank = SettingMalaysiaBank::create($request->all());
|
||||
|
||||
return response()->json($malaysiaBank, 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, SettingMalaysiaBank $malaysiaBank)
|
||||
{
|
||||
$malaysiaBank->update($request->all());
|
||||
|
||||
return response()->json($malaysiaBank, 200);
|
||||
}
|
||||
|
||||
public function delete(SettingMalaysiaBank $malaysiaBank)
|
||||
{
|
||||
$malaysiaBank->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user