@@ -78,194 +78,197 @@ $(document).on("click", ".restaurant_unarchive", function (e) {
|
||||
});
|
||||
});
|
||||
|
||||
//old code for change status
|
||||
$(document).on('click', "#delete_restaurant", function() {
|
||||
var delete_restaurant_user_id = $(this).data('id');
|
||||
$("#news_delete").val(delete_restaurant_user_id);
|
||||
})
|
||||
|
||||
// $(".rest_users_table").on("change", ".active_rest_user", function () {
|
||||
// let base_url = url_path;
|
||||
// var status = $(this).prop("checked") == true ? 1 : 0;
|
||||
// var rest_user_id = $(this).data("id");
|
||||
$(document).on('click', '#delete_restaurant_user', function(e) {
|
||||
let base_url = url_path;
|
||||
e.preventDefault();
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// dataType: "json",
|
||||
// url: base_url + '/change_rest_status',
|
||||
// data: {
|
||||
// status: status,
|
||||
// rest_user_id: rest_user_id,
|
||||
// },
|
||||
// success: function (data) {
|
||||
// if (status == 1) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 500
|
||||
// }
|
||||
// toastr.success("Status Activate successfully. !!");
|
||||
// } else {
|
||||
// toastr.error("Status Deactivate successfully. !!");
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
var id = $('#news_delete').val();
|
||||
console.log('id' , id);
|
||||
$('#delete_restaurant_user').text('Please wait...');
|
||||
$('#delete_restaurant_user').attr('disabled', true);
|
||||
|
||||
// $(document).ready(function () {
|
||||
// // Handle approve button click
|
||||
// $(".approve-btn").on("click", function () {
|
||||
// let base_url = url_path;
|
||||
// var rest_user_id = $(this).data("id");
|
||||
// var status = 1;
|
||||
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// dataType: "json",
|
||||
// url: base_url + '/change_rest_status',
|
||||
// data: {
|
||||
// status: status,
|
||||
// rest_user_id: rest_user_id,
|
||||
// },
|
||||
// success: function (data) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 500
|
||||
// }
|
||||
// toastr.success("User approved and status activated successfully. !!");
|
||||
|
||||
// // Update the switch to active
|
||||
// $('#switch' + rest_user_id).prop('checked', true);
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
|
||||
// // Handle disapprove button click
|
||||
// $(".disapprove-btn").on("click", function () {
|
||||
// let base_url = url_path;
|
||||
// var rest_user_id = $(this).data("id");
|
||||
// var status = 0;
|
||||
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// dataType: "json",
|
||||
// url: base_url + '/change_rest_status',
|
||||
// data: {
|
||||
// status: status,
|
||||
// rest_user_id: rest_user_id,
|
||||
// },
|
||||
// success: function (data) {
|
||||
// toastr.error("User disapproved and status deactivated successfully. !!");
|
||||
|
||||
// // Update the switch to inactive
|
||||
// $('#switch' + rest_user_id).prop('checked', false);
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: base_url + '/delete_restaurant_user/' + id,
|
||||
success: function(result) {
|
||||
if (result.status == 200) {
|
||||
toastr.success('Restaurant Deleted Sucessfully');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/restaurant_users";
|
||||
}, 2000);
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/restaurant_users";
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// $(".rest_users_table").on("change", ".active_rest_user", function () {
|
||||
// // Revert the switch change
|
||||
// var rest_user_id = $(this).data("id");
|
||||
// var currentStatus = $(this).prop("checked");
|
||||
|
||||
// // Revert the switch state
|
||||
// $(this).prop("checked", !currentStatus);
|
||||
$(document).ready(function() {
|
||||
let actionType = '';
|
||||
let restUserId = '';
|
||||
let switchElement = null;
|
||||
let actionButton = null;
|
||||
|
||||
// toastr.options = {
|
||||
// "timeOut": 6000
|
||||
// }
|
||||
// toastr.error("You can only change the status using Approve/Disapprove buttons.");
|
||||
// });
|
||||
$(".approve-btn, .disapprove-btn").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// });
|
||||
actionType = $(this).hasClass('approve-btn') ? 'approve' : 'disapprove';
|
||||
restUserId = $(this).data("id");
|
||||
switchElement = $('#switch' + restUserId);
|
||||
actionButton = $(this);
|
||||
|
||||
// $(document).ready(function() {
|
||||
// // console.log('dfkjb');
|
||||
// $('#rest_user_form').validate({
|
||||
// ignore: [],
|
||||
// debug: false,
|
||||
// rules: {
|
||||
// first_name: {
|
||||
// required: true,
|
||||
// fullNameCharactersOnly: true
|
||||
// },
|
||||
// last_name:{
|
||||
// required: true,
|
||||
// },
|
||||
// user_birth:{
|
||||
// required: true,
|
||||
// },
|
||||
// Check current status for approve
|
||||
if (actionType === 'approve' && switchElement.prop('checked')) {
|
||||
toastr.options = { "timeOut": 100 };
|
||||
toastr.warning("User is already approved. !!");
|
||||
return;
|
||||
}
|
||||
|
||||
// restaurant_email: {
|
||||
// required: true,
|
||||
// email: true,
|
||||
// },
|
||||
// Check current status for disapprove
|
||||
if (actionType === 'disapprove' && $(this).data("deleted_by_admin") == 1) {
|
||||
toastr.options = { "timeOut": 500 };
|
||||
toastr.warning("User is already disapproved. !!");
|
||||
return;
|
||||
}
|
||||
|
||||
// restaurant_phone: {
|
||||
// required: true,
|
||||
// numericCharactersOnly: true
|
||||
// },
|
||||
$('#action-type').text(actionType);
|
||||
$('#action-word').text(actionType);
|
||||
$('#confirm-btn').attr('data-action', actionType);
|
||||
$('#confirm-btn').attr('data-id', restUserId);
|
||||
$('#confirm-modal').modal('show');
|
||||
});
|
||||
|
||||
// },
|
||||
// messages: {
|
||||
// first_name: {
|
||||
// required: "Please enter first name",
|
||||
// alphaCharactersOnly: "Please enter only alphabetical characters"
|
||||
// },
|
||||
// last_name:{
|
||||
// required: "Please enter last name",
|
||||
// },
|
||||
// user_birth:{
|
||||
// required: "Please enter date of birth",
|
||||
// },
|
||||
$('#confirm-btn').on('click', function() {
|
||||
let base_url = url_path;
|
||||
let actionType = $(this).attr('data-action');
|
||||
let restUserId = $(this).attr('data-id');
|
||||
|
||||
// restaurant_email: {
|
||||
// required: "Enter email address",
|
||||
// email: "Please enter a valid email address"
|
||||
// },
|
||||
$(this).text('Please wait...').attr('disabled', true);
|
||||
|
||||
// restaurant_phone: {
|
||||
// required: "Enter Phone Number",
|
||||
// numericCharactersOnly: "Please enter only numeric characters"
|
||||
// },
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: base_url + '/change_rest_status',
|
||||
data: {
|
||||
status: actionType === 'approve' ? 1 : 0,
|
||||
rest_user_id: restUserId,
|
||||
_token: $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
success: function(data) {
|
||||
toastr.options = { "timeOut": 500 };
|
||||
if (actionType === 'approve') {
|
||||
toastr.success("User approved and status activated successfully. !!");
|
||||
switchElement.prop('checked', true);
|
||||
} else {
|
||||
toastr.error("User disapproved and status deactivated successfully. !!");
|
||||
switchElement.prop('checked', false);
|
||||
}
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/restaurant_users";
|
||||
}, 2000);
|
||||
},
|
||||
error: function() {
|
||||
toastr.error("There was an error processing the request. Please try again.");
|
||||
$('#confirm-btn').text('Yes, ' + actionType).attr('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
// },
|
||||
// errorClass: 'error-message',
|
||||
// submitHandler: function(form) {
|
||||
// let base_url = url_path;
|
||||
// var formData = new FormData(form);
|
||||
// // console.log(formData);
|
||||
// $('#restaturant_btn').text('Please wait...');
|
||||
// $('#restaturant_btn').attr('disabled', true);
|
||||
|
||||
// $.ajaxSetup({
|
||||
// headers: {
|
||||
// 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
// }
|
||||
// });
|
||||
// $.ajax({
|
||||
// url: base_url + '/update_restaurant',
|
||||
// type: 'POST',
|
||||
// data: formData,
|
||||
// processData: false,
|
||||
// contentType: false,
|
||||
// success: function(result) {
|
||||
// if (result.status_code == 200) {
|
||||
// toastr.success('Restaurant Updated Sucessfully');
|
||||
// setTimeout(function() {
|
||||
// window.location.href = base_url + "/restaurant_users";
|
||||
// }, 2000);
|
||||
// } else {
|
||||
// toastr.error('Something Went Wrong');
|
||||
// setTimeout(function() {
|
||||
// window.location.href = base_url + "/restaurant_users";
|
||||
// }, 2000);
|
||||
// }
|
||||
// $('#restaturant_btn').attr('disabled', false);
|
||||
// $('#restaturant_btn').text('Submit');
|
||||
// },
|
||||
// error: function() {
|
||||
// toastr.error('Something Went Wrong');
|
||||
// $('#restaturant_btn').attr('disabled', false);
|
||||
// $('#restaturant_btn').text('Submit');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
$('#confirm-modal').modal('hide');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// Handle switch change
|
||||
$(".rest_users_table").on("change", ".active_rest_user", function() {
|
||||
// Revert the switch change
|
||||
var currentStatus = $(this).prop("checked");
|
||||
|
||||
// Revert the switch state
|
||||
$(this).prop("checked", !currentStatus);
|
||||
|
||||
|
||||
toastr.options = {
|
||||
"timeOut": 500
|
||||
}
|
||||
toastr.error("You can only change the status using Approve/Disapprove buttons.");
|
||||
});
|
||||
|
||||
|
||||
$(function(e) {
|
||||
// Select/Deselect all checkboxes
|
||||
$("#select-all-ids").click(function() {
|
||||
$(".form-check-input").prop('checked', $(this).prop('checked'));
|
||||
});
|
||||
|
||||
$(".form-check-input").click(function() {
|
||||
if (!$(this).prop('checked')) {
|
||||
$("#select-all-ids").prop('checked', false);
|
||||
} else {
|
||||
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
|
||||
$("#select-all-ids").prop('checked', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handle download selected action
|
||||
$(document).on("click", "#download-selected", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var selectedIds = [];
|
||||
|
||||
var table = $('#zero-config').DataTable();
|
||||
for (var i = 0; i < table.page.info().pages; i++) {
|
||||
table.page(i).draw(false); // Switch to page i without resetting the table
|
||||
$('#zero-config tbody input.form-check-input:checked').each(function() {
|
||||
selectedIds.push($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
if (selectedIds.length > 0) {
|
||||
// If there are selected customers
|
||||
$('#selected_ids').prop('disabled', false);
|
||||
$('#all_id').prop('disabled', true);
|
||||
$('#selected_ids').val(selectedIds.join(',')); // Join all IDs into a single string
|
||||
|
||||
// Log the selected IDs for debugging
|
||||
// console.log(selectedIds);
|
||||
|
||||
$('#restaurant-form').submit();
|
||||
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 5000); // Adjust the timeout as needed
|
||||
} else {
|
||||
toastr.error("Please select at least one restaurant to download.");
|
||||
}
|
||||
});
|
||||
|
||||
// Handle download all action
|
||||
$(document).on("click", "#download_all", function(e) {
|
||||
e.preventDefault();
|
||||
$('#all_id').prop('disabled', false);
|
||||
$('#selected_ids').prop('disabled', true);
|
||||
$('#restaurant-form').submit();
|
||||
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 5000); // Adjust the timeout as needed
|
||||
});
|
||||
});
|
||||
|
||||
@@ -276,7 +276,7 @@
|
||||
<a href="{{ url('/edit_restaurant_users/' . $restaurant_user->id) }}"><img
|
||||
src="{{ asset('public/assets/img/edit.svg') }}" alt="Edit"
|
||||
title="Edit" /></a>
|
||||
<a href="#" class="delete-restaurant-user"
|
||||
<a href="#" class="delete-restaurant-user" id="delete_restaurant"
|
||||
data-id="{{ $restaurant_user->id }}" data-toggle="modal"
|
||||
data-target="#delete-restaurant-user-modal"><img
|
||||
src="{{ asset('public/assets/img/delete-recycle.svg') }}" /></a>
|
||||
@@ -335,43 +335,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Confirmation Modal -->
|
||||
<!-- <div class="modal fade" id="confirm-modal" tabindex="-1" aria-labelledby="confirmModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="confirmModalLabel">Confirmation</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Are you sure you want to <span id="action-type"></span> this user?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">No</button>
|
||||
<button type="button" class="btn btn-primary" id="confirm-btn">Yes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- Confirmation Modal -->
|
||||
<!-- <div class="modal fade" id="confirm-modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">x</button>
|
||||
</div>
|
||||
<input type="hidden" id="user_id" name="user_id">
|
||||
<h5>
|
||||
<p class="modal-text">Are you sure you want to<br><span id="action-type"></span> this user?</p></h5>
|
||||
<div class="modal-btn d-flex">
|
||||
<a class="extra-btn pointer" data-dismiss="modal">No</a>
|
||||
<a class="download-btn-custom" id="confirm-btn" href="#">Yes, <span id="action-word"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="modal fade" id="confirm-modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
@@ -399,8 +363,6 @@
|
||||
@section('section_script')
|
||||
<script src="{{ asset('public/assets/js/admin/manage_restaurant/main.js') }}"></script>
|
||||
<script>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
// Create the filter button
|
||||
var filterButton = $('<div class="filter-btn-wrapper">' +
|
||||
@@ -486,409 +448,4 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).on('click', "#delete_restaurant_user_id", function() {
|
||||
var delete_restaurant_user_id = $(this).data('id');
|
||||
$("#news_delete").val(delete_restaurant_user_id);
|
||||
})
|
||||
|
||||
$(document).on('click', '#delete_restaurant_user', function(e) {
|
||||
let base_url = url_path;
|
||||
e.preventDefault();
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
var id = $('#news_delete').val();
|
||||
|
||||
$('#delete_restaurant_user').text('Please wait...');
|
||||
$('#delete_restaurant_user').attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'delete_restaurant_user/' + id,
|
||||
success: function(result) {
|
||||
if (result.status == 200) {
|
||||
toastr.success('Restaurant Deleted Sucessfully');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/restaurant_users";
|
||||
}, 2000);
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/restaurant_users";
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
// old code Handle approve button click
|
||||
// $(".approve-btn").on("click", function(e) {
|
||||
// e.preventDefault(); // Prevent form submission
|
||||
// let base_url = url_path;
|
||||
// var rest_user_id = $(this).data("id");
|
||||
// var switchElement = $('#switch' + rest_user_id);
|
||||
|
||||
// // Check current status
|
||||
// if (switchElement.prop('checked')) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 100
|
||||
// }
|
||||
// toastr.warning("User is already approved. !!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $('#approve-btn').text('Please wait...');
|
||||
// $('#approve-btn').attr('disabled', true);
|
||||
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// dataType: "json",
|
||||
// url: base_url + '/change_rest_status',
|
||||
// data: {
|
||||
// status: 1,
|
||||
// rest_user_id: rest_user_id,
|
||||
// },
|
||||
// success: function(data) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 500
|
||||
// }
|
||||
// toastr.success("User approved and status activated successfully. !!");
|
||||
// setTimeout(function() {
|
||||
// window.location.href = base_url + "/restaurant_users";
|
||||
// }, 2000); // Update the switch to active
|
||||
// switchElement.prop('checked', true);
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
// below is updated code of disapprove button start
|
||||
|
||||
// $(".approve-btn").on("click", function(e) {
|
||||
// e.preventDefault(); // Prevent form submission
|
||||
|
||||
// let base_url = url_path;
|
||||
// var rest_user_id = $(this).data("id");
|
||||
// var switchElement = $('#switch' + rest_user_id);
|
||||
// var approveButton = $(this); // Target the clicked button
|
||||
|
||||
// // Check current status
|
||||
// if (switchElement.prop('checked')) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 100
|
||||
// }
|
||||
// toastr.warning("User is already approved. !!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// approveButton.text('Please wait...');
|
||||
// approveButton.attr('disabled', true);
|
||||
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// dataType: "json",
|
||||
// url: base_url + '/change_rest_status',
|
||||
// data: {
|
||||
// status: 1,
|
||||
// rest_user_id: rest_user_id,
|
||||
// },
|
||||
// success: function(data) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 500
|
||||
// }
|
||||
// toastr.success("User approved and status activated successfully. !!");
|
||||
// setTimeout(function() {
|
||||
// window.location.href = base_url + "/restaurant_users";
|
||||
// }, 2000); // Update the switch to active
|
||||
// switchElement.prop('checked', true);
|
||||
// },
|
||||
// error: function() {
|
||||
// // Re-enable the button in case of an error
|
||||
// approveButton.text('Approve');
|
||||
// approveButton.attr('disabled', false);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// below is updated code of disapprove button start
|
||||
|
||||
|
||||
// old code Handle disapprove button click
|
||||
// $(document).ready(function() {
|
||||
// $(".disapprove-btn").on("click", function(e) {
|
||||
// e.preventDefault(); // Prevent form submission
|
||||
// let base_url = url_path;
|
||||
// var rest_user_id = $(this).data("id");
|
||||
// var deleted_by_admin = $(this).data(
|
||||
// "deleted_by_admin"); // Fetch the deleted_by_admin value
|
||||
// var switchElement = $('#switch' + rest_user_id);
|
||||
|
||||
// // console.log(
|
||||
// // deleted_by_admin); // Log the value to check if it is correctly fetched
|
||||
|
||||
// // Check current status
|
||||
// if (deleted_by_admin == 1) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 500
|
||||
// }
|
||||
// toastr.warning("User is already disapproved. !!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $('#disapprove-btn').text('Please wait...');
|
||||
// $('#disapprove-btn').attr('disabled', true);
|
||||
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// dataType: "json",
|
||||
// url: base_url + '/change_rest_status',
|
||||
// data: {
|
||||
// status: 0,
|
||||
// rest_user_id: rest_user_id,
|
||||
// },
|
||||
// success: function(data) {
|
||||
// toastr.error(
|
||||
// "User disapproved and status deactivated successfully. !!"
|
||||
// );
|
||||
// setTimeout(function() {
|
||||
// window.location.href = base_url +
|
||||
// "/restaurant_users";
|
||||
// }, 2000);
|
||||
// // Update the switch to inactive
|
||||
// switchElement.prop('checked', false);
|
||||
// },
|
||||
// error: function(error) {
|
||||
// toastr.error(
|
||||
// "There was an error processing the request. Please try again."
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// below is updated code of disapprove button start
|
||||
|
||||
|
||||
// $(document).ready(function() {
|
||||
// $(".disapprove-btn").on("click", function(e) {
|
||||
// e.preventDefault(); // Prevent form submission
|
||||
|
||||
// let base_url = url_path;
|
||||
// var rest_user_id = $(this).data("id");
|
||||
// var deleted_by_admin = $(this).data("deleted_by_admin"); // Fetch the deleted_by_admin value
|
||||
// var switchElement = $('#switch' + rest_user_id);
|
||||
// var disapproveButton = $(this); // Target the clicked button
|
||||
|
||||
// // Check current status
|
||||
// if (deleted_by_admin == 1) {
|
||||
// toastr.options = {
|
||||
// "timeOut": 500
|
||||
// }
|
||||
// toastr.warning("User is already disapproved. !!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// disapproveButton.text('Please wait...');
|
||||
// disapproveButton.attr('disabled', true);
|
||||
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// dataType: "json",
|
||||
// url: base_url + '/change_rest_status',
|
||||
// data: {
|
||||
// status: 0,
|
||||
// rest_user_id: rest_user_id,
|
||||
// },
|
||||
// success: function(data) {
|
||||
// toastr.error("User disapproved and status deactivated successfully. !!");
|
||||
// setTimeout(function() {
|
||||
// window.location.href = base_url + "/restaurant_users";
|
||||
// }, 2000);
|
||||
// // Update the switch to inactive
|
||||
// switchElement.prop('checked', false);
|
||||
// },
|
||||
// error: function(error) {
|
||||
// toastr.error("There was an error processing the request. Please try again.");
|
||||
// // Re-enable the button in case of an error
|
||||
// disapproveButton.text('Disapprove');
|
||||
// disapproveButton.attr('disabled', false);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// above is updated code of disapprove button end
|
||||
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
let actionType = '';
|
||||
let restUserId = '';
|
||||
let switchElement = null;
|
||||
let actionButton = null;
|
||||
|
||||
$(".approve-btn, .disapprove-btn").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
actionType = $(this).hasClass('approve-btn') ? 'approve' : 'disapprove';
|
||||
restUserId = $(this).data("id");
|
||||
switchElement = $('#switch' + restUserId);
|
||||
actionButton = $(this);
|
||||
|
||||
// Check current status for approve
|
||||
if (actionType === 'approve' && switchElement.prop('checked')) {
|
||||
toastr.options = { "timeOut": 100 };
|
||||
toastr.warning("User is already approved. !!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check current status for disapprove
|
||||
if (actionType === 'disapprove' && $(this).data("deleted_by_admin") == 1) {
|
||||
toastr.options = { "timeOut": 500 };
|
||||
toastr.warning("User is already disapproved. !!");
|
||||
return;
|
||||
}
|
||||
|
||||
$('#action-type').text(actionType);
|
||||
$('#action-word').text(actionType);
|
||||
$('#confirm-btn').attr('data-action', actionType);
|
||||
$('#confirm-btn').attr('data-id', restUserId);
|
||||
$('#confirm-modal').modal('show');
|
||||
});
|
||||
|
||||
$('#confirm-btn').on('click', function() {
|
||||
let base_url = url_path;
|
||||
let actionType = $(this).attr('data-action');
|
||||
let restUserId = $(this).attr('data-id');
|
||||
|
||||
$(this).text('Please wait...').attr('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: base_url + '/change_rest_status',
|
||||
data: {
|
||||
status: actionType === 'approve' ? 1 : 0,
|
||||
rest_user_id: restUserId,
|
||||
_token: $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
success: function(data) {
|
||||
toastr.options = { "timeOut": 500 };
|
||||
if (actionType === 'approve') {
|
||||
toastr.success("User approved and status activated successfully. !!");
|
||||
switchElement.prop('checked', true);
|
||||
} else {
|
||||
toastr.error("User disapproved and status deactivated successfully. !!");
|
||||
switchElement.prop('checked', false);
|
||||
}
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/restaurant_users";
|
||||
}, 2000);
|
||||
},
|
||||
error: function() {
|
||||
toastr.error("There was an error processing the request. Please try again.");
|
||||
$('#confirm-btn').text('Yes, ' + actionType).attr('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#confirm-modal').modal('hide');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// Handle switch change
|
||||
$(".rest_users_table").on("change", ".active_rest_user", function() {
|
||||
// Revert the switch change
|
||||
var currentStatus = $(this).prop("checked");
|
||||
|
||||
// Revert the switch state
|
||||
$(this).prop("checked", !currentStatus);
|
||||
|
||||
|
||||
toastr.options = {
|
||||
"timeOut": 500
|
||||
}
|
||||
toastr.error("You can only change the status using Approve/Disapprove buttons.");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
$(function(e) {
|
||||
// Select/Deselect all checkboxes
|
||||
$("#select-all-ids").click(function() {
|
||||
$(".form-check-input").prop('checked', $(this).prop('checked'));
|
||||
});
|
||||
|
||||
$(".form-check-input").click(function() {
|
||||
if (!$(this).prop('checked')) {
|
||||
$("#select-all-ids").prop('checked', false);
|
||||
} else {
|
||||
if ($(".form-check-input:checked").length === $(".form-check-input").length) {
|
||||
$("#select-all-ids").prop('checked', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handle download selected action
|
||||
$(document).on("click", "#download-selected", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var selectedIds = [];
|
||||
|
||||
var table = $('#zero-config').DataTable();
|
||||
for (var i = 0; i < table.page.info().pages; i++) {
|
||||
table.page(i).draw(false); // Switch to page i without resetting the table
|
||||
$('#zero-config tbody input.form-check-input:checked').each(function() {
|
||||
selectedIds.push($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
if (selectedIds.length > 0) {
|
||||
// If there are selected customers
|
||||
$('#selected_ids').prop('disabled', false);
|
||||
$('#all_id').prop('disabled', true);
|
||||
$('#selected_ids').val(selectedIds.join(',')); // Join all IDs into a single string
|
||||
|
||||
// Log the selected IDs for debugging
|
||||
// console.log(selectedIds);
|
||||
|
||||
$('#restaurant-form').submit();
|
||||
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 5000); // Adjust the timeout as needed
|
||||
} else {
|
||||
toastr.error("Please select at least one restaurant to download.");
|
||||
}
|
||||
});
|
||||
|
||||
// Handle download all action
|
||||
$(document).on("click", "#download_all", function(e) {
|
||||
e.preventDefault();
|
||||
$('#all_id').prop('disabled', false);
|
||||
$('#selected_ids').prop('disabled', true);
|
||||
$('#restaurant-form').submit();
|
||||
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 5000); // Adjust the timeout as needed
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user