Merge pull request #359 from WDI-Ideas/sayli

Sayli
This commit is contained in:
Sayli Raut
2024-07-19 19:13:37 +05:30
committed by GitHub
5 changed files with 828 additions and 247 deletions

View File

@@ -68,16 +68,16 @@ class ManageNotificationsController extends Controller
->get();
$notifications = $notificationsOfType3->merge($notificationsOfType4);
$scheduledNotifications = NotificationDetails::where('is_schedule', 1)->where('is_active', 1)->orderByDesc('id')->get();
}
return view('Admin.pages.manage_notification.manage_notification', compact('notifications'));
return view('Admin.pages.manage_notification.manage_notification', compact('notifications', 'scheduledNotifications'));
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To view notification details.s
* Use : To view add notification.
*/
public function add()
{
@@ -88,180 +88,217 @@ class ManageNotificationsController extends Controller
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To add notification .
* Use : To store notification .
*/
public function store_notification_data(Request $request)
{
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
]);
public function store_notification_data(Request $request)
{
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
]);
DB::beginTransaction();
DB::beginTransaction();
$imagePath = null;
if ($request->hasFile('image')) {
$image = $request->file('image');
$imagePath = saveSingleImageWithoutCrop($image, 'notification_images');
$imagePath = ListingImageUrl('notification_images', $imagePath);
}
$imagePath = null;
if ($request->hasFile('image')) {
$image = $request->file('image');
$imagePath = saveSingleImageWithoutCrop($image, 'notification_images');
$imagePath = ListingImageUrl('notification_images', $imagePath);
}
$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();
$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();
$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();
$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();
$scheduled = false;
$scheduled = false;
if ($request->user_type == 1) {
$allCustomerOneSignalIds = $subscribe->pluck('id');
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
if ($request->user_type == 1) {
$allCustomerOneSignalIds = $subscribe->pluck('id');
$UserData = IamPrincipal::whereIn('id', $allCustomerOneSignalIds)->get();
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
NotificationDetails::create([
'user_type' => $request->user_type,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'state_ids' => json_encode($states),
]);
$scheduled = true;
} else {
foreach ($UserData as $customerIdItem) {
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) {
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)->pluck('id');
$subscribedIds = Subscriptions::select('iam_principal_xid')
->where('next_payment_date', '>=', $formattedDateTime)
->pluck('iam_principal_xid');
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
$unsubscribedPrincipals = IamPrincipal::whereIn('id', $unsubscribedIds)
->where('is_active', 1)
->where('notification_status', 1)
->whereIn('state_xid', $states)
->get();
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
NotificationDetails::create([
'user_type' => $request->user_type,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'state_ids' => json_encode($states),
]);
$scheduled = true;
} else {
foreach ($UserData as $customerIdItem) {
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) {
$allPrincipalIds = IamPrincipal::where('principal_type_xid', 3)->pluck('id');
$subscribedIds = Subscriptions::select('iam_principal_xid')
->where('next_payment_date', '>=', $formattedDateTime)
->pluck('iam_principal_xid');
$unsubscribedIds = $allPrincipalIds->diff($subscribedIds);
$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();
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
NotificationDetails::create([
'user_type' => $request->user_type,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'state_ids' => json_encode($states),
]);
$scheduled = true;
} else {
foreach ($restaurantData as $restaurantsData) {
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) {
$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();
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
NotificationDetails::create([
'user_type' => $request->user_type,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'state_ids' => json_encode($states),
]);
$scheduled = true;
} else {
foreach ($UserData as $CustomerData) {
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();
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);
}
}
$allRestaurantOneSignalIds = $unsubscribedPrincipals->pluck('id');
$restaurantData = IamPrincipal::whereIn('id', $allRestaurantOneSignalIds)->get();
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
NotificationDetails::create([
'user_type' => $request->user_type,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'state_ids' => json_encode($states),
]);
$scheduled = true;
} else {
foreach ($restaurantData as $restaurantsData) {
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) {
$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();
if ($request->schedule_radio1 == 1 && $request->schedule_date) {
NotificationDetails::create([
'user_type' => $request->user_type,
'description' => $request->description,
'type' => $request->title,
'image' => $imagePath,
'date_added' => $request->schedule_date,
'is_schedule' => 1,
'delivery_schedule' => $request->schedule_date,
'state_ids' => json_encode($states),
]);
$scheduled = true;
} else {
foreach ($UserData as $CustomerData) {
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();
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);
}
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To view notification details.s
* Use : To view notification detail.
*/
public function view($id)
{
$notification = NotificationDetails::with('notification')->findOrFail($id);
return view('Admin.pages.manage_notification.manage_notifications_view', compact('notification'));
}
public function edit($id)
{
$edit_notification = NotificationDetails::findOrFail($id);
$states = ManageState::where('is_active', 1)->get();
return view('Admin.pages.manage_notification.manage_notification_edit', compact('edit_notification', 'states'));
}
public function update(Request $request)
{
try {
$notification = NotificationDetails::findOrFail($request->id);
$notification->type = $request->type;
$notification->description = $request->description;
$notification->delivery_schedule = $request->delivery_schedule;
if ($request->hasFile('image')) {
$image = $request->file('image');
$imagePath = saveSingleImageWithoutCrop($image, 'notification_images');
$imagePath = ListingImageUrl('notification_images', $imagePath);
$notification->image = $imagePath;
}
$notification->user_type = $request->user_type;
$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());
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
public function delete($id)
{
$data = NotificationDetails::find($id)->delete();
return redirect()->back()->with('success', '');
}
}

View File

@@ -4,91 +4,203 @@
@php
$currentPage = 'manage-notification';
@endphp
<style>
.action-buttons {
display: flex;
gap: 10px; /* Adjust the value to control the space between buttons */
}
</style>
<div class="layout-px-spacing">
<div class="middle-content container-xxl p-0">
<div class="row layout-top-spacing ">
<div class="row layout-top-spacing">
<div class="top-tabel">
<div class="row">
<div class="col-md-4">
<h6 class="card-title">Manage Notification</h6>
</div>
<div class="col-md-8">
<div class="col-md-8"></div>
</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">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home"
role="tab" aria-controls="pills-home" aria-selected="true">Sent</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile"
role="tab" aria-controls="pills-profile" aria-selected="false">Scheduled</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel"
aria-labelledby="pills-home-tab">
<table id="zero-config" class="table dt-table-hover" style="width:100%">
<thead class="text-center">
<tr>
<th class="text-start">Sr No.</th>
<th class="text-start">Notification Content</th>
<th class="text-start">Email</th>
<th class="text-start">Created Date</th>
<th class="text-start">Recipients</th>
<th class="text-start">Date Sent</th>
<th class="no-content">Action</th>
</tr>
</thead>
<tbody class="text-center">
@foreach ($notifications as $notification)
<tr>
<td class="text-start">{{ $loop->iteration }}</td>
<td class="text-start">{{ $notification->type }}</td>
<td class="text-start">{{ $notification->Notification->email_address }}</td>
<td class="text-start">
{{ \Carbon\Carbon::parse($notification->created_at)->format('m/d/Y') }}
</td>
<td class="text-start">
@if ($notification->Notification->principal_type_xid == '3')
Customer
@else
Restaurant
@endif
</td>
<td class="text-start">
{{ \Carbon\Carbon::parse($notification->date_added)->format('m/d/Y') }}
</td>
<td>
<div class="dropout">
<button class="more">
<span></span>
<span></span>
<span></span>
</button>
<ul>
<li>
<a
href="{{ url('/manage_edit_notifications/' . $notification->id) }}">
<img src="{{ asset('public/assets/img/view.svg') }}" />
<span>View</span>
</a>
</li>
</ul>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<!-- Scheduled Notifications Tab -->
<div class="tab-pane fade" id="pills-profile" role="tabpanel"
aria-labelledby="pills-profile-tab">
<table id="zero-config-scheduled" class="table dt-table-hover" style="width:100%">
<thead class="text-center">
<tr>
<th class="text-start">Sr No.</th>
<th class="text-start">Notification Content</th>
<th class="text-start">Created Date</th>
<th class="text-start">Scheduled Date</th>
<th class="text-start">View</th>
<th class="no-content">Status</th>
<th class="no-content">Actions</th>
</tr>
</thead>
<tbody class="text-center">
@foreach ($scheduledNotifications as $notification)
<tr>
<td class="text-start">{{ $loop->iteration }}</td>
<td class="text-start">{{ $notification->type }}</td>
<td class="text-start">
{{ \Carbon\Carbon::parse($notification->created_at)->format('m/d/Y') }}
</td>
<td class="text-start">
{{ \Carbon\Carbon::parse($notification->delivery_schedule)->format('m/d/Y') }}
</td>
<td>
<a class="view-btn m-0"
href="{{ url('/manage_view_notifications/' . $notification->id) }}">
<span>View</span>
</a>
</td>
<td class="text-start">Scheduled</td>
<td>
<div class="dropout">
<div class="action-buttons">
<a class="action-btn reply-button"
href="{{ url('/manage_edit_notifications/' . $notification->id) }}">
<img src="{{ asset('public/assets/img/edit.svg') }}" />
<span>Edit</span>
</a>
<a href="" data-toggle="modal"
data-target="#delete-modal" class="admin_delete_btn"
data-id="{{ $notification->id }}">
<img
src="{{ asset('public/assets/img/delete-recycle.svg') }}" />
<span>Delete</span>
</a>
</div>
</div>
</td>
</tr>
<div class="modal fade" id="delete-modal" tabindex="-1" role="dialog"
aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-dismiss="modal"
aria-label="Close">
x
</button>
</div>
<div class="modal-body">
<p class="modal-text">Are you sure you want to<br>Delete </p>
<input type="hidden" id="sub_admin_delete">
<div class="modal-btn d-flex ">
<a class="extra-btn" href="#"
data-dismiss="modal">No</a>
<a class="download-btn-custom admin_delete"
data-dismiss="modal">Yes</a>
</div>
</div>
</div>
</div>
</div>
@endforeach
</tbody>
</table>
</div>
</div>
</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">
<table id="zero-config" class="table dt-table-hover" style="width:100%">
<thead class="text-center">
<tr>
<th class="text-start">Sr No.</th>
<th class="text-start">Notification content</th>
<th class="text-start">Email</th>
<th class="text-start">Created Date</th>
<th class="text-start">Recipients</th>
<th class="text-start">Date sent</th>
<th class="no-content">Status</th>
</tr>
</thead>
<tbody class="text-center">
@foreach ($notifications as $notification)
<tr>
<td class="text-start">{{ $loop->iteration }}</td>
<td class="text-start">{{ $notification->type }}</td>
<td class="text-start">{{ $notification->Notification->email_address }}</td>
<td class="text-start">
{{ \Carbon\Carbon::parse($notification->created_at)->format('m/d/Y') }}</td>
<td class="text-start">
@if ($notification->Notification->principal_type_xid == '3')
Customer
@else
Resturant
@endif
</td>
<td class="text-start">
{{ \Carbon\Carbon::parse($notification->date_added)->format('m/d/Y') }}</td>
<td>
<div class="dropout">
<button class="more">
<span></span>
<span></span>
<span></span>
</button>
<ul>
<li>
<a
href="{{ url('/manage_view_notifications/' . $notification->id) }}">
<img src="{{ asset('public/assets/img/view.svg') }}" />
<span>View</span>
</a>
</li>
{{-- <li>
<a href="{{ route('manage_edit_notifications') }}">
<img src="{{ asset('public/assets/img/edit.svg') }}" />
<span>Edit</span>
</a>
</li> --}}
{{-- <li>
<a href="" data-toggle="modal" data-target="#delete-modal">
<img
src="{{ asset('public/assets/img/delete-recycle.svg') }}" />
<span>Delete</span>
</a>
</li> --}}
</ul>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="modal fade" id="delete-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">
x
</button>
</div>
<div class="modal-body">
<p class="modal-text">Are you sure you want to<br>Delete </p>
<input type="hidden" id="sub_admin_delete">
<div class="modal-btn d-flex ">
<a class="extra-btn" href="#" data-dismiss="modal">No</a>
<a class="download-btn-custom admin_delete" data-dismiss="modal">Yes</a>
</div>
</div>
</div>
</div>
@@ -98,24 +210,67 @@
@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>
$('#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>'
$(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_",
},
"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
"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>
@@ -183,4 +338,34 @@
}
}
</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

View File

@@ -0,0 +1,355 @@
@extends('Admin.layouts.master')
@section('content')
@php
$currentPage = 'manage_cms';
@endphp
<style>
.error-message {
color: #FF0000;
}
form .error-message {
color: red;
/* Set your desired color here */
}
form .input_class.error-message {
color: #0e1726;
}
</style>
<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-12 left d-flex align-items-center justify-content-between" style="gap: 15px;">
<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">Edit Notification</h6>
</a>
</div>
</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">
<form method="POST" id="editNotificationForm" class="form py-5 pb-0"
action="javascript:void(0)" enctype="multipart/form-data">
@csrf
<div class="row">
<div class="col-md-6">
<input type="hidden" name="id" id="id"
value="{{ $edit_notification->id }}" />
<div class="form-group">
<label for="company-name" class="label">Notification Title</label>
<input type="text" class="form-control" id="type"
name="type" value="{{ $edit_notification->type }}" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description" name="description" rows="3" required>{{ $edit_notification->description }}</textarea>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<label for="company-name" class="label">Image</label>
<input type="file" accept="image/*" class="form-control"
name="image" id="imageInputNormal">
<div id="imageInputPreviewNormal" style="width: 30%;">
<img src="{{ $edit_notification->image }}" alt="Image Preview"
style="width: 40%;">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="delivery_schedule">Delivery Schedule</label>
<input type="datetime-local" class="form-control"
id="delivery_schedule" name="delivery_schedule"
min="{{ date('Y-m-d\TH:i') }}"
value="{{ \Carbon\Carbon::parse($edit_notification->delivery_schedule)->format('Y-m-d\TH:i') }}"
required>
</div>
</div>
@php
$stateIds = json_decode($edit_notification->state_ids, true);
if (!is_array($stateIds)) {
$stateIds = [];
}
@endphp
<div class="col-md-6">
<div class="form-group">
<label for="location" class="label">When should this message start
sending:</label>
<div
class="form-check form-check-sm form-check-custom form-check-solid me-3">
<!-- Radio Button 1 -->
<input class="form-check-input" type="radio" name="user_type"
value="1" id="select-all-ids-edit"
{{ $edit_notification->user_type == 1 ? 'checked' : '' }} />
<label class="form-check-label" for="select-all-ids-edit">Send
to subscribed users who are in their respective
states</label><br>
<div id="dropdown-1-edit"
class="dropdown-container state-group-1"
style="display: {{ $edit_notification->user_type == 1 ? 'block' : 'none' }}; max-height: 200px; overflow-y: auto;">
<div class="form-check">
<input class="form-check-input select-all-checkbox"
type="checkbox" id="select-all-1-edit"
data-group="1" />
<label class="form-check-label"
for="select-all-1-edit">Select All States</label>
</div>
@foreach ($states as $state)
<div class="form-check">
<input
class="form-check-input state-checkbox state-group-1-checkbox"
type="checkbox" name="state_ids[]"
value="{{ $state->id }}"
id="state-1-{{ $state->id }}"
{{ in_array($state->id, $stateIds) ? 'checked' : '' }} />
<label class="form-check-label"
for="state-1-{{ $state->id }}">{{ $state->name }}</label>
</div>
@endforeach
</div>
<!-- Radio Button 2 -->
<input class="form-check-input" type="radio"
name="user_type" id="select-popular-ids-edit"
value="2"
{{ $edit_notification->user_type == 2 ? 'checked' : '' }} />
<label class="form-check-label"
for="select-popular-ids-edit">Send to unsubscribed users
who are in their respective states</label><br>
<div id="dropdown-2-edit"
class="dropdown-container state-group-2"
style="display: {{ $edit_notification->user_type == 2 ? 'block' : 'none' }}; max-height: 200px; overflow-y: auto;">
<div class="form-check">
<input class="form-check-input select-all-checkbox"
type="checkbox" id="select-all-2-edit"
data-group="2" />
<label class="form-check-label"
for="select-all-2-edit">Select All States</label>
</div>
@foreach ($states as $state)
<div class="form-check">
<input
class="form-check-input state-checkbox state-group-2-checkbox"
type="checkbox" name="state_ids[]"
value="{{ $state->id }}"
id="state-2-{{ $state->id }}"
{{ in_array($state->id, $stateIds) ? 'checked' : '' }} />
<label class="form-check-label"
for="state-2-{{ $state->id }}">{{ $state->name }}</label>
</div>
@endforeach
</div>
<!-- Radio Button 3 -->
<input class="form-check-input" type="radio"
name="user_type" id="select-ids-edit" value="3"
{{ $edit_notification->user_type == 3 ? 'checked' : '' }} />
<label class="form-check-label" for="select-ids-edit">Send to
subscribed and unsubscribed users who are in their
respective states</label><br>
<div id="dropdown-3-edit"
class="dropdown-container state-group-3"
style="display: {{ $edit_notification->user_type == 3 ? 'block' : 'none' }}; max-height: 200px; overflow-y: auto;">
<div class="form-check">
<input class="form-check-input select-all-checkbox"
type="checkbox" id="select-all-3-edit"
data-group="3" />
<label class="form-check-label"
for="select-all-3-edit">Select All States</label>
</div>
@foreach ($states as $state)
<div class="form-check">
<input
class="form-check-input state-checkbox state-group-3-checkbox"
type="checkbox" name="state_ids[]"
value="{{ $state->id }}"
id="state-3-{{ $state->id }}"
{{ in_array($state->id, $stateIds) ? 'checked' : '' }} />
<label class="form-check-label"
for="state-3-{{ $state->id }}">{{ $state->name }}</label>
</div>
@endforeach
</div>
</div>
</div>
</div>
</div>
<button button class="download-btn-custom mt-3 custom-width-10"
id="update_notification">Update
Notification</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</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>
@endsection

View File

@@ -39,7 +39,7 @@
<td>{{ $notification->type }}</td>
<td>{{ $notification->description }}</td>
<td>{{ \Carbon\Carbon::parse($notification->date_added)->format('d/m/y') }}
<td>{{ \Carbon\Carbon::parse($notification->date_added)->format('m/d/y') }}
</td>
</tr>
@@ -56,12 +56,13 @@
{{-- <td>Last Modified Date :</td> --}}
</tr>
<tr class="w-100">
<td>
@if ($notification->notification->principal_type_xid == '3')
@if ($notification->notification && $notification->notification->principal_xid == '3')
Customer
@elseif ($notification->principal_xid == null || $notification->principal_xid == '3')
Customer
@else
Resturant
Restaurant
@endif
</td>
<td>

View File

@@ -189,8 +189,11 @@ Route::group(['middleware' => ['checkStatus']], function () {
//*******************************************************manage notification********************************************************
Route::get('/manage-notification', [ManageNotificationsController::class, 'index'])->name('manage.notification');
Route::get('/manage_add_notifications', [ManageNotificationsController::class, 'add'])->name('manage_add_notifications');
Route::get('/manage_edit_notifications/{id}', [ManageNotificationsController::class, 'edit'])->name('manage_edit_notifications');
Route::post('/insert_notification', [ManageNotificationsController::class, 'store_notification_data']);
Route::post('/manage_update_notifications', [ManageNotificationsController::class, 'update'])->name('manage_update_notifications');
Route::get('/manage_view_notifications/{id}', [ManageNotificationsController::class, 'view']);
Route::post('/manage_delete_notifications/{id}', [ManageNotificationsController::class, 'delete']);