File: /var/www/admin.javaapp.co.uk/public/assets/js/cafe/editCafeHours.js
$(function() {
// $('#getCafeHours').click(() => {
// // $('#load_screen').fadeIn('slow');
// let getCafeHours = $.ajax({
// type: "get",
// url: $('#getCafeHours').data("action"),
// contentType: false,
// processData: false,
// });
// getCafeHours.then((result) => {
// if (result.status == 200) {
// if ($('.modal-content').children('form').length > 0) {
// // console.log(124);
// $('.modal-content').children('form').remove();
// }
// $('.modal-content').append(result.data);
// // console.log(456);
// $('#set_cafe_hours').click((e) => {
// e.preventDefault();
// $("#set_cafe_hours_from").validate();
// // $('[name*="open_time"]').each(function () {
// // $(this).rules('add', {
// // required: true,
// // maxlength: 5,
// // messages: {
// // required: "Please enter the open time",
// // maxlength: "Open time must be less than or equal to 5 characters",
// // },
// // errorElement: 'span',
// // errorPlacement: function (error, element) {
// // console.log(error);
// // error.addClass('invalid-feedback');
// // if (element.attr("name") == "profile_picture") {
// // error.appendTo("#profile_picture_error")
// // } else {
// // element.closest('.form-group').append(error);
// // }
// // },
// // highlight: function (element, errorClass, validClass) {
// // $(element).addClass('is-invalid');
// // },
// // unhighlight: function (element, errorClass, validClass) {
// // $(element).removeClass('is-invalid');
// // }
// // });
// // });
// // $('[name*="close_time"]').each(function () {
// // $(this).rules('add', {
// // required: true,
// // maxlength: 5,
// // messages: {
// // required: "Please enter the close time",
// // maxlength: "Close time must be less than or equal to 5 characters",
// // },
// // errorElement: 'span',
// // errorPlacement: function (error, element) {
// // error.addClass('invalid-feedback');
// // if (element.attr("name") == "profile_picture") {
// // error.appendTo("#profile_picture_error")
// // } else {
// // element.closest('.form-group').append(error);
// // }
// // },
// // highlight: function (element, errorClass, validClass) {
// // $(element).addClass('is-invalid');
// // },
// // unhighlight: function (element, errorClass, validClass) {
// // $(element).removeClass('is-invalid');
// // }
// // });
// // });
// $.ajax({
// type: "POST",
// url: $('#set_cafe_hours_from').data("action"),
// data: new FormData($('#set_cafe_hours_from')[0]),
// contentType: false,
// processData: false,
// success: function (result) {
// if (result.status == 200) {
// $('.modal').removeClass('show');
// $('.modal-backdrop').remove();
// Swal.fire('success', result.message, 'success');
// window.location.href = result.goto;
// } else {
// Swal.fire({
// icon: 'error',
// title: error,
// text: result.message,
// });
// }
// },
// error: function (error) {
// Swal.fire({
// icon: 'error',
// title: error,
// text: result.message,
// });
// }
// });
// });
// } else {
// $('.modal').removeClass('show');
// $('.modal-backdrop').remove();
// Swal.fire({
// icon: 'error',
// title: 'Oops...',
// text: result.message,
// });
// }
// }).catch(() => {
// $('.modal').removeClass('show');
// $('.modal-backdrop').remove();
// Swal.fire({
// icon: 'error',
// title: 'Oops...',
// text: result.message,
// });
// });
// });
$("#set_cafe_hours_from").validate({
ignore: [],
errorElement: 'span',
errorPlacement: function (error, element) {
error.addClass('invalid-feedback');
if (element.attr("name") == "profile_picture") {
error.appendTo("#profile_picture_error")
} else {
element.closest('.form-group').append(error);
}
},
highlight: function (element, errorClass, validClass) {
$(element).addClass('is-invalid');
},
unhighlight: function (element, errorClass, validClass) {
$(element).removeClass('is-invalid');
}
});
$('[name*="open_time"]').each(function () {
$(this).rules('add', {
required: true,
maxlength: 5,
regexTime: /[0-9]{2}:[0-9]{2}/,
messages: {
required: validation.open_time_required,
maxlength: validation.open_time_maxlength,
},
});
});
$('[name*="close_time"]').each(function () {
$(this).rules('add', {
required: true,
maxlength: 5,
regexTime: /[0-9]{2}:[0-9]{2}/,
messages: {
required: validation.close_time_required,
maxlength: validation.close_time_maxlength,
},
});
});
$('input').on('input', () => {
$('#set_cafe_hours_from').valid();
});
$('#set_cafe_hours').click((e) => {
if ($('#set_cafe_hours_from').valid()) {
e.preventDefault();
$.ajax({
type: "POST",
url: $('#set_cafe_hours_from').attr("action"),
data: new FormData($('#set_cafe_hours_from')[0]),
contentType: false,
processData: false,
success: function (response) {
if (response.status == 200) {
// $('.modal').removeClass('show');
// $('.modal-backdrop').remove();
window.location.href = response.goto;
// Swal.fire({
// title: success,
// text: response.message,
// type: 'success',
// confirmButtonColor: '#461C10',
// confirmButtonText: 'Ok'
// }).then((result) => {
// if (result.value) {
// }
// });
} else {
console.log(response);
$.growl.error({
title: "error",
message: response.message,
});
}
},
error: function (error) {
$.growl.error({
title: "error",
message: somethingWentWrong,
});
}
});
}
});
});