update sah payment acc

This commit is contained in:
faiqahzaman
2022-03-06 11:31:36 +08:00
parent c3629a736b
commit 31d60c44e7
3 changed files with 73 additions and 57 deletions
+15 -14
View File
@@ -90,12 +90,12 @@ class AccountController extends Controller
}
}
return view('account.sahsagonline', compact('senaraisag', 'user_id', 'lelong_id','total_payment'));
return view('account.sahsagonline', compact('senaraisag', 'lelong_id', 'user_id', 'total_payment'));
}
public function sahbayaronline($lelong_id, $user_id)
public function sahbayaronline(Request $request)
{
// dd($request->all());
$currentdate = Carbon::now();
$currentdate = $currentdate->toDateTimeString();
@@ -103,25 +103,26 @@ class AccountController extends Controller
$senaraisag = LelongBid::join('lelongbidder', 'lelongbid.id', '=', 'lelongbidder.lelongbid_id')
->join('payment', 'lelongbid.id', '=', 'payment.lelongbid_id')
->where('lelongbid.lelong_id', $lelong_id)
->where('lelongbidder.user_id', $user_id)
->where('lelongbid.lelong_id', $request->lelong_id)
->where('lelongbidder.user_id', $request->user_id)
->where('lelongbidder.status_bidder', 1)
->where('payment.status_payment_opt', 2)
->get();
->get();
$total_payment = 0;
foreach($senaraisag as $sag)
{
$payment = Payment::where('lelong_id', $lelong_id)
->where('user_id', $user_id)
$payment = Payment::where('lelong_id', $request->lelong_id)
->where('user_id', $request->user_id)
->where('lelongbid_id',$sag->lelongbid_id)
->first();
$payment->disahkan_oleh = $user->id;
$payment->disahkan_pada = $currentdate;
$payment->save();
$total_payment = $total_payment + $payment->total_payment;
$updatelelbidbidder = LelongBidder::where('lelongbid_id', $sag->lelongbid_id)
->first();
$updatelelbidbidder->status_payment = 1;
@@ -133,14 +134,14 @@ class AccountController extends Controller
$eachbid->save();
}
$senaraisagallpayment = LelongBid::join('lelongbidder', 'lelongbid.id', '=', 'lelongbidder.lelongbid_id')
->where('lelongbid.lelong_id', $lelong_id)
->where('lelongbidder.user_id', $user_id)
->where('lelongbid.lelong_id', $request->lelong_id)
->where('lelongbidder.user_id', $request->user_id)
->where('lelongbidder.status_bidder', 1)
->get();
// dd($senaraisagallpayment);
$resit = Resit::where('id',$payment->resit_id)->first();
$resit = Resit::where('id', $payment->resit_id)->first();
$resit->total_payment = $resit->total_payment + $total_payment;
if($resit->total_payment >= $senaraisagallpayment->sum('hargabida'))
+57 -42
View File
@@ -4,33 +4,32 @@
<div class="container-fluid">
<div class="row ">
<form action="{{ route('account.sahbayaronline') }}" method="POST" id="formsahbayaronline">
@csrf
<input type="hidden" name="lelong_id" value="{{ $lelong_id }}" />
<input type="hidden" name="user_id" value="{{ $user_id }}" />
<div class="col-md-11 mx-auto card p-4">
<div class="col-md-11 mx-auto card p-4">
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
@endif
<table class="table table-striped table-xl text-center" id="tablekaunter" style="width:100%">
<thead class="bg-primary text-white">
<tr>
<th>No</th>
<th>No Rujukan</th>
<th>Tarikh Lelong</th>
<th>Harga Asas (RM)</th>
<th>Harga Bida (RM)</th>
<th>Masa Bidaan</th>
<th class="text-center">Status</th>
</tr>
</thead>
<tbody>
@foreach($senaraisag as $sag)
<form action="{{ route('account.sahbayaronline') }}" method="POST" id="formsahbayaronline">
@csrf
<input type="hidden" name="lelong_id" value="{{ $lelong_id }}" />
<input type="hidden" name="user_id" value="{{ $user_id }}" />
<table class="table table-striped table-xl text-center" id="tablekaunter" style="width:100%">
<thead class="bg-primary text-white">
<tr>
<td> {{ $loop->iteration }} </td>
<th>No</th>
<th>No Rujukan</th>
<th>Tarikh Lelong</th>
<th>Harga Asas (RM)</th>
<th>Harga Bida (RM)</th>
<th>Masa Bidaan</th>
<th class="text-center">Status</th>
</tr>
</thead>
<tbody>
@foreach($senaraisag as $sag)
<tr>
<td> {{ $loop->iteration }} </td>
<td>{{ $sag['norujukan'] }}</td>
<td>{{ $sag['t_lelong'] }}</td>
<td>{{ $sag['hargaasas'] }}</td>
@@ -39,31 +38,47 @@
<td>
<span class="btn btn-success btn-sm hovernone-success" disabled>PAID</span>
</td>
</tr>
@endforeach
</tbody>
</tr>
@endforeach
</tbody>
<tr>
<td colspan="2"><b> Jumlah Bayaran</b></td>
<td colspan="2"></td>
<td colspan="1"><b>RM<input type="text" id="total" value="{{ $total_payment }}" style="border: none;" readonly></b></td>
<td colspan="2"></td>
</tr>
</table>
<div class="modal-footer" style="margin-top:2%;">
<a href="{{ route('account.senarailelongan') }}" class="btn btn-primary">Kembali</a>
<!-- <a href="{{ route('account.sahbayaronline', ['lelong_id'=>$lelong_id, 'user_id'=>$user_id]) }}" class="btn btn-warning">Sahkan</a> -->
<button type="button" class="btn btn-warning" onclick="confirm()" >Sahkan</button>
</div>
</form>
<tr>
<td colspan="2"><b> Jumlah Bayaran</b></td>
<td colspan="2"></td>
<td colspan="1"><b>RM<input type="text" id="total" value="{{ $total_payment }}" style="border: none;" readonly></b></td>
<td colspan="2"></td>
</tr>
</table>
<div class="modal-footer" style="margin-top:2%;">
<a href="{{ route('account.senarailelongan') }}" class="btn btn-primary">Kembali</a>
<a href="{{ route('account.sahbayaronline', ['lelong_id'=>$lelong_id, 'user_id'=>$user_id]) }}" class="btn btn-warning">Sahkan</a>
<button type="button" class="btn btn-warning" onclick="sahbayaronline()" >Sahkan</button>
</div>
</div>
</form>
</div>
</div>
<script>
function sahbayaronline() {
$("#formsahbayaronline").submit();
function confirm() {
$.confirm({
title: 'Confirmation',
content: 'Anda pasti?',
type: 'orange',
typeAnimated: true,
buttons: {
Simpan: {
btnClass: 'btn-warning',
action: function () {
$("#formsahbayaronline").submit();
}
},
Batal: {
btnClass: 'btn-default',
action: function () {}
}
}
});
}
var tablekaunter = $('#tablekaunter').DataTable({
"columnDefs": [
+1 -1
View File
@@ -167,7 +167,7 @@ Route::group(['middleware' => ['permission:pengesahanbayaran'],'prefix'=>'accoun
Route::get('/senarailelongan', ['as'=>'account.senarailelongan','uses'=>'AccountController@senarailelongan']);
Route::get('/listbayaranonline/{lelong_id}', ['as'=>'account.listbayaranonline','uses'=>'AccountController@listbayaranonline']);
Route::get('/sahsagonline/{lelong_id}/{user_id}', ['as'=>'account.sahsagonline','uses'=>'AccountController@sahsagonline']);
Route::get('/sahbayaronline/{lelong_id}/{user_id}', ['as'=>'account.sahbayaronline','uses'=>'AccountController@sahbayaronline']);
Route::post('/sahbayaronline', ['as'=>'account.sahbayaronline','uses'=>'AccountController@sahbayaronline']);
});
// Account