changes in notification
This commit is contained in:
@@ -86,178 +86,184 @@ class ManageNotificationsController extends Controller
|
||||
* Use : To add notification .
|
||||
*/
|
||||
|
||||
public function store_notificaton_data(Request $request)
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
public function store_notificaton_data(Request $request)
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
DB::beginTransaction();
|
||||
|
||||
if (isset($request->image)) {
|
||||
$image = $request->image;
|
||||
$image_db = null;
|
||||
} else {
|
||||
$image = null;
|
||||
$image_db = $request->image;
|
||||
}
|
||||
if (isset($request->image)) {
|
||||
$image = $request->image;
|
||||
$image_db = null;
|
||||
} else {
|
||||
$image = null;
|
||||
$image_db = $request->image;
|
||||
}
|
||||
|
||||
$tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db);
|
||||
$imagePath = ListingImageUrl('notification_images', $tnormalImage);
|
||||
$tnormalImage = saveSingleImageWithoutCrop($image, 'notification_images', $image_db);
|
||||
$imagePath = ListingImageUrl('notification_images', $tnormalImage);
|
||||
|
||||
$states = $request->states;
|
||||
$states = $request->states;
|
||||
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$iamPrincipals = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->get();
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
$iamPrincipals = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->get();
|
||||
|
||||
$iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid');
|
||||
$iamPrincipalIds = $iamPrincipals->pluck('iam_principal_xid');
|
||||
|
||||
$subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
$subscribe = IamPrincipal::whereIn('id', $iamPrincipalIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
|
||||
if ($request->user_type == 1) {
|
||||
$allCustomerOneSignalIds = $subscribe->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
|
||||
$scheduled = false;
|
||||
|
||||
foreach ($UserData as $customerIdItem) {
|
||||
// user_type 1 = subscribed user
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $customerIdItem->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
if ($request->user_type == 1) {
|
||||
$allCustomerOneSignalIds = $subscribe->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
|
||||
|
||||
]);
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($customerIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerIdItem->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
} elseif ($request->user_type == 2) {
|
||||
//user_type 2 unsubscribed users
|
||||
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)
|
||||
->pluck('id');
|
||||
foreach ($UserData as $customerIdItem) {
|
||||
// user_type 1 = subscribed user
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $customerIdItem->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
]);
|
||||
$scheduled = true;
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($customerIdItem->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$customerIdItem->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($customerIdItem->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
} elseif ($request->user_type == 2) {
|
||||
// user_type 2 unsubscribed users
|
||||
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)
|
||||
->pluck('id');
|
||||
|
||||
$subscribedIds = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->pluck('iam_principal_xid');
|
||||
$subscribedIds = Subscriptions::select('iam_principal_xid')
|
||||
->where('next_payment_date', '>=', $formattedDateTime)
|
||||
->pluck('iam_principal_xid');
|
||||
|
||||
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
|
||||
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
|
||||
|
||||
$unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
$unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds)
|
||||
->where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->whereIn('state_xid', $states)
|
||||
->get();
|
||||
|
||||
$allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id');
|
||||
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
|
||||
$allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id');
|
||||
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
|
||||
|
||||
foreach ($restaurantData as $restaurantsData) {
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $restaurantsData->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
foreach ($restaurantData as $restaurantsData) {
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $restaurantsData->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
]);
|
||||
$scheduled = true;
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($restaurantsData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$restaurantsData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
$request->title,
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
} elseif ($request->user_type == 3) {
|
||||
// user_type 3 = subscribed and unsubscribed users
|
||||
$userQuery = IamPrincipal::where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $states);
|
||||
|
||||
$allUserOneSignalIds = $userQuery->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get();
|
||||
|
||||
]);
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($restaurantsData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$restaurantsData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
$request->title,
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($restaurantsData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
} elseif ($request->user_type == 3) {
|
||||
// user_type 3 = subscribed and unsubscribed users
|
||||
$userQuery = IamPrincipal::where('is_active', 1)
|
||||
->where('notification_status', 1)
|
||||
->where('principal_type_xid', 3)
|
||||
->whereIn('state_xid', $states);
|
||||
foreach ($UserData as $CustomerData) {
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $CustomerData->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
]);
|
||||
$scheduled = true;
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($CustomerData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$CustomerData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$allUserOneSignalIds = $userQuery->pluck('id');
|
||||
$UserData = IamPrincipal::whereIn('id', $allUserOneSignalIds)->get();
|
||||
DB::commit();
|
||||
|
||||
foreach ($UserData as $CustomerData) {
|
||||
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
|
||||
// Scheduled Notification
|
||||
NotificationDetails::create([
|
||||
'principal_xid' => $CustomerData->id,
|
||||
'description' => $request->description,
|
||||
'type' => $request->title,
|
||||
'image' => $imagePath,
|
||||
'date_added' => $request->schedule_date,
|
||||
'is_schedule' => 1,
|
||||
'delivery_schedule' => $request->schedule_date,
|
||||
'is_active' => 0,
|
||||
if ($scheduled) {
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data_scheduled'));
|
||||
} else {
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data_immediate'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Notification send Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
]);
|
||||
} else {
|
||||
// Immediate Notification
|
||||
if ($CustomerData->one_signal_player_id) {
|
||||
onesignalhelper::sendNotificationApi(
|
||||
$CustomerData->one_signal_player_id,
|
||||
$request->title,
|
||||
$request->description,
|
||||
'Dashboard Notification',
|
||||
$imagePath,
|
||||
$id = null
|
||||
);
|
||||
}
|
||||
onesignalhelper::StoreNotificationDetails($CustomerData->id, 'Notification', $request->title, $imagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
return jsonResponseWithSuccessMessage(__('success.save_data'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("Notification send Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,8 @@ return [
|
||||
'authentic_success' => 'Authentication Successful',
|
||||
'confirmed_password' => 'please confirm your passsword',
|
||||
'redeemed_successfully' => 'Referral code redeemed successfully.',
|
||||
'save_data_scheduled' => 'Notification Schedule Successfully.',
|
||||
'save_data_immediate' => 'Notification Sent Successfully.',
|
||||
|
||||
|
||||
];
|
||||
|
||||
@@ -57,7 +57,10 @@
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="company-name" class="label">Upload Image</label>
|
||||
<input type="file" class="form-control" name="image" accept="image/*">
|
||||
<input type="file" class="form-control" name="image" accept="image/*"
|
||||
onchange="previewImage(event)">
|
||||
<img id="preview" src="#" alt="your image" class="mt-3"
|
||||
style="display:none;width:20%;" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@@ -138,10 +141,12 @@
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="notification-card">
|
||||
<h6>Delivery Schedule</h6>
|
||||
<label for="company-name" class="label">Delivery Schedule</label>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h6>When should this message start sending?</h6>
|
||||
<label for="company-name" class="label">When should this message
|
||||
start sending?</label>
|
||||
<div class="form-group radio-btn">
|
||||
<input type="radio" class="form-control" name="schedule_radio1"
|
||||
id="push_schedule_radi01" value="0">
|
||||
@@ -182,193 +187,212 @@
|
||||
</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.');
|
||||
<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.insertAfter("#select-ids").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()}`).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);
|
||||
// Validate the form
|
||||
$('#send_notification_form').validate({
|
||||
ignore: [],
|
||||
debug: false,
|
||||
rules: {
|
||||
title: {
|
||||
required: true
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(result) {
|
||||
if (result.status_code == 200) {
|
||||
toastr.success('Data Added Successfully');
|
||||
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);
|
||||
description: {
|
||||
required: true
|
||||
},
|
||||
image: {
|
||||
required: true
|
||||
},
|
||||
user_type: {
|
||||
required: true
|
||||
},
|
||||
schedule_radio1: {
|
||||
required: true
|
||||
},
|
||||
schedule_date: {
|
||||
required: function() {
|
||||
return $('#push_schedule_radi02').is(':checked');
|
||||
}
|
||||
$('#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);
|
||||
'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.insertAfter("#select-ids").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()}`)
|
||||
.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');
|
||||
},
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
|
||||
function toggleCheckboxes(dropdown, disable) {
|
||||
var checkboxes = dropdown.querySelectorAll('.form-check-input');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].disabled = disable;
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
@endsection
|
||||
|
||||
@@ -1,83 +1,91 @@
|
||||
@extends('Admin.layouts.master')
|
||||
|
||||
@section('content')
|
||||
@php
|
||||
$currentPage = 'manage-notification';
|
||||
@endphp
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
<div class="top-tabel">
|
||||
<div class="row">
|
||||
<div class="col-md-4 left">
|
||||
<a class="d-flex align-items-center justify-content-center pl-2"
|
||||
href="{{ route('manage.notification')}}">
|
||||
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg')}}">
|
||||
<h6 class="card-title p-0">View Details</h6>
|
||||
</a>
|
||||
</div>
|
||||
@php
|
||||
$currentPage = 'manage-notification';
|
||||
@endphp
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
<div class="top-tabel">
|
||||
<div class="row">
|
||||
<div class="col-md-4 left">
|
||||
<a class="d-flex align-items-center justify-content-center pl-2"
|
||||
href="{{ route('manage.notification') }}">
|
||||
<img class="back-btn" src="{{ asset('public/assets/img/left-arrow.svg') }}">
|
||||
<h6 class="card-title p-0">View Details</h6>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
|
||||
<div class="widget-content widget-content-area br-8 position-btn p-0">
|
||||
<div class="view-details">
|
||||
<div class="simple-tab">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel"
|
||||
aria-labelledby="home-tab" tabindex="0">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-10 tabs23">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Notification content :</td>
|
||||
<td>Created Date :</td>
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
<td>{{ $notification->description }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="col-md-6 mb-10">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Recipients :</td>
|
||||
{{-- <td>Last Modified Date :</td> --}}
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
</div>
|
||||
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
|
||||
<div class="widget-content widget-content-area br-8 position-btn p-0">
|
||||
<div class="view-details">
|
||||
<div class="simple-tab">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel"
|
||||
aria-labelledby="home-tab" tabindex="0">
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-10 tabs23">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Message :</td>
|
||||
<td>Description :</td>
|
||||
<td>Created Date :</td>
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
<td>{{ $notification->type }}</td>
|
||||
<td>{{ $notification->description }}</td>
|
||||
|
||||
<td>@if($notification->notification->principal_type_xid == '3')
|
||||
Customer
|
||||
@else
|
||||
Resturant
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="col-md-6 mb-10">
|
||||
<table>
|
||||
<tr class="title">
|
||||
<td>Recipients :</td>
|
||||
<td>Image :</td>
|
||||
|
||||
{{-- <td>Last Modified Date :</td> --}}
|
||||
</tr>
|
||||
<tr class="w-100">
|
||||
|
||||
<td>
|
||||
@if ($notification->notification->principal_type_xid == '3')
|
||||
Customer
|
||||
@else
|
||||
Resturant
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<img src="{{ $notification->image }}" alt="Notification Image"
|
||||
style="max-width: 100px; max-height: 100px;">
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user