mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
added relantionship in chinabankslip model
added update chinabankslip feature
This commit is contained in:
@@ -36,6 +36,10 @@ class Booking extends Model
|
||||
return $this->belongsTo('app\BookingSupplier ');
|
||||
}
|
||||
|
||||
public function chinaBankSlip(){
|
||||
return $this->hasOne(ChinaBankSlip::class);
|
||||
}
|
||||
|
||||
public function userBankSlip(){
|
||||
return $this->hasOne(UserBankSlip::class);
|
||||
}
|
||||
|
||||
@@ -7,4 +7,9 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class ChinaBankSlip extends Model
|
||||
{
|
||||
protected $fillable = ['actual_transfer_amount','date','details','china_bank_slip_path'];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,4 +62,26 @@ class ChinaBankSlipController extends Controller
|
||||
return response()->json(['message'=>'success'], 201);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id){
|
||||
$booking = Booking::where('id',$id)->first();
|
||||
$china_bankslip = $booking->chinaBankSlip()->first();
|
||||
|
||||
// TODO: first or fail
|
||||
if(!$china_bankslip){
|
||||
return response()->json(["message"=> "not found"],400);
|
||||
}
|
||||
|
||||
$china_bankslip->actual_transfer_amount = $request->input('actual_transfer_amount');
|
||||
$china_bankslip->date = $request->input('date');
|
||||
$china_bankslip->details = $request->input('details');
|
||||
$china_bankslip->save();
|
||||
|
||||
// update booking status
|
||||
$booking->status = 5;
|
||||
$booking->admin_status = 6;
|
||||
$booking->save();
|
||||
|
||||
return response()->json(["message"=> "Success"],200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -205,17 +205,12 @@
|
||||
<div align="center">
|
||||
|
||||
<!-- upload image -->
|
||||
<el-upload class="upload-demo" :action="'/api/booking/' + booking_id + '/upload-china-bankslip'"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove"
|
||||
:multiple="false"
|
||||
list-type="picture">
|
||||
<el-upload class="upload-demo" :action="'/api/booking/' + booking_id + '/upload-china-bankslip'" :on-preview="handlePreview"
|
||||
:on-remove="handleRemove" :multiple="false" list-type="picture">
|
||||
<el-button size="small" type="primary">Click to upload</el-button>
|
||||
<div slot="tip" class="el-upload__tip">jpg/png files with a size less than 3mb</div>
|
||||
</el-upload>
|
||||
<el-dialog :visible.sync="dialogVisible">
|
||||
<img :src="dialogImageUrl" width="100%" alt="">
|
||||
</el-dialog>
|
||||
|
||||
<br>
|
||||
<!-- upload image end -->
|
||||
<el-form-item prop="date">
|
||||
@@ -230,7 +225,7 @@
|
||||
<el-input v-model="chinaSlipForm.details" type="text" placeholder="Details" style="width: 80%" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button :loading="loading_btn" type="primary" @click="submitcChinaSlip('chinaSlipForm')">Submit</el-button>
|
||||
<el-button :loading="loading_btn" type="primary" @click="submitChinaSlip('chinaSlipForm')">Submit</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
@@ -284,7 +279,7 @@
|
||||
}],
|
||||
details: [{
|
||||
required: true,
|
||||
message: 'Please input account name',
|
||||
message: 'Please input details',
|
||||
trigger: 'change'
|
||||
}]
|
||||
},
|
||||
@@ -351,39 +346,40 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
submitcChinaSlip(formName) {
|
||||
submitChinaSlip(formName) {
|
||||
this.loading_btn = true
|
||||
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
let newReport = {
|
||||
booking_id: this.$route.params.id,
|
||||
supplier_id: this.supplierBookingForm.supplier,
|
||||
amount: this.supplierBookingForm.amount,
|
||||
rebate: this.supplierBookingForm.rebate,
|
||||
rate: this.supplierBookingForm.rate,
|
||||
transfer_amount: this.supplierBookingForm.transfer_amount,
|
||||
let newChinaSlip = {
|
||||
date: this.chinaSlipForm.date,
|
||||
actual_transfer_amount: this.chinaSlipForm.actual_transfer_amount,
|
||||
details: this.chinaSlipForm.details,
|
||||
}
|
||||
|
||||
axios.post('/api/supplier-booking', newReport)
|
||||
axios.patch('/api/booking/' + this.booking_id + '/upload-china-slip', newChinaSlip)
|
||||
.then((response) => {
|
||||
this.loading_btn = false
|
||||
|
||||
this.$router.push({
|
||||
name: 'booking.admin.supplier.report',
|
||||
params: {
|
||||
id: this.$route.params.id
|
||||
}
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: 'Your bankinslip has been submitted, please wait admin to approve.',
|
||||
type: 'success',
|
||||
duration: 5000
|
||||
})
|
||||
// redirect to supplier report
|
||||
|
||||
console.log(response)
|
||||
this.$router.push({
|
||||
name: 'home'
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading_btn = false
|
||||
this.loading = false
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: 'Please upload your bankin slip first.',
|
||||
type: 'warning',
|
||||
duration: 10000
|
||||
})
|
||||
console.log(error)
|
||||
|
||||
// TODO : Show error message
|
||||
|
||||
})
|
||||
|
||||
} else {
|
||||
@@ -391,6 +387,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
console.log(file, fileList);
|
||||
|
||||
@@ -102,6 +102,7 @@ Route::group(['middleware' => ['role:admin']], function() {
|
||||
Route::put('supplier-booking/{id}', 'BookingSupplierController@update');
|
||||
|
||||
Route::post('/booking/{id}/upload-china-bankslip','ChinaBankSlipController@store');
|
||||
Route::patch('/booking/{id}/upload-china-bankslip','ChinaBankSlipController@update');
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user