Merge pull request #115 from WDI-Ideas/sayli

Sayli
This commit is contained in:
Sayli Raut
2024-06-11 15:10:13 +05:30
committed by GitHub
9 changed files with 494 additions and 61 deletions

View File

@@ -11,7 +11,7 @@ use App\Models\ManageRestaurant;
class DashboardController extends Controller
{
/**
/**
* Created By : sayali parab
* Created at : 16 May 2024
* Use : To show the dashboard.
@@ -83,10 +83,14 @@ class DashboardController extends Controller
$restaurantCount = ManageRestaurant::where('is_active', 1)->count();
return view('Admin.dashboard', compact(
'customerCount', 'restaurantCount', 'dataMonthlyWithType3', 'dataMonthlyWithType4',
'dataQuarterlyWithType3', 'dataQuarterlyWithType4', 'dataYearlyWithType3', 'dataYearlyWithType4'
'customerCount',
'restaurantCount',
'dataMonthlyWithType3',
'dataMonthlyWithType4',
'dataQuarterlyWithType3',
'dataQuarterlyWithType4',
'dataYearlyWithType3',
'dataYearlyWithType4'
));
}
}

View File

@@ -32,6 +32,11 @@ class ManageContactUsController extends Controller
return view('Admin.pages.manage_contact_us.manage_contact', compact('queries'));
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To send reply.
*/
public function sendReply(Request $request)
{
if (!$request->user_id || $request->user_id == null) {
@@ -63,6 +68,12 @@ class ManageContactUsController extends Controller
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To delete query.
*/
public function delete_user($id)
{
$data = ManageContactUs::find($id)->delete();

View File

@@ -24,6 +24,11 @@ class ManageFeedbackController extends Controller
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To delete query.
*/
public function delete_feedback($id)
{
$data = ManageFeedback::find($id)->delete();

View File

@@ -3,13 +3,177 @@
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\NotificationDetails;
use Illuminate\Http\Request;
class ManageNotificationsController extends Controller
{
public function index(){
return view('Admin.pages.manage_notification.manage_notification');
public function index(Request $request)
{
/**
* Created By : Sayli Raut
* Created at : 11 June 2024
* Use : To list notifications.
*/
$activeQuery = $request->query('active');
if ($activeQuery == 4) { // for customer
$notifications = NotificationDetails::with('Notification')
->whereHas('Notification', function ($query) {
$query->where('principal_type_xid', 3);
})
->latest()
->take(12)
->get();
} else if ($activeQuery == 3) { // for restaurant
$notifications = NotificationDetails::with('Notification')
->whereHas('Notification', function ($query) {
$query->where('principal_type_xid', 4);
})
->latest()
->take(12)
->get();
// return $notifications;
} else {
$notificationsOfType3 = NotificationDetails::with('Notification')
->whereHas('Notification', function ($query) {
$query->where('principal_type_xid', 3);
})
->latest()
->take(12)
->get();
$notificationsOfType4 = NotificationDetails::with('Notification')
->whereHas('Notification', function ($query) {
$query->where('principal_type_xid', 4);
})
->latest()
->take(12)
->get();
$notifications = $notificationsOfType3->merge($notificationsOfType4);
}
return view('Admin.pages.manage_notification.manage_notification', compact('notifications'));
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To view notification details.s
*/
public function add()
{
return view('Admin.pages.manage_notification.manage_notifications_add');
}
/**
* Created By : Sayli Raut
* Created at : 10 June 2024
* Use : To add notification .
*/
public function store_notificaton_data(Request $request)
{
try {
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
]);
DB::beginTransaction();
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);
$allOrders = Order::pluck('iam_principal_xid');
$passportId = $request->passport;
$passportUserIds = OrderedPassport::where('passport_xid', $passportId)
->whereHas('iamPrincipal', function ($query) {
$query->where('notification_status', 1)
->where('principal_type_xid', 3);
})
->pluck('iam_principal_xid');
$passportUserIdsToArray = $passportUserIds->toArray();
$allCustomerOneSignalIds = IamPrincipal::where('is_active', 1)
->where('notification_status', 1)
->where('principal_type_xid', 3)
->pluck('id');
// Find the remaining user IDs
$remainingUserIds = $allCustomerOneSignalIds->diff($allOrders);
$remainingUserIdsArray = $remainingUserIds->toArray();
// Find the remaining user data
$remainingUserData = IamPrincipal::whereIn('id', $remainingUserIdsArray)->get();
$parchasePassportUserData = IamPrincipal::whereIn('id', $passportUserIdsToArray)->get();
$title = $request->title;
$message = $request->description;
$content_type = 'Notification';
$imageUrl = $imagePath;
// FOR all User
if ($request->user_type == 1) {
foreach ($remainingUserData as $customerIdItem) {
if ($customerIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$customerIdItem->one_signal_player_id,
$title,
$message,
$content_type,
$imageUrl,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath);
}
} elseif ($request->user_type == 2) {
foreach ($parchasePassportUserData as $customerIdItem) {
if ($customerIdItem->one_signal_player_id) {
onesignalhelper::sendNotificationApi(
$customerIdItem->one_signal_player_id,
$title,
$message,
$content_type,
$imageUrl,
$id = null
);
}
onesignalhelper::StoreNotificationDetails($customerIdItem->id, $content_type, $title, $imagePath);
}
}
// FOR All passport user
DB::commit();
return jsonResponseWithSuccessMessage(__('success.save_data'));
// return $voucher_data;
} catch (Exception $e) {
DB::rollBack();
Log::error("Coupon Store Page Load 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
*/
public function view($id)
{
$notification = NotificationDetails::with('notification')->findOrFail($id);
return view('Admin.pages.manage_notification.manage_notifications_view', compact('notification'));
}
}

View File

@@ -229,7 +229,7 @@ class RestaurantApiServices
}
// Check if there's an existing entry for the restaurant and update it
$restexist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->first();
$restexist = RedeemRestaurant::where('manage_restaurants_xid', $restaurant->id)->where('iam_principal_xid', $customerIamId)->first();
if ($restexist) {
$restexist->is_redeem = 1;
$restexist->redeem_date = now();

View File

@@ -29,6 +29,7 @@
<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>
@@ -36,12 +37,22 @@
</tr>
</thead>
<tbody class="text-center">
@foreach ($notifications as $notification)
<tr>
<td class="text-start">1</td>
<td class="text-start">Lorem Ipsum</td>
<td class="text-start">08/22/2023</td>
<td class="text-start">Customer</td>
<td class="text-start">20/22/2023</td>
<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">
@@ -51,64 +62,30 @@
</button>
<ul>
<li>
<a href="manage-notification-view.php">
<img src="../src/assets/img/view.svg" />
<a
href="{{ url('/manage_view_notifications/' . $notification->id) }}">
<img src="{{ asset('public/assets/img/view.svg') }}" />
<span>View</span>
</a>
</li>
<li>
<a href="manage-notification-edit.php">
<img src="../src/assets/img/edit.svg" />
{{-- <li>
<a href="{{ route('manage_edit_notifications') }}">
<img src="{{ asset('public/assets/img/edit.svg') }}" />
<span>Edit</span>
</a>
</li>
<li>
</li> --}}
{{-- <li>
<a href="" data-toggle="modal" data-target="#delete-modal">
<img src="../src/assets/img/delete-recycle.svg" />
<img
src="{{ asset('public/assets/img/delete-recycle.svg') }}" />
<span>Delete</span>
</a>
</li>
</li> --}}
</ul>
</div>
</td>
</tr>
<tr>
<td class="text-start">1</td>
<td class="text-start">Lorem Ipsum</td>
<td class="text-start">08/22/2023</td>
<td class="text-start">Customer</td>
<td class="text-start">20/22/2023</td>
<td>
<div class="dropout">
<button class="more">
<span></span>
<span></span>
<span></span>
</button>
<ul>
<li>
<a href="manage-vouchers-view.php">
<img src="../src/assets/img/view.svg" />
<span>View</span>
</a>
</li>
<li>
<a href="manage-vouchers-edit.php">
<img src="../src/assets/img/edit.svg" />
<span>Edit</span>
</a>
</li>
<li>
<a href="" data-toggle="modal" data-target="#delete-modal">
<img src="../src/assets/img/delete-recycle.svg" />
<span>Delete</span>
</a>
</li>
</ul>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@@ -142,7 +119,7 @@
<script>
$(document).ready(function () {
$('<button><a class="extra-btn width-max-content" href="manage-notification-add.php">Add</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="#"><span>All</span></a></div><div class="dropdown-item"><a href="#"><span>Customer</span></a></div><div class="dropdown-item"><a href="#"> <span>Restaurant</span></a></div></div></li></ul></button>').insertBefore("#zero-config_filter label");
$('<button><a class="extra-btn width-max-content" href="{{ route('manage_add_notifications') }}">Add</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="#"><span>All</span></a></div><div class="dropdown-item"><a href="#"><span>Customer</span></a></div><div class="dropdown-item"><a href="#"> <span>Restaurant</span></a></div></div></li></ul></button>').insertBefore("#zero-config_filter label");
});
</script>
@endsection

View File

@@ -0,0 +1,185 @@
@extends('admin.layouts.master')
@section('content')
@php
$currentPage = 'manage_notification';
@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-4">
<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">Add Details</h6>
</a>
</div>
<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 h-10">
<div class="view-details Article">
<form id="send_notification_form">
@csrf
<div class="row">
<div class="col-md-6">
<div class="form-group ">
<label for="company-name" class="label">Notification Content</label>
<input type="text" class="form-control" name="title">
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<label for="company-name" class="label">Description</label>
<textarea type="text" class="form-control" name="description"></textarea>
</div>
</div>
<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/*">
</div>
</div>
<div class="col-ms-6">
<div class="form-group">
<label for="company-name" class="label"> Recipients </label>
<select id="recipients" name="recipients" class="form-control">
<option value="">Select Category</option>
<option value="customer">
Customer
</option>
<option value="customer">
Restaurant
</option>
</select>
</div>
</div>
<div class="col-md-12">
<button class="download-btn-custom mt-3 custom-width-10" type="submit"
id="store_notification_btn" class="w-100"><span>Submit</span></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
<script>
$(document).on("click", "#store_notification_btn", function(e) {
$.validator.addMethod("atLeastOneChecked", function(value, element) {
return $('input[type=radio]:checked', element.form).length > 0;
}, "Please select at least one option");
$('#send_notification_form').validate({
ignore: [],
debug: false,
rules: {
title: {
required: true
},
description: {
required: true
},
image: {
required: true,
},
user_type: {
atLeastOneChecked: true
}
},
messages: {
title: {
required: 'Please enter this field',
},
description: {
required: 'Please enter this field',
},
image: {
required: 'Please upload an image file',
},
user_type: {
atLeastOneChecked: 'Please select at least one option'
}
},
errorClass: 'error-message',
errorPlacement: function(error, element) {
if (element.attr("name") == "user_type") {
error.insertAfter("#select-popular-ids").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('Data Added Successfully');
setTimeout(function() {
window.location.href = base_url +
"/manage_notifications";
}, 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_notifications";
}, 2000);
});
} else {
toastr.error('Something Went Wrong');
setTimeout(function() {
window.location.href = base_url +
"/manage_notifications";
}, 2000);
}
$('#store_notification_btn').attr('disabled', false);
$('#store_notification_btn').text('Submit');
},
});
}
});
});
</script>

View File

@@ -0,0 +1,83 @@
@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>
</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">
<td>@if($notification->notification->principal_type_xid == '3')
Customer
@else
Resturant
@endif
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -149,6 +149,10 @@ 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::post('/insert_notification', [ManageNotificationsController::class, 'store_notificaton_data']);
Route::get('/manage_view_notifications/{id}', [ManageNotificationsController::class, 'view']);
//*******************************************************manage restraunts********************************************************