copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
$(document).ready(function () {
|
||||
$('#formjabatankaryawan').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
var btn = $('#submitjabatan');
|
||||
|
||||
btn.attr('disabled', 'disabled').text('Wait...');
|
||||
|
||||
$.ajax({
|
||||
url: $(this).attr('action'),
|
||||
data: $(this).serialize(),
|
||||
type: 'POST',
|
||||
success: function (response) {
|
||||
btn.removeAttr('disabled').text('Submit');
|
||||
if (response.status) {
|
||||
// Swal('Sukses', 'Data Berhasil diupdate', 'success')
|
||||
// .then((result) => {
|
||||
// if (result.value) {
|
||||
window.location.href = base_url + 'index.php/ManageKaryawan/edit/' + response.id;
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
$.each(response.errors, function (key, val) {
|
||||
$('[name="' + key + '"]').closest('.form-group').addClass('has-error');
|
||||
$('[name="' + key + '"]').nextAll('.help-block').eq(0).text(val);
|
||||
if (val === '') {
|
||||
$('[name="' + key + '"]').closest('.form-group').removeClass('has-error').addClass('has-success');
|
||||
$('[name="' + key + '"]').nextAll('.help-block').eq(0).text('');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$('#formpasskaryawan').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
var btn = $('#submitpass');
|
||||
|
||||
btn.attr('disabled', 'disabled').text('Wait...');
|
||||
|
||||
$.ajax({
|
||||
url: $(this).attr('action'),
|
||||
data: $(this).serialize(),
|
||||
type: 'POST',
|
||||
success: function (response) {
|
||||
btn.removeAttr('disabled').text('Submit');
|
||||
if (response.status) {
|
||||
Swal('Sukses', 'Data Berhasil diupdate', 'success')
|
||||
.then((result) => {
|
||||
if (result.value) {
|
||||
window.location.href = base_url + 'index.php/ManageKaryawan';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (response.err) {
|
||||
Swal({
|
||||
"title": "Gagal",
|
||||
"text": response.message,
|
||||
"type": "error"
|
||||
});
|
||||
$.each(response.errors, function (key, val) {
|
||||
$('[name="oldpassword"]').closest('.form-group').addClass('has-error');
|
||||
$('[name="oldpassword"]').nextAll('.help-block').eq(0).text('Old password incorrect');
|
||||
// if (val === '') {
|
||||
// $('[name="oldpassword"]').closest('.form-group').removeClass('has-error').addClass('has-success');
|
||||
// $('[name="oldpassword"]').nextAll('.help-block').eq(0).text('');
|
||||
// }
|
||||
});
|
||||
} else {
|
||||
$.each(response.errors, function (key, val) {
|
||||
$('[name="' + key + '"]').closest('.form-group').addClass('has-error');
|
||||
$('[name="' + key + '"]').nextAll('.help-block').eq(0).text(val);
|
||||
if (val === '') {
|
||||
$('[name="' + key + '"]').closest('.form-group').removeClass('has-error').addClass('has-success');
|
||||
$('[name="' + key + '"]').nextAll('.help-block').eq(0).text('');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
$('#formjabatankaryawan input, #formjabatankaryawan select').on('change', function () {
|
||||
$(this).closest('.form-group').removeClass('has-error has-success');
|
||||
$(this).nextAll('.help-block').eq(0).text('');
|
||||
});
|
||||
$('#formpasskaryawan input, #formpasskaryawan select').on('change', function () {
|
||||
$(this).closest('.form-group').removeClass('has-error has-success');
|
||||
$(this).nextAll('.help-block').eq(0).text('');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user