added function operasi can edit perubatan asal

This commit is contained in:
hafifierahman
2024-11-10 22:31:55 +08:00
parent c4388321aa
commit f59e0a4d4e
5 changed files with 76 additions and 9 deletions
+4 -4
View File
@@ -739,7 +739,7 @@ class KhazanahController extends Controller
$request->merge(['kodlaluan' => $auth_user['name']]);
$data_request = $request->except('_token');
$updatepanjar = Http::withOptions(['verify' => config('app.api_verify')])->post( config('api.url') .'/api/test/createpanjar/'. $auth_user['cawangan'],$data_request)->json();
$updatepanjar = Http::withOptions(['verify' => config('app.api_verify')])->post( config('api.url') .'/api/panjar/createpanjar/'. $auth_user['cawangan'],$data_request)->json();
if($updatepanjar['result'] == 'success')
{
@@ -773,7 +773,7 @@ class KhazanahController extends Controller
$request->merge(['kodlaluan' => $auth_user['name']]);
$data_request = $request->except('_token');
$updatepanjar = Http::withOptions(['verify' => config('app.api_verify')])->post( config('api.url') .'/api/test/deletepanjar/'. $auth_user['cawangan'],$data_request)->json();
$updatepanjar = Http::withOptions(['verify' => config('app.api_verify')])->post( config('api.url') .'/api/panjar/deletepanjar/'. $auth_user['cawangan'],$data_request)->json();
if($updatepanjar['result'] == 'success')
{
@@ -1062,7 +1062,7 @@ class KhazanahController extends Controller
}
else{
$response_data = $request->except('_token');
$test = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/test/updatetunai/'.$auth_user['cawangan'],$response_data)->json();
$test = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/panjar/updatetunai/'.$auth_user['cawangan'],$response_data)->json();
if($test == 'success'){
event(new PendahuluanSerahan("Lulus","pendahuluan",$auth_user['cawangan'],$request->teller));
@@ -1087,7 +1087,7 @@ class KhazanahController extends Controller
$peti_besi_terkini=Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/daftarVault/'.$auth_user['cawangan'])->json();
}
$response_data = $request->except('_token');
$test = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/test/serahantunai/'.$auth_user['cawangan'],$response_data)->json();
$test = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url').'/api/panjar/serahantunai/'.$auth_user['cawangan'],$response_data)->json();
if($test == 'success'){
event(new PendahuluanSerahan("Lulus","serahan",$auth_user['cawangan'],$request->teller));
@@ -43,4 +43,24 @@ class PerubatanController extends Controller
return view('operasi.perubatan.index',compact('cawangan_info','api_url','auth_user','paginate'));
}
public function update(Request $request){
$api_url = config('api.url');
$auth_user = Auth::user();
$user = User::where('id', $request->id)->first();
$user = optional($user)->toArray();
$amount = str_replace(',', '', $request->amount);
$total_perubatan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/panjar/getperubatan/'. $user['cawangan'],[
'tuntutoleh' => $user['name']
])->json();
$remaining = floatval($amount) - floatval($total_perubatan);
$response = User::where('id', $request->id)->update(['perubatan_asal' => $amount,'perubatan' => $remaining]);
return $response;
}
}
+45
View File
@@ -17,6 +17,51 @@ let editfunc = (pageid) => {
}
let savefunc = (pageid) => {
let amount = document.getElementById("input-" + pageid);
Swal.fire({
title: 'Memuatkan...',
allowEscapeKey : false,
allowOutsideClick: false,
didOpen: function () {
Swal.showLoading();
}
});
$.ajax({
url : updateurl,
method : 'PUT',
data : {
"amount" : amount.value,
"id" : pageid,
"_token": $('meta[name="csrf-token"]').attr('content')
},
success:function(response){
if(response == 0){
Swal.fire({
icon: 'error',
title: 'Perubahan Nilai Perubatan Tidak Berjaya!',
});
return false;
}
Swal.fire({
icon: 'success',
title: 'Perubahan Nilai Perubatan Berjaya!',
showCancelButton: false,
confirmButtonText: "Okay!",
allowEscapeKey: false,
allowOutsideClick: false
}).then((result) => {
if (result.isConfirmed) {
window.location.reload();
}
});
}
});
// let editbtn = document.getElementById('editButton-' + pageid);
// let divbtn = document.getElementById('div-' + pageid);
@@ -26,7 +26,7 @@
<th scope="col">#</th>
<th scope="col">Nama</th>
<th scope="col">Baki Perubatan</th>
<th scope="col">Perubatan</th>
<th scope="col" style="width:15%;">Perubatan</th>
<th scope="col">Tindakan</th>
</tr>
</thead>
@@ -35,9 +35,9 @@
<tr>
<td>{{ ($paginate->currentPage() - 1) * $paginate->perPage() + $loop->index + 1 }}</td>
<td scope="col">{{ $page->name }}</td>
<td scope="col">{{ $page->perubatan }}</td>
<td scope="col">{{ number_format($page->perubatan,2) }}</td>
<td scope="col">
<input name="perubatan" id="input-{{ $page->id }}" class="" value="{{ $page->perubatan_asal }}" disabled/>
<input name="perubatan" id="input-{{ $page->id }}" class="form-control" value="{{ $page->perubatan_asal }}" disabled/>
</td>
<td>
<div id="divedit-{{ $page->id }}" class="d-block">
@@ -63,5 +63,8 @@
</div>
</div>
</div>
<script>
let updateurl = "{{ route('perubatan.update') }}";
</script>
<script src="{{ asset('js/perubatan.js') }}"></script>
@endsection
+1 -2
View File
@@ -479,5 +479,4 @@ Route::get('/event/tellercash',['as'=>'event.tellercash','uses'=>'EventTriggerCo
/* Perubatan */
Route::get('/perubatan',['as'=>'perubatan','uses'=>'PerubatanController@index'])->middleware('auth','operasi');
Route::get('/perubatan/search',['as'=>'perubatan.search','uses'=>'PerubatanController@search'])->middleware('auth','operasi');
Route::put('/perubatan/update',['as'=>'perubatan.update','uses'=>'PerubatanController@update'])->middleware('auth','operasi');