60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
$('#saveButton').on('click', saveWorkTimeSettingAjax);
|
|
function saveWorkTimeSettingAjax() {
|
|
var isValid = true;
|
|
var loading = $('#saveButton').next('.spinner-loading');
|
|
|
|
$('#create-form').find('.sub-input, select').each(function () {
|
|
if (!$(this).prop('disabled') && !$(this).val()) {
|
|
isValid = false;
|
|
$(this).addClass('errored');
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text('لطفا جای خالی ساعت را پر نمائید');
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
}, 3500);
|
|
return false;
|
|
} else {
|
|
$(this).removeClass('error');
|
|
}
|
|
});
|
|
|
|
if (!isValid) {
|
|
return;
|
|
}
|
|
|
|
var data = $('#create-form').serialize();
|
|
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: saveWorkTimeSetting,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: data,
|
|
success: function (response) {
|
|
if (response.isSuccess) {
|
|
loading.show();
|
|
$('.alert-success-msg').show();
|
|
$('.alert-success-msg p').text(response.message);
|
|
setTimeout(function () {
|
|
$('.alert-success-msg').hide();
|
|
$('.alert-success-msg p').text('');
|
|
loading.hide();
|
|
}, 3500);
|
|
} else {
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text(response.message);
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
loading.hide();
|
|
}, 3500);
|
|
}
|
|
},
|
|
error: function (err) {
|
|
loading.hide();
|
|
console.log(err);
|
|
}
|
|
});
|
|
} |