update validasi signer
This commit is contained in:
@ -34,6 +34,7 @@
|
|||||||
use Modules\Konfirmasibank\Http\Requests\Fasilitas\StoreFasilitasRequest;
|
use Modules\Konfirmasibank\Http\Requests\Fasilitas\StoreFasilitasRequest;
|
||||||
use Akaunting\Money\Currency;
|
use Akaunting\Money\Currency;
|
||||||
use Akaunting\Money\Money;
|
use Akaunting\Money\Money;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class KonfirmasiBankController extends Controller
|
class KonfirmasiBankController extends Controller
|
||||||
{
|
{
|
||||||
@ -227,44 +228,64 @@
|
|||||||
return $formattedAmount;
|
return $formattedAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postSigner(Request $request){
|
public function postSigner(Request $request)
|
||||||
|
{
|
||||||
if (is_null($this->user) || !$this->user->can('konfirmasibank.create')) {
|
if (is_null($this->user) || !$this->user->can('konfirmasibank.create')) {
|
||||||
abort(403, 'Sorry !! You are Unauthorized to create any konfirmasibank.create !');
|
abort(403, 'Maaf!! Anda tidak memiliki otorisasi untuk membuat konfirmasi bank.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$messages = [
|
||||||
|
'deputy_director.required' => 'Nama Deputy Director wajib diisi.',
|
||||||
|
'deputy_director.string' => 'Nama Deputy Director harus berupa teks.',
|
||||||
|
'deputy_director.unique' => 'Nama Deputy Director sudah terdaftar.',
|
||||||
|
'deputy_director.regex' => 'Nama Deputy Director tidak boleh mengandung angka.',
|
||||||
|
'executive_officer.required' => 'Nama Executive Officer wajib diisi.',
|
||||||
|
'executive_officer.string' => 'Nama Executive Officer harus berupa teks.',
|
||||||
|
'executive_officer.unique' => 'Nama Executive Officer sudah terdaftar.',
|
||||||
|
'executive_officer.regex' => 'Nama Executive Officer tidak boleh mengandung angka.',
|
||||||
|
'signer_type.required' => 'Tipe penandatangan wajib diisi.',
|
||||||
|
'signer_type.string' => 'Tipe penandatangan harus berupa teks.',
|
||||||
|
];
|
||||||
|
|
||||||
$currentDate = Carbon::now();
|
$request->validate([
|
||||||
$validated = $request->validate([
|
'deputy_director' => [
|
||||||
'deputy_director' => 'required|string',
|
'required',
|
||||||
'executive_officer' => 'required|string',
|
'string',
|
||||||
|
'unique:signers,deputy_director_name',
|
||||||
|
'regex:/^[a-zA-Z\s]*$/',
|
||||||
|
function($attribute, $value, $fail) use ($request) {
|
||||||
|
if ($value === $request->executive_officer) {
|
||||||
|
$fail('Nama Deputy Director tidak boleh sama dengan nama Executive Officer.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'executive_officer' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'unique:signers,executive_officer_name',
|
||||||
|
'regex:/^[a-zA-Z\s]*$/'
|
||||||
|
],
|
||||||
'signer_type' => 'required|string'
|
'signer_type' => 'required|string'
|
||||||
]);
|
], $messages);
|
||||||
|
|
||||||
if ($validated) {
|
try {
|
||||||
try {
|
// Membuat instance baru dari Signer
|
||||||
// Create New User
|
|
||||||
$signer = new Signer();
|
$signer = new Signer();
|
||||||
$signer->deputy_director_name = $request->deputy_director;
|
$signer->deputy_director_name = $request->deputy_director;
|
||||||
$signer->executive_officer_name = $request->executive_officer;
|
$signer->executive_officer_name = $request->executive_officer;
|
||||||
$signer->signer_type = $request->signer_type;
|
$signer->signer_type = $request->signer_type;
|
||||||
$signer->created_at = $currentDate;
|
$signer->created_at = Carbon::now();
|
||||||
$signer->status = 1;
|
$signer->status = 1;
|
||||||
$signer->save();
|
$signer->save();
|
||||||
// return redirect()->route('konfirmasibank.addFasilitas')->with('success', 'Data berhasil ditambahkan');
|
|
||||||
echo json_encode(['status' => 'success', 'message' => ' Add signer successfully .']);
|
|
||||||
|
|
||||||
|
return response()->json(['status' => 'success', 'message' => 'Penandatangan berhasil ditambahkan.']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return json_encode([
|
return response()->json([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => $e->getMessage()
|
'message' => $e->getMessage()
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
@ -286,45 +307,63 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function updateSigner(Request $request)
|
public function updateSigner(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (is_null($this->user) || !$this->user->can('konfirmasibank.update')) {
|
if (is_null($this->user) || !$this->user->can('konfirmasibank.update')) {
|
||||||
abort(403, 'Sorry !! You are Unauthorized to edit any role !');
|
abort(403, 'Maaf!! Anda tidak memiliki otorisasi untuk mengupdate konfirmasi bank.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$today = Carbon::now();
|
$signer = Signer::findOrFail($request->id);
|
||||||
|
|
||||||
$validator = Validator::make($request->all(), [
|
$messages = [
|
||||||
'deputy_director' => 'required|string',
|
'deputy_director.required' => 'Nama Deputy Director wajib diisi.',
|
||||||
'executive_officer' => 'required|string',
|
'deputy_director.string' => 'Nama Deputy Director harus berupa teks.',
|
||||||
'signer_type' => 'required|string'
|
'deputy_director.unique' => 'Nama Deputy Director sudah terdaftar.',
|
||||||
]);
|
'deputy_director.regex' => 'Nama Deputy Director tidak boleh mengandung angka.',
|
||||||
|
'executive_officer.required' => 'Nama Executive Officer wajib diisi.',
|
||||||
|
'executive_officer.string' => 'Nama Executive Officer harus berupa teks.',
|
||||||
|
'executive_officer.unique' => 'Nama Executive Officer sudah terdaftar.',
|
||||||
|
'executive_officer.regex' => 'Nama Executive Officer tidak boleh mengandung angka.',
|
||||||
|
'signer_type.required' => 'Tipe penandatangan wajib diisi.',
|
||||||
|
'signer_type.string' => 'Tipe penandatangan harus berupa teks.',
|
||||||
|
];
|
||||||
|
|
||||||
if ($validator->fails()) {
|
$request->validate([
|
||||||
return response()->json(['errors' => $validator->errors()], 422); // Return validation errors as JSON
|
'deputy_director' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
// Rule::unique('signers', 'deputy_director_name')->ignore($signer->id),
|
||||||
|
'regex:/^[a-zA-Z\s]*$/',
|
||||||
|
function($attribute, $value, $fail) use ($request) {
|
||||||
|
if ($value === $request->executive_officer) {
|
||||||
|
$fail('Nama Deputy Director tidak boleh sama dengan nama Executive Officer.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'executive_officer' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
// Rule::unique('signers', 'executive_officer_name')->ignore($signer->id),
|
||||||
|
'regex:/^[a-zA-Z\s]*$/'
|
||||||
|
],
|
||||||
|
'signer_type' => 'required|string'
|
||||||
|
], $messages);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$signer->deputy_director_name = $request->deputy_director;
|
||||||
|
$signer->executive_officer_name = $request->executive_officer;
|
||||||
|
$signer->signer_type = $request->signer_type;
|
||||||
|
$signer->updated_at = Carbon::now();
|
||||||
|
$signer->save();
|
||||||
|
|
||||||
|
return response()->json(['status' => 'success', 'message' => 'Penandatangan berhasil diperbarui.']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($validator) {
|
|
||||||
try {
|
|
||||||
$signer = Signer::findOrFail($request->id);
|
|
||||||
$signer->deputy_director_name = $request->deputy_director;
|
|
||||||
$signer->executive_officer_name = $request->executive_officer;
|
|
||||||
$signer->signer_type = $request->signer_type;
|
|
||||||
$signer->updated_at = $today;
|
|
||||||
$signer->save();
|
|
||||||
|
|
||||||
echo json_encode(['status' => 'success', 'message' => ' signer updated successfully.']);
|
|
||||||
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo json_encode(['status' => 'error', 'message' => ' signer updated failed.']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
echo json_encode(['status' => 'error', 'message' => ' signer updated failed.']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function export(Request $request){
|
public function export(Request $request){
|
||||||
@ -337,12 +376,17 @@
|
|||||||
$DataPinjaman = [];
|
$DataPinjaman = [];
|
||||||
$DataFasilitas = [];
|
$DataFasilitas = [];
|
||||||
$DataRK = [];
|
$DataRK = [];
|
||||||
|
$Accounts = [];
|
||||||
// dd($listAccount);
|
// dd($listAccount);
|
||||||
$GetCustomer = $Account->getCustomer($request['cusNo'])->first();
|
$GetCustomer = $Account->getCustomer($request['cusNo'])->first();
|
||||||
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore )->get();
|
$listAccount = $Account->getAccount($request['cusNo'], $arrAccount, $dateCore )->get();
|
||||||
|
//dd( $listAccount);
|
||||||
|
|
||||||
foreach ($listAccount as $key1 => $account) {
|
foreach ($listAccount as $key1 => $account) {
|
||||||
$dataAADepo = $Account->getAA($request['cusNo'],$account->ACCOUNT_NUMBER, $dateCore)->first();
|
$dataAADepo = $Account->getAA($request['cusNo'],$account->ACCOUNT_NUMBER, $dateCore)->first();
|
||||||
|
array_push($Accounts, $account->ACCOUNT_NUMBER);
|
||||||
|
|
||||||
|
// $AccountAnjak = $Account->getAccountAnjak($request['cusNo'], $dateCore )->first();
|
||||||
|
|
||||||
if ($account->CATEGORY == '6603' || $account->CATEGORY == '6602') {
|
if ($account->CATEGORY == '6603' || $account->CATEGORY == '6602') {
|
||||||
if ($dataAADepo != null) {
|
if ($dataAADepo != null) {
|
||||||
@ -383,6 +427,11 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $string = implode(", ", $Accounts);
|
||||||
|
|
||||||
|
// dd($string );
|
||||||
|
// $DataAnjak = $Account->getAccountAnjak($Accounts, $dateCore)->get();
|
||||||
|
// dd($DataAnjak );
|
||||||
$Arrangement = $Account->getPinjaman($request['cusNo'], $dateCore)->get();
|
$Arrangement = $Account->getPinjaman($request['cusNo'], $dateCore)->get();
|
||||||
|
|
||||||
foreach ($Arrangement as $key2 => $pinjaman) {
|
foreach ($Arrangement as $key2 => $pinjaman) {
|
||||||
@ -402,6 +451,8 @@
|
|||||||
|
|
||||||
$listAccountRK = $Account->getAccountRK($request['cusNo'], $dateCore )->get();
|
$listAccountRK = $Account->getAccountRK($request['cusNo'], $dateCore )->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($listAccountRK as $rk => $valRk) {
|
foreach ($listAccountRK as $rk => $valRk) {
|
||||||
if ( $valRk->CATEGORY == '1003') {
|
if ( $valRk->CATEGORY == '1003') {
|
||||||
$rateRK = "";
|
$rateRK = "";
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="inputName" class="col-sm-4 col-form-label">Executive Officer</label>
|
<label for="inputName" class="col-sm-4 col-form-label">Executive Officer</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="text" class="form-control form-control-sm " id="executive_officer" name="executive_officer" placeholder="Nama Executive Officer" id="executive_officer" >
|
<input type="text" class="form-control form-control-sm " name="executive_officer" placeholder="Nama Executive Officer" id="executive_officer" >
|
||||||
<span class="note" style="color:darkred;display:none" ><small>Nama Tidak Boleh Sama .. !</small></span>
|
<span class="note" style="color:darkred;display:none" ><small>Nama Tidak Boleh Sama .. !</small></span>
|
||||||
<span class="noteEx" style="color:darkred;display:none" ><small>Nama Hanya Boleh Huruf.. !</small></span>
|
<span class="noteEx" style="color:darkred;display:none" ><small>Nama Hanya Boleh Huruf.. !</small></span>
|
||||||
</div>
|
</div>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary btn-sm closeButtonSigner"
|
<button type="button" class="btn btn-secondary btn-sm closeButtonSigner"
|
||||||
data-dismiss="modal">Close</button>
|
data-dismiss="modal">Close</button>
|
||||||
<button type="button" class="btn btn-primary btn-sm" id="submitSigner">Submit</button>
|
<button type="button" class="btn btn-primary btn-sm submitSigner" id="submitSigner">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -152,128 +152,70 @@
|
|||||||
$("#myModalEditSigner").modal("hide");
|
$("#myModalEditSigner").modal("hide");
|
||||||
});
|
});
|
||||||
|
|
||||||
// $('#executive_officer').on('keyup', function() {
|
|
||||||
// let deputy_eirector = $('input[name="deputy_director"]').val();
|
|
||||||
// let executive_officer = $(this).val();
|
|
||||||
// var value = $(this).val();
|
|
||||||
// // var valid = /^[A-Za-z ]+$/.test(value);
|
|
||||||
|
|
||||||
// // if (!valid) {
|
// $('input[name="deputy_director"]').on('input', function() {
|
||||||
// // $(this).css('border-color', 'red'); // Ubah warna border menjadi merah jika input tidak valid
|
// let executive_officer = $('input[name="executive_officer"]').val();
|
||||||
// // $('#submitSigner, #submitFormUpdateSigner').prop('disabled', true); // Non-aktifkan tombol submit
|
// var deputy_eirector = $(this).val();
|
||||||
// // alert('Input hanya boleh berisi huruf.');
|
// var valid = /^[A-Za-z ]+$/.test(deputy_eirector);
|
||||||
// // } else {
|
|
||||||
// // $(this).css('border-color', ''); // Kembalikan warna border
|
|
||||||
// // $('#submitSigner, #submitFormUpdateSigner').prop('disabled', false); // Aktifkan tombol submit
|
|
||||||
// // }
|
|
||||||
// if (executive_officer == deputy_eirector ) {
|
|
||||||
// // alert('Penandatangan Tidak Boleh Sama');
|
|
||||||
// $('#executive_officer').css('border-color', 'red');
|
|
||||||
// $('#submitSigner').attr('disabled', 'disabled');
|
|
||||||
// $('#note').show();
|
|
||||||
// }else{
|
|
||||||
// $('#executive_officer').css('border-color', '');
|
|
||||||
// $('#submitSigner').attr('disabled', false);
|
|
||||||
// $('#note').hide();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// $('#executive_officer2').on('keyup', function() {
|
// if (!valid) {
|
||||||
// let deputy_eirector = $('input[name="deputy_director"]').val().toUpperCase();
|
// $(this).css('border-color', 'red'); // Ubah warna border menjadi merah jika input tidak valid
|
||||||
// let executive_officer = $(this).val();
|
// $('#submitSigner, #submitFormUpdateSigner').prop('disabled', true); // Non-aktifkan tombol submit
|
||||||
// if (executive_officer == deputy_eirector ) {
|
// $('#deputy_director').css('border-color', 'red');
|
||||||
// $('#executive_officer2').css('border-color', 'red');
|
// $('.noteDir').show();
|
||||||
// $('#submitFormUpdateSigner').attr('disabled', 'disabled');
|
// // alert('Input hanya boleh berisi huruf.');
|
||||||
// $('#note2').show();
|
// } else {
|
||||||
// }else{
|
// $(this).css('border-color', ''); // Kembalikan warna border
|
||||||
// $('#executive_officer2').css('border-color', '');
|
// $('#submitSigner, #submitFormUpdateSigner').prop('disabled', false); // Aktifkan tombol submit
|
||||||
// $('#submitFormUpdateSigner').attr('disabled', false);
|
// $('.noteDir').hide();
|
||||||
// $('#note2').hide();
|
// }
|
||||||
// }
|
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
// $('input[name="executive_officer"]').on('input', function() {
|
||||||
|
// let deputy_eirector = $('input[name="deputy_director"]').val();
|
||||||
|
// var executive_officer = $(this).val();
|
||||||
|
// var valid = /^[A-Za-z ]+$/.test(executive_officer);
|
||||||
|
|
||||||
|
// if (!valid) {
|
||||||
|
// $(this).css('border-color', 'red'); // Ubah warna border menjadi merah jika input tidak valid
|
||||||
|
// $('#submitSigner, #submitFormUpdateSigner').prop('disabled', true); // Non-aktifkan tombol submit
|
||||||
|
// $('#executive_officer').css('border-color', 'red');
|
||||||
|
// $('.noteEx').show();
|
||||||
|
// // alert('Input hanya boleh berisi huruf.');
|
||||||
|
// } else {
|
||||||
|
// $(this).css('border-color', ''); // Kembalikan warna border
|
||||||
|
// $('#submitSigner, #submitFormUpdateSigner').prop('disabled', false); // Aktifkan tombol submit
|
||||||
|
// $('.noteEx').hide();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
$('input[name="deputy_director"]').on('input', function() {
|
|
||||||
let executive_officer = $('input[name="executive_officer"]').val();
|
|
||||||
var deputy_eirector = $(this).val();
|
|
||||||
var valid = /^[A-Za-z ]+$/.test(deputy_eirector);
|
|
||||||
|
|
||||||
if (!valid) {
|
// });
|
||||||
$(this).css('border-color', 'red'); // Ubah warna border menjadi merah jika input tidak valid
|
|
||||||
$('#submitSigner, #submitFormUpdateSigner').prop('disabled', true); // Non-aktifkan tombol submit
|
|
||||||
$('#deputy_director').css('border-color', 'red');
|
|
||||||
$('.noteDir').show();
|
|
||||||
// alert('Input hanya boleh berisi huruf.');
|
|
||||||
} else {
|
|
||||||
$(this).css('border-color', ''); // Kembalikan warna border
|
|
||||||
$('#submitSigner, #submitFormUpdateSigner').prop('disabled', false); // Aktifkan tombol submit
|
|
||||||
$('.noteDir').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$('input[name="executive_officer"]').on('input', function() {
|
|
||||||
let deputy_eirector = $('input[name="deputy_director"]').val();
|
|
||||||
var executive_officer = $(this).val();
|
|
||||||
var valid = /^[A-Za-z ]+$/.test(executive_officer);
|
|
||||||
|
|
||||||
if (!valid) {
|
|
||||||
$(this).css('border-color', 'red'); // Ubah warna border menjadi merah jika input tidak valid
|
|
||||||
$('#submitSigner, #submitFormUpdateSigner').prop('disabled', true); // Non-aktifkan tombol submit
|
|
||||||
$('#executive_officer').css('border-color', 'red');
|
|
||||||
$('.noteEx').show();
|
|
||||||
// alert('Input hanya boleh berisi huruf.');
|
|
||||||
} else {
|
|
||||||
$(this).css('border-color', ''); // Kembalikan warna border
|
|
||||||
$('#submitSigner, #submitFormUpdateSigner').prop('disabled', false); // Aktifkan tombol submit
|
|
||||||
$('.noteEx').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (executive_officer == deputy_eirector ) {
|
|
||||||
// alert('Penandatangan Tidak Boleh Sama');
|
|
||||||
$('#executive_officer').css('border-color', 'red');
|
|
||||||
$('#submitSigner').attr('disabled', 'disabled');
|
|
||||||
$('.note').show();
|
|
||||||
}else{
|
|
||||||
$('#executive_officer').css('border-color', '');
|
|
||||||
$('#submitSigner').attr('disabled', false);
|
|
||||||
$('.note').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle form submission when the "Submit" button inside the modal is clicked
|
// Handle form submission when the "Submit" button inside the modal is clicked
|
||||||
$("#submitSigner").click(function(e) {
|
$("#submitSigner").click(function(e) {
|
||||||
// Serialize the form data
|
e.preventDefault(); // Mencegah submit form secara default
|
||||||
e.preventDefault();
|
var formData = $("#formSigner").serialize(); // Mengambil data dari form dan mengubahnya menjadi string query
|
||||||
var formData = $("#formSigner").serialize();
|
|
||||||
// var executive_officer = $('input[name="executive_officer"]').val();
|
|
||||||
// var deputy_director = $('input[name="executive_officer"]').val();
|
|
||||||
// if(executive_officer == deputy_director){
|
|
||||||
// alert();
|
|
||||||
// }
|
|
||||||
// Send an AJAX request to the form submission route
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST', // Metode HTTP yang digunakan untuk request
|
||||||
url: "{{ route('konfirmasibank.postSigner') }}",
|
url: "{{ route('konfirmasibank.postSigner') }}", // URL tujuan request
|
||||||
data: formData,
|
data: formData, // Data yang dikirimkan
|
||||||
dataType: 'json',
|
dataType: 'json', // Tipe data yang diharapkan dari server
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
$("#signerModal").modal('hide');
|
$("#signerModal").modal('hide'); // Menutup modal setelah data berhasil dikirim
|
||||||
// var _data = JSON.parse(data);
|
toastr.success(data.message); // Menampilkan pesan sukses
|
||||||
toastr.success(data.message);
|
location.reload(); // Memuat ulang halaman
|
||||||
location.reload();
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
},
|
// Menangani respons error
|
||||||
error: function(xhr, status, error) {
|
var errors = xhr.responseJSON.errors;
|
||||||
// Handle error response (if applicable)
|
$.each(errors, function(key, value) {
|
||||||
var errors = data.responseJSON.errors;
|
toastr.error(value); // Menampilkan pesan error
|
||||||
$.each(errors, function(key, value) {
|
});
|
||||||
toastr.error(value);
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".btnEditSigner").click(function(e) {
|
$(".btnEditSigner").click(function(e) {
|
||||||
@ -310,26 +252,26 @@
|
|||||||
|
|
||||||
|
|
||||||
$("#submitFormUpdateSigner").click(function(e) {
|
$("#submitFormUpdateSigner").click(function(e) {
|
||||||
// Serialize the form data
|
e.preventDefault(); // Mencegah pengiriman formulir secara default
|
||||||
e.preventDefault();
|
|
||||||
var formData = $("#formUpdateSigner").serialize();
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "{{ route('konfirmasibank.updateSigner') }}",
|
|
||||||
data: formData, // serializes the form's elements.
|
|
||||||
success: function(data) {
|
|
||||||
$("#myModalEditSigner").modal('hide');
|
|
||||||
var _data = JSON.parse(data);
|
|
||||||
toastr.success(_data.message);
|
|
||||||
location.reload();
|
|
||||||
|
|
||||||
},
|
var formData = $("#formUpdateSigner").serialize(); // Mengambil data dari formulir dan mengubahnya menjadi string query
|
||||||
error: function(data, textStatus, errorThrown) {
|
|
||||||
var errors = data.responseJSON.errors;
|
$.ajax({
|
||||||
$.each(errors, function(key, value) {
|
type: "POST",
|
||||||
toastr.error(value);
|
url: "{{ route('konfirmasibank.updateSigner') }}", // URL tujuan request, sesuaikan dengan route yang benar
|
||||||
});
|
data: formData, // Data yang dikirimkan
|
||||||
}
|
success: function(response) {
|
||||||
|
$("#myModalEditSigner").modal('hide'); // Menutup modal setelah data berhasil dikirim
|
||||||
|
toastr.success(response.message); // Menampilkan pesan sukses
|
||||||
|
location.reload(); // Memuat ulang halaman
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Menangani respons error
|
||||||
|
var errors = xhr.responseJSON.errors;
|
||||||
|
$.each(errors, function(key, value) {
|
||||||
|
toastr.error(value); // Menampilkan pesan error
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user