mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-19 04:24:08 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange into admin_Completed_Order
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use App\Rate;
|
||||
|
||||
class RateUpdated implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $rate;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Rate $rate)
|
||||
{
|
||||
$this->rate = $rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new Channel('rate-updated');
|
||||
//return new PrivateChannel('rate-updated');
|
||||
}
|
||||
|
||||
public function broadcastWith() {
|
||||
return [
|
||||
'rate' => $this->rate,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,11 +25,13 @@ class BookingController extends Controller
|
||||
$user = Auth::user();
|
||||
$bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
->where('user_id', Auth::user()->id)
|
||||
->where('status', '=', '6')
|
||||
->orwhere('status', '=', '4')
|
||||
->orwhere('status', '=', '3')
|
||||
->orwhere('status', '=', '2')
|
||||
->orwhere('status', '=', '1')
|
||||
->where(function ($query) {
|
||||
$query->where('status', '=', '6')
|
||||
->orwhere('status', '=', '4')
|
||||
->orwhere('status', '=', '3')
|
||||
->orwhere('status', '=', '2')
|
||||
->orwhere('status', '=', '1');
|
||||
})
|
||||
->orderby('updated_at','desc')
|
||||
->paginate(10);
|
||||
|
||||
@@ -159,14 +161,13 @@ class BookingController extends Controller
|
||||
public function adminIndex(){
|
||||
$user = Auth::user();
|
||||
$bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
|
||||
|
||||
->where('admin_status', '=', '5')
|
||||
->orwhere('admin_status', '=', '4')
|
||||
->orwhere('admin_status', '=', '3')
|
||||
->orwhere('admin_status', '=', '2')
|
||||
->orwhere('admin_status', '=', '1')
|
||||
->orderby('updated_at','desc')
|
||||
->paginate(10);
|
||||
->where('admin_status', '=', '5')
|
||||
->orwhere('admin_status', '=', '4')
|
||||
->orwhere('admin_status', '=', '3')
|
||||
->orwhere('admin_status', '=', '2')
|
||||
->orwhere('admin_status', '=', '1')
|
||||
->orderby('updated_at','desc')
|
||||
->paginate(10);
|
||||
|
||||
// reformat to fit frontend structure
|
||||
foreach ($bookings as $booking) {
|
||||
@@ -469,7 +470,8 @@ class BookingController extends Controller
|
||||
if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) {
|
||||
$svcharge = 0;
|
||||
} else {
|
||||
$svcharge = 20.00;
|
||||
//$svcharge = 20.00;
|
||||
$svcharge = 0; // UPDATE ON : 15-8-2018 from PM
|
||||
}
|
||||
|
||||
$subtotal = round(($amount + $svcharge) / $rate, 2);
|
||||
@@ -638,16 +640,9 @@ class BookingController extends Controller
|
||||
$booking->admin_status = 2;
|
||||
$booking->save();
|
||||
|
||||
// Add notification message to admin
|
||||
$adminNotification = new Notification;
|
||||
$adminNotification->detail = "A bankslip is uploaded for booking " . $booking->id;
|
||||
$adminNotification->link = "/booking/" . $booking->id . "/verification";
|
||||
$adminNotification->user_id = User::withRole('admin')->first()->id;
|
||||
$adminNotification->save();
|
||||
|
||||
$user_bankslip->transfer_amount = $request->input('transfer_amount');
|
||||
$user_bankslip->save();
|
||||
return response()->json($adminNotification,200);
|
||||
return response()->json(["success"=>true],200);
|
||||
}
|
||||
|
||||
public function uploadPurchaseOrder(Request $request, $id)
|
||||
@@ -796,7 +791,8 @@ class BookingController extends Controller
|
||||
if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) {
|
||||
$svcharge = 0;
|
||||
} else {
|
||||
$svcharge = 20.00;
|
||||
//$svcharge = 20.00;
|
||||
$svcharge = 0; // UPDATE ON : 15-8-2018 from PM
|
||||
}
|
||||
|
||||
$subtotal = round(($amount + $svcharge) / $rate,2);
|
||||
@@ -868,21 +864,13 @@ class BookingController extends Controller
|
||||
$booking->status = 4;
|
||||
if($booking->term !== "x1_ba" || $booking->term !== "x2_cheque"){
|
||||
$booking->admin_status = 3;
|
||||
// Add notification message to user
|
||||
$userNotification = new Notification;
|
||||
$userNotification->detail = "Your bankslip for booking " . $booking->id . " is approved.";
|
||||
$userNotification->link = "/booking/" . $booking->id . "/transfer";
|
||||
$userNotification->user_id = $booking->user_id;
|
||||
$userNotification->save();
|
||||
// TODO : Add notification message to user
|
||||
|
||||
}
|
||||
else{
|
||||
$booking->admin_status = 5;
|
||||
// Add notification message to user
|
||||
$userNotification = new Notification;
|
||||
$userNotification->detail = "Your bankslip for booking " . $booking->id . " is approved.";
|
||||
$userNotification->link = "/booking/" . $booking->id . "/supplier";
|
||||
$userNotification->user_id = $booking->user_id;
|
||||
$userNotification->save();
|
||||
// TODO : Add notification message to user
|
||||
|
||||
}
|
||||
$booking->save();
|
||||
|
||||
@@ -981,11 +969,11 @@ class BookingController extends Controller
|
||||
$booking->admin_status = 5; // upload china bankslip
|
||||
|
||||
if($booking->save()){
|
||||
$userNotification = new Notification;
|
||||
$userNotification->detail = "Supplier booking report for booking " . $booking->id . " is completed.";
|
||||
$userNotification->link = "/booking/" . $booking->id . "/transfer";
|
||||
$userNotification->user_id = $booking->user_id;
|
||||
$userNotification->save();
|
||||
// $userNotification = new Notification;
|
||||
// $userNotification->detail = "Supplier booking report for booking " . $booking->id . " is completed.";
|
||||
// $userNotification->link = "/booking/" . $booking->id . "/transfer";
|
||||
// $userNotification->user_id = $booking->user_id;
|
||||
// $userNotification->save();
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
}
|
||||
}
|
||||
@@ -1002,12 +990,6 @@ class BookingController extends Controller
|
||||
$booking->admin_status = 6; // upload invoice
|
||||
$booking->save();
|
||||
|
||||
$adminNotification = new Notification;
|
||||
$adminNotification->detail = "Purchase Order for booking " . $booking->id . " is uploaded.";
|
||||
$adminNotification->link = "/booking/" . $booking->id . "/upload-invoice";
|
||||
$adminNotification->user_id = User::withRole('admin')->first()->id;
|
||||
$adminNotification->save();
|
||||
|
||||
return response()->json($purchase_order,200);
|
||||
}
|
||||
|
||||
@@ -1025,11 +1007,6 @@ class BookingController extends Controller
|
||||
$booking->admin_status = 7; // completed
|
||||
|
||||
if($booking->save()){
|
||||
$adminNotification = new Notification;
|
||||
$adminNotification->detail = "Invoice for booking " . $booking->id . " is uploaded.";
|
||||
$adminNotification->link = "/booking/" . $booking->id . "/complete";
|
||||
$adminNotification->user_id = $booking->user_id;
|
||||
$adminNotification->save();
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
||||
use App\ChinaBankSlip;
|
||||
use App\Booking;
|
||||
use App\User;
|
||||
use App\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Validator;
|
||||
@@ -82,13 +81,6 @@ class ChinaBankSlipController extends Controller
|
||||
$booking->admin_status = 6;
|
||||
$booking->save();
|
||||
|
||||
$userNotification = new Notification;
|
||||
$userNotification->detail = "Your china bankslip for booking " . $booking->id . " is uploaded.";
|
||||
$userNotification->link = "/booking/" . $booking->id . "/upload-po";
|
||||
$userNotification->user_id = $booking->user_id;
|
||||
$userNotification->save();
|
||||
|
||||
|
||||
return response()->json(["message"=> "Success"],200);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Rate;
|
||||
use App\User;
|
||||
use App\Events\RateUpdated;
|
||||
|
||||
class RateObserver
|
||||
{
|
||||
/**
|
||||
* Handle the rate "created" event.
|
||||
*
|
||||
* @param \App\Rate $rate
|
||||
* @return void
|
||||
*/
|
||||
public function created(Rate $rate)
|
||||
{
|
||||
event(new RateUpdated($rate));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace App\Providers;
|
||||
use Laravel\Dusk\DuskServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Observers\RateObserver;
|
||||
use App\Rate;
|
||||
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -21,6 +23,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
*/
|
||||
Rate::observe(RateObserver::class);
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ class BroadcastServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
//Broadcast::routes();
|
||||
Broadcast::routes(["middleware" => ["auth:api"]]);
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user