$('#zero-config').DataTable({
"dom": "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
"<'table-responsive'tr>" +
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
"oLanguage": {
"oPaginate": { "sPrevious": '', "sNext": '' },
"sInfo": "Showing page _PAGE_ of _PAGES_",
"sSearch": '',
"sSearchPlaceholder": "Search...",
"sLengthMenu": "Results : _MENU_",
},
"stripeClasses": [],
"lengthMenu": [7, 10, 20, 50],
"pageLength": 10
});
$(document).ready(function() {
$(' ')
.insertBefore("#zero-config_filter label");
});
$(".location_table").on("change", ".active_location", function () {
let base_url = url_path;
var status = $(this).prop("checked") == true ? 1 : 0;
var location_id = $(this).data("id");
$.ajax({
type: "GET",
dataType: "json",
url: base_url + '/change_location_status',
data: {
status: status,
location_id: location_id,
},
success: function (data) {
if (status == 1) {
toastr.options = {
"timeOut": 500
}
toastr.success("Status Activate successfully. !!");
} else {
toastr.error("Status Deactivate successfully. !!");
}
},
});
});
$(document).on("click", ".delete_location", function () {
var delete_id = $(this).data('id');
$('#delete_location_id').val(delete_id);
});
$(document).on("click", ".delete_location_button", function (e) {
e.preventDefault();
let base_url = url_path;
var delete_id = $('#delete_location_id').val();
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
});
$.ajax({
type: "DELETE",
url: base_url + "/delete_location/" + delete_id,
success: function (response) {
if (response.status == 200) {
toastr.success('Location Deleted Successfully');
setTimeout(function () {
window.location.href = base_url + "/manage_location";
}, 1000);
} else {
toastr.error("Something went wrong");
}
},
});
});