mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
create notification for each step done. Make unread message bold.
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Invoice;
|
||||
use App\SettingCredit;
|
||||
use App\SettingTaxRate;
|
||||
use App\SettingBillingCharge;
|
||||
use App\Notification;
|
||||
use Auth;
|
||||
use Validator;
|
||||
use DateTime;
|
||||
@@ -447,9 +448,16 @@ 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(["message"=> "Success"],200);
|
||||
return response()->json($adminNotification,200);
|
||||
}
|
||||
|
||||
public function uploadPurchaseOrder(Request $request, $id)
|
||||
@@ -559,7 +567,6 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
switch ($term) {
|
||||
case "x1_cash":
|
||||
@@ -647,11 +654,26 @@ class BookingController extends Controller
|
||||
|
||||
// update booking status
|
||||
$booking->status = 4;
|
||||
if($booking->term !== "x1_ba" || $booking->term !== "x2_cheque")
|
||||
if($booking->term !== "x1_ba" || $booking->term !== "x2_cheque"){
|
||||
$booking->admin_status = 3;
|
||||
else
|
||||
// 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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
$booking->save();
|
||||
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
@@ -747,6 +769,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();
|
||||
return response()->json(['message'=>"Success"],200);
|
||||
}
|
||||
}
|
||||
@@ -755,16 +782,21 @@ class BookingController extends Controller
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
|
||||
$purchase_order = $booking->purchaseOrder()->first();
|
||||
return($purchase_order);
|
||||
|
||||
if(!$purchase_order){
|
||||
return response()->json(["message"=> "Please upload your purchase order"],400);
|
||||
}
|
||||
|
||||
$booking->status = 6; // wait invoice
|
||||
$booking->admin_status = 6; // upload invoice
|
||||
$booking->save();
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
public function confirmInvoice(Request $request, $id)
|
||||
@@ -781,6 +813,11 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ 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;
|
||||
@@ -80,6 +82,13 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class NotificationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return Notification::all();
|
||||
return Notification::all()->orderby('updated_at','desc');
|
||||
}
|
||||
|
||||
public function show(Notification $notification)
|
||||
@@ -43,11 +43,11 @@ class NotificationController extends Controller
|
||||
public function getUserMessage()
|
||||
{
|
||||
return response()->json([
|
||||
"message" =>Notification::Where("user_id",Auth::user()->id)->get(),
|
||||
"message" =>Notification::Where("user_id",Auth::user()->id)->orderby('updated_at','desc')->get(),
|
||||
"unread_message" =>Notification::Where([
|
||||
["user_id",Auth::user()->id],
|
||||
["is_read",0]
|
||||
])->get()
|
||||
])->orderby('updated_at','desc')->get()
|
||||
],200);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,19 @@
|
||||
<!-- Authenticated -->
|
||||
<template v-if="user">
|
||||
<el-dropdown trigger="click">
|
||||
<el-badge :value="unreadMessage.length > 0 ? unreadMessage.length : ''" class="item">
|
||||
<el-badge :value="unread_message.length > 0 ? unread_message.length : ''" class="item">
|
||||
<el-button v-if="loadingNotification" icon="el-icon-loading" circle ></el-button>
|
||||
<el-button v-else icon="el-icon-bell" circle v-on:click="refreshNotificatoin"></el-button>
|
||||
</el-badge>
|
||||
<el-dropdown-menu slot="dropdown" style="max-width: 30%" id="notification" >
|
||||
<a v-for="item in notification" :href="item.link">
|
||||
<el-dropdown-menu slot="dropdown" id="notification">
|
||||
<a v-for="(item,index) in notification" :href="item.link">
|
||||
<el-dropdown-item>
|
||||
{{item.detail}}
|
||||
<b v-if="index < unread_message_length">
|
||||
{{item.detail}}
|
||||
</b>
|
||||
<span v-else>
|
||||
{{item.detail}}
|
||||
</span>
|
||||
</el-dropdown-item>
|
||||
</a>
|
||||
</el-dropdown-menu>
|
||||
@@ -85,7 +90,8 @@ export default {
|
||||
appName: window.config.appName,
|
||||
notification:[],
|
||||
loadingNotification:false,
|
||||
unreadMessage:null
|
||||
unread_message:null,
|
||||
unread_message_length:0,
|
||||
|
||||
}),
|
||||
|
||||
@@ -105,14 +111,16 @@ export default {
|
||||
},
|
||||
getNotification(){
|
||||
this.notification = [];
|
||||
this.unreadMessage='';
|
||||
this.unread_message='';
|
||||
this.loadingNotification=true;
|
||||
axios
|
||||
.get('/api/notification/user/')
|
||||
.then((response) => {
|
||||
this.loadingNotification=false;
|
||||
this.notification = response.data.message;
|
||||
this.unreadMessage=response.data.unread_message;
|
||||
this.unread_message=response.data.unread_message;
|
||||
this.unread_message_length=this.unread_message.length;
|
||||
console.log(this.unread_message_length);
|
||||
console.log(response.data);
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
@@ -122,8 +130,8 @@ export default {
|
||||
})
|
||||
},
|
||||
refreshNotificatoin(){
|
||||
this.readAllNotification();
|
||||
this.getNotification();
|
||||
this.readAllNotification();
|
||||
},
|
||||
readAllNotification(){
|
||||
axios
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
<el-button :loading="loading_btn" type="primary" size="mini" @click="RefreshBooking()">Refresh</el-button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Booking Table -->
|
||||
<el-row :gutter="20">
|
||||
<div>
|
||||
@@ -81,9 +79,9 @@ export default {
|
||||
getBooking(){
|
||||
let $this = this
|
||||
axios.get(this.url).then(response => {
|
||||
this.bookingTable = response.data.data
|
||||
$this.makePagination(response.data)
|
||||
console.log(response)
|
||||
this.bookingTable = response.data.data;
|
||||
$this.makePagination(this.bookingTable);
|
||||
console.log(response.data.data);
|
||||
})
|
||||
},
|
||||
RefreshBooking() {
|
||||
|
||||
@@ -267,8 +267,10 @@ export default {
|
||||
let newUserSlip = {
|
||||
transfer_amount: this.user_slip_form.transfer_amount
|
||||
}
|
||||
axios.patch('/api/booking/' + this.booking_id + '/bankslip-amount', newUserSlip)
|
||||
axios.patch('/api/booking/' + this.booking_id + '/bankslip-amount/', newUserSlip)
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: 'Your bankinslip has been submitted, please wait admin to approve.',
|
||||
@@ -279,6 +281,7 @@ export default {
|
||||
this.$router.push({
|
||||
name: 'home'
|
||||
})
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading = false
|
||||
|
||||
@@ -141,19 +141,19 @@
|
||||
|
||||
<!-- Form_popup -->
|
||||
<el-dialog :visible.sync="dialogFormVisible" :fullscreen="true" title="Booking" center>
|
||||
<el-form ref="bookingForm" :model="bookingForm[0]" :rules="rules">
|
||||
<el-form ref="bookingForm" :model="bookingForm" :rules="rules">
|
||||
<div align="center">
|
||||
<el-form-item prop="account_name">
|
||||
<el-input v-model="bookingForm[0].account_name" placeholder="China Beneficiary Account" style="width: 80%" required="true" />
|
||||
<el-input v-model="bookingForm.account_name" placeholder="China Beneficiary Account" style="width: 80%" required="true" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="bank_name">
|
||||
<el-input v-model="bookingForm[0].bank_name" type="text" placeholder="Bank Name / AliPay / WechatPay" style="width: 80%" />
|
||||
<el-input v-model="bookingForm.bank_name" type="text" placeholder="Bank Name / AliPay / WechatPay" style="width: 80%" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="bank_branch">
|
||||
<el-input v-model="bookingForm[0].bank_branch" type="text" placeholder="Branch / 分行/支行" style="width: 80%" />
|
||||
<el-input v-model="bookingForm.bank_branch" type="text" placeholder="Branch / 分行/支行" style="width: 80%" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="account_num">
|
||||
<el-input v-model="bookingForm[0].account_num" type="text" placeholder="Account Number / AliPay_ID / WechatPay_ID" style="width: 80%"
|
||||
<el-input v-model="bookingForm.account_num" type="text" placeholder="Account Number / AliPay_ID / WechatPay_ID" style="width: 80%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@@ -367,12 +367,12 @@ export default {
|
||||
amount: '',
|
||||
rate: ''
|
||||
},
|
||||
bookingForm: [{
|
||||
bookingForm: {
|
||||
account_name: '',
|
||||
bank_name: '',
|
||||
bank_branch: '',
|
||||
account_num: ''
|
||||
}],
|
||||
},
|
||||
rules: {
|
||||
amount: [{
|
||||
required: true,
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ Route::group(['middleware' => 'auth:api'], function () {
|
||||
Route::post('booking/{book_id}/reject-bank-slip','BookingController@rejectBankSlip');
|
||||
Route::post('booking/{book_id}/approve-bank-slip','BookingController@approveBankSlip');
|
||||
Route::post('booking/{book_id}/cancel', 'BookingController@cancel');
|
||||
Route::get('/booking', 'BookingController@index');
|
||||
Route::get('booking', 'BookingController@index');
|
||||
Route::get('user', 'UserController@show');
|
||||
Route::patch('settings/profile', 'Settings\ProfileController@update');
|
||||
Route::patch('settings/password', 'Settings\PasswordController@update');
|
||||
|
||||
Reference in New Issue
Block a user