changes
This commit is contained in:
@@ -34,6 +34,8 @@ class ManageNotificationsController extends Controller
|
||||
->latest()
|
||||
->take(12)
|
||||
->get();
|
||||
// return $notifications;
|
||||
|
||||
} else if ($activeQuery == 3) { // for restaurant
|
||||
$notifications = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
@@ -44,8 +46,6 @@ class ManageNotificationsController extends Controller
|
||||
->latest()
|
||||
->take(12)
|
||||
->get();
|
||||
|
||||
// return $notifications;
|
||||
} else {
|
||||
$notificationsOfType3 = NotificationDetails::with('Notification')
|
||||
->where('is_active', 1)
|
||||
@@ -68,8 +68,8 @@ class ManageNotificationsController extends Controller
|
||||
->get();
|
||||
|
||||
$notifications = $notificationsOfType3->merge($notificationsOfType4);
|
||||
$scheduledNotifications = NotificationDetails::where('is_schedule', 1)->where('is_active', 1)->orderByDesc('id')->get();
|
||||
}
|
||||
$scheduledNotifications = NotificationDetails::where('is_schedule', 1)->where('is_active', 1)->orderByDesc('id')->get();
|
||||
|
||||
return view('Admin.pages.manage_notification.manage_notification', compact('notifications', 'scheduledNotifications'));
|
||||
}
|
||||
@@ -287,7 +287,6 @@ class ManageNotificationsController extends Controller
|
||||
$notification->state_ids = json_encode($request->state_ids);
|
||||
$notification->save();
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data_scheduled'));
|
||||
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Notification update Failed " . $e->getMessage());
|
||||
@@ -300,5 +299,4 @@ class ManageNotificationsController extends Controller
|
||||
$data = NotificationDetails::find($id)->delete();
|
||||
return redirect()->back()->with('success', '');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
206
public/assets/js/admin/manage_notification/add.js
Normal file
206
public/assets/js/admin/manage_notification/add.js
Normal file
@@ -0,0 +1,206 @@
|
||||
$(document).ready(function() {
|
||||
// Custom validator for checking state checkboxes
|
||||
$.validator.addMethod('stateRequired', function(value, element) {
|
||||
let selectedUserType = $('input[name="user_type"]:checked').val();
|
||||
if (selectedUserType) {
|
||||
let dropdownId = `dropdown-${selectedUserType}`;
|
||||
return $(`#${dropdownId} .state-checkbox:checked`).length > 0;
|
||||
}
|
||||
return true;
|
||||
}, 'Please select at least one state.');
|
||||
|
||||
// Validate the form
|
||||
$('#send_notification_form').validate({
|
||||
ignore: [],
|
||||
debug: false,
|
||||
rules: {
|
||||
title: {
|
||||
required: true
|
||||
},
|
||||
description: {
|
||||
required: true
|
||||
},
|
||||
image: {
|
||||
required: true
|
||||
},
|
||||
user_type: {
|
||||
required: true
|
||||
},
|
||||
schedule_radio1: {
|
||||
required: true
|
||||
},
|
||||
schedule_date: {
|
||||
required: function() {
|
||||
return $('#push_schedule_radi02').is(':checked');
|
||||
}
|
||||
},
|
||||
'states[]': {
|
||||
stateRequired: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
title: {
|
||||
required: 'Please enter this field'
|
||||
},
|
||||
description: {
|
||||
required: 'Please enter this field'
|
||||
},
|
||||
image: {
|
||||
required: 'Please upload an image file'
|
||||
},
|
||||
user_type: {
|
||||
required: 'Please select at least one category'
|
||||
},
|
||||
schedule_radio1: {
|
||||
required: 'Please select a delivery schedule'
|
||||
},
|
||||
schedule_date: {
|
||||
required: 'Please select a specific time'
|
||||
},
|
||||
'states[]': {
|
||||
stateRequired: 'Please select at least one state.'
|
||||
}
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
errorPlacement: function(error, element) {
|
||||
if (element.attr("name") == "user_type") {
|
||||
error.appendTo("#user_type_error").addClass('error-message');
|
||||
} else if (element.attr("name") == "schedule_radio1") {
|
||||
error.insertAfter("#push_schedule_radi02").addClass('error-message');
|
||||
} else if (element.attr("name") == "states[]") {
|
||||
error.insertAfter(`#dropdown-${$('input[name="user_type"]:checked').val()}`)
|
||||
error.appendTo("#user_type_error").addClass('error-message');
|
||||
} else {
|
||||
error.insertAfter(element).addClass('error-message');
|
||||
}
|
||||
},
|
||||
submitHandler: function(form) {
|
||||
var formData = new FormData(form);
|
||||
let base_url = url_path;
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: base_url + '/insert_notification',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
beforeSend: function() {
|
||||
$('#store_notification_btn').html('Please wait...');
|
||||
$('#store_notification_btn').attr('disabled', true);
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(result) {
|
||||
if (result.status_code == 200) {
|
||||
toastr.success(result.message);
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-notification";
|
||||
}, 2000);
|
||||
} else if (result.status_code == 422) {
|
||||
// Display validation errors using toastr
|
||||
$.each(result.errors, function(key, value) {
|
||||
toastr.error(value);
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-notification";
|
||||
}, 2000);
|
||||
});
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-notification";
|
||||
}, 2000);
|
||||
}
|
||||
$('#store_notification_btn').attr('disabled', false);
|
||||
$('#store_notification_btn').text('Submit');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Hide date and time input by default
|
||||
$('.checkbox-btsss').hide();
|
||||
|
||||
// Show/hide date and time input based on radio button selection
|
||||
$('#push_schedule_radi01').click(function() {
|
||||
$('.checkbox-btsss').hide();
|
||||
$('input[name="schedule_date"]').val(''); // Clear date and time input
|
||||
});
|
||||
|
||||
$('#push_schedule_radi02').click(function() {
|
||||
$('.checkbox-btsss').show();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
function handleUserTypeChange() {
|
||||
var dropdowns = [
|
||||
document.getElementById('dropdown-1'),
|
||||
document.getElementById('dropdown-2'),
|
||||
document.getElementById('dropdown-3')
|
||||
];
|
||||
|
||||
dropdowns.forEach(function(dropdown, index) {
|
||||
if (index + 1 == this.value) {
|
||||
dropdown.style.display = 'block';
|
||||
toggleCheckboxes(dropdown, false);
|
||||
} else {
|
||||
dropdown.style.display = 'none';
|
||||
toggleCheckboxes(dropdown, true);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
function toggleCheckboxes(dropdown, disable) {
|
||||
var checkboxes = dropdown.querySelectorAll('.form-check-input');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].disabled = disable;
|
||||
}
|
||||
}
|
||||
|
||||
var userTypeRadios = document.getElementsByName('user_type');
|
||||
for (var i = 0; i < userTypeRadios.length; i++) {
|
||||
userTypeRadios[i].addEventListener('change', handleUserTypeChange);
|
||||
}
|
||||
|
||||
var checkedRadio = document.querySelector('input[name="user_type"]:checked');
|
||||
if (checkedRadio) {
|
||||
handleUserTypeChange.call(checkedRadio);
|
||||
}
|
||||
|
||||
function handleSelectAllChange() {
|
||||
var dropdown = this.closest('div[id^="dropdown-"]');
|
||||
var checkboxes = dropdown.querySelectorAll('.state-checkbox');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = this.checked;
|
||||
}
|
||||
}
|
||||
|
||||
var selectAllCheckboxes = document.querySelectorAll('.select-all-checkbox');
|
||||
for (var i = 0; i < selectAllCheckboxes.length; i++) {
|
||||
selectAllCheckboxes[i].addEventListener('change', handleSelectAllChange);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function previewImage(event) {
|
||||
var input = event.target;
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function() {
|
||||
var preview = document.getElementById('preview');
|
||||
preview.src = reader.result;
|
||||
preview.style.display = 'block';
|
||||
};
|
||||
|
||||
if (input.files && input.files[0]) {
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
}
|
||||
139
public/assets/js/admin/manage_notification/edit.js
Normal file
139
public/assets/js/admin/manage_notification/edit.js
Normal file
@@ -0,0 +1,139 @@
|
||||
$(document).ready(function () {
|
||||
$('#editNotificationForm').validate({
|
||||
ignore: [],
|
||||
debug: false,
|
||||
rules: {
|
||||
type: {
|
||||
required: true
|
||||
},
|
||||
description: {
|
||||
required: true
|
||||
},
|
||||
delivery_schedule: {
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
type: {
|
||||
required: 'Please enter the notification title'
|
||||
},
|
||||
description: {
|
||||
required: 'Please enter the description'
|
||||
},
|
||||
delivery_schedule: {
|
||||
required: 'Please select a delivery schedule',
|
||||
}
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
submitHandler: function (form) {
|
||||
var formData = new FormData(form);
|
||||
|
||||
$('#update_notification').text('Please wait...');
|
||||
$('#update_notification').attr('disabled', true);
|
||||
let base_url = url_path;
|
||||
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: base_url + '/manage_update_notifications/',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (result) {
|
||||
if (result.status_code == 200) {
|
||||
toastr.success('Notification Updated Successfully');
|
||||
setTimeout(function () {
|
||||
window.location.href =
|
||||
"{{ route('manage.notification') }}";
|
||||
}, 2000);
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function () {
|
||||
window.location.href =
|
||||
"{{ route('manage.notification') }}";
|
||||
}, 2000);
|
||||
}
|
||||
$('#update_notification').attr('disabled', false);
|
||||
$('#update_notification').text('Submit');
|
||||
},
|
||||
error: function (xhr) {
|
||||
toastr.error('An error occurred: ' + xhr.responseText);
|
||||
$('#update_notification').attr('disabled', false);
|
||||
$('#update_notification').text('Submit');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$('input[name="user_type"]').change(function () {
|
||||
var selectedValue = $(this).val();
|
||||
|
||||
$('.dropdown-container').hide();
|
||||
|
||||
// Disable all checkboxes
|
||||
$('.dropdown-container input[type="checkbox"]').prop('disabled', true);
|
||||
|
||||
// Enable and show the checkboxes for the selected radio button
|
||||
$('#dropdown-' + selectedValue + '-edit').show();
|
||||
$('#dropdown-' + selectedValue + '-edit input[type="checkbox"]').prop('disabled', false);
|
||||
});
|
||||
|
||||
// Trigger the change event on page load to set the initial state
|
||||
$('input[name="user_type"]:checked').trigger('change');
|
||||
|
||||
// Select All functionality
|
||||
$('.select-all-checkbox').change(function () {
|
||||
var groupNumber = $(this).data('group');
|
||||
var isChecked = $(this).is(':checked');
|
||||
$('.state-group-' + groupNumber + '-checkbox').prop('checked', isChecked);
|
||||
});
|
||||
|
||||
// Check if all checkboxes are checked when loading the form
|
||||
$('.select-all-checkbox').each(function () {
|
||||
var groupNumber = $(this).data('group');
|
||||
var allChecked = $('.state-group-' + groupNumber + '-checkbox').length === $(
|
||||
'.state-group-' + groupNumber + '-checkbox:checked').length;
|
||||
$(this).prop('checked', allChecked);
|
||||
});
|
||||
|
||||
// Update "Select All" checkbox when any state checkbox is changed
|
||||
$('.state-checkbox').change(function () {
|
||||
var groupNumber = $(this).closest('.dropdown-container').find('.select-all-checkbox').data(
|
||||
'group');
|
||||
var allChecked = $('.state-group-' + groupNumber + '-checkbox').length === $(
|
||||
'.state-group-' + groupNumber + '-checkbox:checked').length;
|
||||
$('#select-all-' + groupNumber + '-edit').prop('checked', allChecked);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const imageInputEdit = document.getElementById('imageInputNormal');
|
||||
const imagePreviewEdit = document.getElementById('imageInputPreviewNormal');
|
||||
|
||||
imageInputEdit.addEventListener('change', function () {
|
||||
const file = this.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
const img = document.createElement('img');
|
||||
img.src = event.target.result;
|
||||
img.style.maxWidth = '60px';
|
||||
img.style.maxHeight = '60px';
|
||||
imagePreviewEdit.innerHTML = '';
|
||||
imagePreviewEdit.appendChild(img);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
imagePreviewEdit.innerHTML = '';
|
||||
}
|
||||
});
|
||||
88
public/assets/js/admin/manage_notification/main.js
Normal file
88
public/assets/js/admin/manage_notification/main.js
Normal file
@@ -0,0 +1,88 @@
|
||||
$(document).ready(function () {
|
||||
$('#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": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page _PAGE_ of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
|
||||
$('#zero-config-scheduled').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": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page _PAGE_ of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function toggleDropdown(event) {
|
||||
event.stopPropagation();
|
||||
const dropdownMenu = event.currentTarget.nextElementSibling;
|
||||
const isVisible = dropdownMenu.style.display === 'block';
|
||||
document.querySelectorAll('.dropdown-menu').forEach(menu => menu.style.display = 'none');
|
||||
dropdownMenu.style.display = isVisible ? 'none' : 'block';
|
||||
}
|
||||
|
||||
document.addEventListener('click', () => {
|
||||
document.querySelectorAll('.dropdown-menu').forEach(menu => menu.style.display = 'none');
|
||||
});
|
||||
|
||||
document.querySelectorAll('.dropdown-menu').forEach(menu => {
|
||||
menu.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.admin_delete_btn').on('click', function() {
|
||||
var id = $(this).data('id');
|
||||
$('#sub_admin_delete').val(id);
|
||||
});
|
||||
|
||||
|
||||
let base_url = url_path;
|
||||
|
||||
|
||||
$('.admin_delete').on('click', function() {
|
||||
var id = $('#sub_admin_delete').val();
|
||||
$.ajax({
|
||||
url: base_url + '/manage_delete_notifications/' + id,
|
||||
|
||||
type: 'POST',
|
||||
data: {
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(result) {
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr) {
|
||||
alert('An error occurred: ' + xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -209,70 +209,8 @@
|
||||
|
||||
|
||||
@section('section_script')
|
||||
<script src="../src/plugins/src/table/datatable/datatables.js"></script>
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/5.1.3/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="{{ asset('public/assets/js/admin/manage_notification/main.js') }}"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#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": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page _PAGE_ of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
|
||||
$('#zero-config-scheduled').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": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
|
||||
"sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>'
|
||||
},
|
||||
"sInfo": "Showing page _PAGE_ of _PAGES_",
|
||||
"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||
"sSearchPlaceholder": "Search...",
|
||||
"sLengthMenu": "Results : _MENU_",
|
||||
},
|
||||
"stripeClasses": [],
|
||||
"lengthMenu": [7, 10, 20, 50],
|
||||
"pageLength": 10
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function toggleDropdown(event) {
|
||||
event.stopPropagation();
|
||||
const dropdownMenu = event.currentTarget.nextElementSibling;
|
||||
const isVisible = dropdownMenu.style.display === 'block';
|
||||
document.querySelectorAll('.dropdown-menu').forEach(menu => menu.style.display = 'none');
|
||||
dropdownMenu.style.display = isVisible ? 'none' : 'block';
|
||||
}
|
||||
|
||||
document.addEventListener('click', () => {
|
||||
document.querySelectorAll('.dropdown-menu').forEach(menu => menu.style.display = 'none');
|
||||
});
|
||||
|
||||
document.querySelectorAll('.dropdown-menu').forEach(menu => {
|
||||
menu.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('<button><a class="extra-btn width-max-content" href="{{ route('manage_add_notifications') }}">Send Notification</a></button><button><ul class="navbar-item flex-row ms-lg-auto ms-0"><li class="nav-item dropdown action-dropdown order-lg-0 order-1"><a href="javascript:void(0);"class="nav-link dropdown-toggle user extra-btn" id="actionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="avatar-container"><div class="avatar avatar-sm avatar-indicators avatar-online"><h3>Filter</h3></div></div></a><div class="dropdown-menu position-absolute" aria-labelledby="actionDropdown"><div class="dropdown-item"><a href="{{ route('manage.notification') }}" id="allFilter"><span>All</span></a></div><div class="dropdown-item"><a href="{{ route('manage.notification', ['active' => 4]) }}" id="activeFilter"><span>Customer</span></a></div><div class="dropdown-item"><a href="{{ route('manage.notification', ['active' => 3]) }}" id="expiredFilter"> <span>Restaurant</span></a></div></div></li></ul></button>')
|
||||
@@ -338,34 +276,4 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.admin_delete_btn').on('click', function() {
|
||||
var id = $(this).data('id');
|
||||
$('#sub_admin_delete').val(id);
|
||||
});
|
||||
|
||||
|
||||
let base_url = url_path;
|
||||
|
||||
|
||||
$('.admin_delete').on('click', function() {
|
||||
var id = $('#sub_admin_delete').val();
|
||||
$.ajax({
|
||||
url: base_url + '/manage_delete_notifications/' + id,
|
||||
|
||||
type: 'POST',
|
||||
data: {
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(result) {
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr) {
|
||||
alert('An error occurred: ' + xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -210,146 +210,5 @@
|
||||
</div>
|
||||
@endsection
|
||||
@section('section_script')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#editNotificationForm').validate({
|
||||
ignore: [],
|
||||
debug: false,
|
||||
rules: {
|
||||
type: {
|
||||
required: true
|
||||
},
|
||||
description: {
|
||||
required: true
|
||||
},
|
||||
{{-- image: {
|
||||
extension: "jpg|jpeg|png|gif"
|
||||
}, --}}
|
||||
delivery_schedule: {
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
type: {
|
||||
required: 'Please enter the notification title'
|
||||
},
|
||||
description: {
|
||||
required: 'Please enter the description'
|
||||
},
|
||||
{{-- image: {
|
||||
extension: 'Please upload a valid image file (jpg, jpeg, png, gif)'
|
||||
}, --}}
|
||||
delivery_schedule: {
|
||||
required: 'Please select a delivery schedule',
|
||||
}
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
submitHandler: function(form) {
|
||||
var formData = new FormData(form);
|
||||
|
||||
$('#update_notification').text('Please wait...');
|
||||
$('#update_notification').attr('disabled', true);
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('manage_update_notifications') }}",
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(result) {
|
||||
if (result.status_code == 200) {
|
||||
toastr.success('Notification Updated Successfully');
|
||||
setTimeout(function() {
|
||||
window.location.href =
|
||||
"{{ route('manage.notification') }}";
|
||||
}, 2000);
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function() {
|
||||
window.location.href =
|
||||
"{{ route('manage.notification') }}";
|
||||
}, 2000);
|
||||
}
|
||||
$('#update_notification').attr('disabled', false);
|
||||
$('#update_notification').text('Submit');
|
||||
},
|
||||
error: function(xhr) {
|
||||
toastr.error('An error occurred: ' + xhr.responseText);
|
||||
$('#update_notification').attr('disabled', false);
|
||||
$('#update_notification').text('Submit');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('input[name="user_type"]').change(function() {
|
||||
var selectedValue = $(this).val();
|
||||
|
||||
$('.dropdown-container').hide();
|
||||
|
||||
// Disable all checkboxes
|
||||
$('.dropdown-container input[type="checkbox"]').prop('disabled', true);
|
||||
|
||||
// Enable and show the checkboxes for the selected radio button
|
||||
$('#dropdown-' + selectedValue + '-edit').show();
|
||||
$('#dropdown-' + selectedValue + '-edit input[type="checkbox"]').prop('disabled', false);
|
||||
});
|
||||
|
||||
// Trigger the change event on page load to set the initial state
|
||||
$('input[name="user_type"]:checked').trigger('change');
|
||||
|
||||
// Select All functionality
|
||||
$('.select-all-checkbox').change(function() {
|
||||
var groupNumber = $(this).data('group');
|
||||
var isChecked = $(this).is(':checked');
|
||||
$('.state-group-' + groupNumber + '-checkbox').prop('checked', isChecked);
|
||||
});
|
||||
|
||||
// Check if all checkboxes are checked when loading the form
|
||||
$('.select-all-checkbox').each(function() {
|
||||
var groupNumber = $(this).data('group');
|
||||
var allChecked = $('.state-group-' + groupNumber + '-checkbox').length === $('.state-group-' + groupNumber + '-checkbox:checked').length;
|
||||
$(this).prop('checked', allChecked);
|
||||
});
|
||||
|
||||
// Update "Select All" checkbox when any state checkbox is changed
|
||||
$('.state-checkbox').change(function() {
|
||||
var groupNumber = $(this).closest('.dropdown-container').find('.select-all-checkbox').data('group');
|
||||
var allChecked = $('.state-group-' + groupNumber + '-checkbox').length === $('.state-group-' + groupNumber + '-checkbox:checked').length;
|
||||
$('#select-all-' + groupNumber + '-edit').prop('checked', allChecked);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
const imageInputEdit = document.getElementById('imageInputNormal');
|
||||
const imagePreviewEdit = document.getElementById('imageInputPreviewNormal');
|
||||
|
||||
imageInputEdit.addEventListener('change', function() {
|
||||
const file = this.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
const img = document.createElement('img');
|
||||
img.src = event.target.result;
|
||||
img.style.maxWidth = '60px';
|
||||
img.style.maxHeight = '60px';
|
||||
imagePreviewEdit.innerHTML = '';
|
||||
imagePreviewEdit.appendChild(img);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
imagePreviewEdit.innerHTML = '';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script src="{{ asset('public/assets/js/admin/manage_notification/edit.js') }}"></script>
|
||||
@endsection
|
||||
|
||||
@@ -189,212 +189,5 @@
|
||||
</div>
|
||||
@endsection
|
||||
@section('section_script')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Custom validator for checking state checkboxes
|
||||
$.validator.addMethod('stateRequired', function(value, element) {
|
||||
let selectedUserType = $('input[name="user_type"]:checked').val();
|
||||
if (selectedUserType) {
|
||||
let dropdownId = `dropdown-${selectedUserType}`;
|
||||
return $(`#${dropdownId} .state-checkbox:checked`).length > 0;
|
||||
}
|
||||
return true;
|
||||
}, 'Please select at least one state.');
|
||||
|
||||
// Validate the form
|
||||
$('#send_notification_form').validate({
|
||||
ignore: [],
|
||||
debug: false,
|
||||
rules: {
|
||||
title: {
|
||||
required: true
|
||||
},
|
||||
description: {
|
||||
required: true
|
||||
},
|
||||
image: {
|
||||
required: true
|
||||
},
|
||||
user_type: {
|
||||
required: true
|
||||
},
|
||||
schedule_radio1: {
|
||||
required: true
|
||||
},
|
||||
schedule_date: {
|
||||
required: function() {
|
||||
return $('#push_schedule_radi02').is(':checked');
|
||||
}
|
||||
},
|
||||
'states[]': {
|
||||
stateRequired: true
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
title: {
|
||||
required: 'Please enter this field'
|
||||
},
|
||||
description: {
|
||||
required: 'Please enter this field'
|
||||
},
|
||||
image: {
|
||||
required: 'Please upload an image file'
|
||||
},
|
||||
user_type: {
|
||||
required: 'Please select at least one category'
|
||||
},
|
||||
schedule_radio1: {
|
||||
required: 'Please select a delivery schedule'
|
||||
},
|
||||
schedule_date: {
|
||||
required: 'Please select a specific time'
|
||||
},
|
||||
'states[]': {
|
||||
stateRequired: 'Please select at least one state.'
|
||||
}
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
errorPlacement: function(error, element) {
|
||||
if (element.attr("name") == "user_type") {
|
||||
error.appendTo("#user_type_error").addClass('error-message');
|
||||
} else if (element.attr("name") == "schedule_radio1") {
|
||||
error.insertAfter("#push_schedule_radi02").addClass('error-message');
|
||||
} else if (element.attr("name") == "states[]") {
|
||||
error.insertAfter(`#dropdown-${$('input[name="user_type"]:checked').val()}`)
|
||||
error.appendTo("#user_type_error").addClass('error-message');
|
||||
} else {
|
||||
error.insertAfter(element).addClass('error-message');
|
||||
}
|
||||
},
|
||||
submitHandler: function(form) {
|
||||
var formData = new FormData(form);
|
||||
let base_url = url_path;
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: base_url + '/insert_notification',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
beforeSend: function() {
|
||||
$('#store_notification_btn').html('Please wait...');
|
||||
$('#store_notification_btn').attr('disabled', true);
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(result) {
|
||||
if (result.status_code == 200) {
|
||||
toastr.success(result.message);
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-notification";
|
||||
}, 2000);
|
||||
} else if (result.status_code == 422) {
|
||||
// Display validation errors using toastr
|
||||
$.each(result.errors, function(key, value) {
|
||||
toastr.error(value);
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-notification";
|
||||
}, 2000);
|
||||
});
|
||||
} else {
|
||||
toastr.error('Something Went Wrong');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-notification";
|
||||
}, 2000);
|
||||
}
|
||||
$('#store_notification_btn').attr('disabled', false);
|
||||
$('#store_notification_btn').text('Submit');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Hide date and time input by default
|
||||
$('.checkbox-btsss').hide();
|
||||
|
||||
// Show/hide date and time input based on radio button selection
|
||||
$('#push_schedule_radi01').click(function() {
|
||||
$('.checkbox-btsss').hide();
|
||||
$('input[name="schedule_date"]').val(''); // Clear date and time input
|
||||
});
|
||||
|
||||
$('#push_schedule_radi02').click(function() {
|
||||
$('.checkbox-btsss').show();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
function handleUserTypeChange() {
|
||||
var dropdowns = [
|
||||
document.getElementById('dropdown-1'),
|
||||
document.getElementById('dropdown-2'),
|
||||
document.getElementById('dropdown-3')
|
||||
];
|
||||
|
||||
dropdowns.forEach(function(dropdown, index) {
|
||||
if (index + 1 == this.value) {
|
||||
dropdown.style.display = 'block';
|
||||
toggleCheckboxes(dropdown, false);
|
||||
} else {
|
||||
dropdown.style.display = 'none';
|
||||
toggleCheckboxes(dropdown, true);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
function toggleCheckboxes(dropdown, disable) {
|
||||
var checkboxes = dropdown.querySelectorAll('.form-check-input');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].disabled = disable;
|
||||
}
|
||||
}
|
||||
|
||||
var userTypeRadios = document.getElementsByName('user_type');
|
||||
for (var i = 0; i < userTypeRadios.length; i++) {
|
||||
userTypeRadios[i].addEventListener('change', handleUserTypeChange);
|
||||
}
|
||||
|
||||
var checkedRadio = document.querySelector('input[name="user_type"]:checked');
|
||||
if (checkedRadio) {
|
||||
handleUserTypeChange.call(checkedRadio);
|
||||
}
|
||||
|
||||
function handleSelectAllChange() {
|
||||
var dropdown = this.closest('div[id^="dropdown-"]');
|
||||
var checkboxes = dropdown.querySelectorAll('.state-checkbox');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = this.checked;
|
||||
}
|
||||
}
|
||||
|
||||
var selectAllCheckboxes = document.querySelectorAll('.select-all-checkbox');
|
||||
for (var i = 0; i < selectAllCheckboxes.length; i++) {
|
||||
selectAllCheckboxes[i].addEventListener('change', handleSelectAllChange);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function previewImage(event) {
|
||||
var input = event.target;
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function() {
|
||||
var preview = document.getElementById('preview');
|
||||
preview.src = reader.result;
|
||||
preview.style.display = 'block';
|
||||
};
|
||||
|
||||
if (input.files && input.files[0]) {
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="{{ asset('public/assets/js/admin/manage_notification/add.js') }}"></script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user