Merge branch 'main' of https://github.com/WDI-Ideas/cheerstothe_season_laravel11 into sayli
This commit is contained in:
@@ -13,17 +13,21 @@ class ReportExport implements FromView
|
||||
protected $states;
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
protected $restaurants;
|
||||
|
||||
public function __construct($reportType, $states, $startDate, $endDate)
|
||||
public function __construct($reportType, $states, $startDate, $endDate, $restaurants = [])
|
||||
{
|
||||
$this->reportType = $reportType;
|
||||
$this->states = $states;
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
$this->restaurants = $restaurants;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = collect();
|
||||
|
||||
if ($this->reportType === 'Total Users') {
|
||||
$query = IamPrincipal::query();
|
||||
|
||||
@@ -40,10 +44,6 @@ class ReportExport implements FromView
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
return view('exports.report', [
|
||||
'data' => $data,
|
||||
'reportType' => $this->reportType
|
||||
]);
|
||||
} elseif ($this->reportType === 'Redemptions') {
|
||||
$query = RedeemRestaurant::with(['restaurant', 'customer'])->where('is_redeem', 0);
|
||||
|
||||
@@ -54,23 +54,34 @@ class ReportExport implements FromView
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('redeem_date', '>=', $this->startDate);
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('redeem_date', '<=', $this->endDate);
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Redemptions for Specific Restaurants') {
|
||||
$query = RedeemRestaurant::with('restaurant', 'customer');
|
||||
|
||||
if (!empty($this->restaurants)) {
|
||||
$query->whereIn('manage_restaurants_xid', $this->restaurants);
|
||||
}
|
||||
|
||||
if ($this->startDate) {
|
||||
$query->whereDate('created_at', '>=', $this->startDate);
|
||||
}
|
||||
|
||||
if ($this->endDate) {
|
||||
$query->whereDate('created_at', '<=', $this->endDate);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
return view('exports.report', [
|
||||
'data' => $data,
|
||||
'reportType' => $this->reportType
|
||||
]);
|
||||
}
|
||||
|
||||
// Default empty data if no matching report type
|
||||
return view('exports.report', [
|
||||
'data' => collect(),
|
||||
'data' => $data,
|
||||
'reportType' => $this->reportType
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -23,19 +23,18 @@ class SubscriptionController extends Controller
|
||||
//created by; Hritik
|
||||
//On - 28th June ,2024
|
||||
//use - to get Data of User in Webview and show list of product
|
||||
|
||||
public function mySubscription(Request $request)
|
||||
{
|
||||
try {
|
||||
// dd($request->header('access-token'));
|
||||
// $token = readHeaderToken();
|
||||
$token = readHeaderToken();
|
||||
// dd("acc",$token);
|
||||
$token = true;
|
||||
// $token = true;
|
||||
|
||||
// dd($token, Session::get('vendorToken'));
|
||||
if ($token) {
|
||||
$user_id = 12;
|
||||
// $user_id = $token['sub'];
|
||||
// $user_id = 12;
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$dateTime = now();
|
||||
$formattedDateTime = $dateTime->format('Y-m-d H:i:s');
|
||||
@@ -62,14 +61,12 @@ class SubscriptionController extends Controller
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
Log::error("An error occurred in " . _METHOD_ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//created by; Hritik
|
||||
//On - 28th June ,2024
|
||||
//use - to get Data of User in Webview and show list of product
|
||||
@@ -83,7 +80,7 @@ class SubscriptionController extends Controller
|
||||
return view('Admin.pages.subscriptions.list-of-products', compact('productList'));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
Log::error("An error occurred in " . _METHOD_ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
@@ -237,7 +234,7 @@ class SubscriptionController extends Controller
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
Log::error("An error occurred in " . _METHOD_ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
|
||||
// return redirect()->back()->with(['error' => "Something went wrong while subscription!" . $e->getMessage()]);
|
||||
|
||||
@@ -304,7 +301,7 @@ class SubscriptionController extends Controller
|
||||
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
Log::error("An error occurred in " . _METHOD_ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ use App\Models\ManageState;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\ReportExport;
|
||||
|
||||
|
||||
use App\Models\ManageRestaurant;
|
||||
|
||||
class ManageReportsController extends Controller
|
||||
{
|
||||
@@ -18,7 +17,8 @@ class ManageReportsController extends Controller
|
||||
{
|
||||
try {
|
||||
$states = ManageState::all();
|
||||
return view('Admin.pages.manage_reports.manage_reports', compact('states'));
|
||||
$restaurants = ManageRestaurant::all();
|
||||
return view('Admin.pages.manage_reports.manage_reports', compact('states','restaurants'));
|
||||
} catch (\Exception $e) {
|
||||
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
@@ -40,10 +40,12 @@ public function exportReports(Request $request)
|
||||
{
|
||||
$reportType = $request->input('reportType');
|
||||
$states = $request->input('states');
|
||||
$restaurants = $request->input('restaurants', []);
|
||||
|
||||
$startDate = $request->input('startDate');
|
||||
$endDate = $request->input('endDate');
|
||||
|
||||
return Excel::download(new ReportExport($reportType, $states, $startDate, $endDate), 'report.xlsx');
|
||||
return Excel::download(new ReportExport($reportType, $states, $startDate, $endDate, $restaurants), 'report.xlsx');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,14 +20,6 @@ $currentPage = 'manage-reports';
|
||||
<form id="reportForm" action="{{ route('export.reports') }}" method="POST">
|
||||
@csrf
|
||||
<div class="row widget-content widget-content-area br-8 position-btn m-auto py-3" style="overflow: auto;">
|
||||
<!-- <div class="col-md-6">
|
||||
<label for="">Select Modules</label>
|
||||
<select class="form-control">
|
||||
<option value="">dummy</option>
|
||||
<option value="">dummy</option>
|
||||
<option value="">dummy</option>
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="col-6">
|
||||
<label for="startDate">Start Date:</label>
|
||||
<input class="form-control" placeholder="Select start date" type="text" id="startDate" name="startDate">
|
||||
@@ -60,16 +52,29 @@ $currentPage = 'manage-reports';
|
||||
</label>
|
||||
</div>
|
||||
<div class="card-body state-checkboxes" style="display: none;" data-point="{{ $point }}">
|
||||
<label>
|
||||
<input type="checkbox" class="check-all"> Check All
|
||||
</label>
|
||||
<div class="state-checkboxes-container">
|
||||
@foreach($states as $state)
|
||||
<label class="state-checkbox-label">
|
||||
<input type="checkbox" name="states[]" value="{{ $state->id }}" class="state-checkbox"> {{ $state->name }}
|
||||
@if($point === 'Redemptions for Specific Restaurants')
|
||||
<label>
|
||||
<input type="checkbox" class="check-all"> Check All
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="state-checkboxes-container">
|
||||
@foreach($restaurants as $restaurant)
|
||||
<label class="state-checkbox-label">
|
||||
<input type="checkbox" name="restaurants[]" value="{{ $restaurant->id }}" class="state-checkbox"> {{ $restaurant->name }}
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
@else
|
||||
<label>
|
||||
<input type="checkbox" class="check-all"> Check All
|
||||
</label>
|
||||
<div class="state-checkboxes-container">
|
||||
@foreach($states as $state)
|
||||
<label class="state-checkbox-label">
|
||||
<input type="checkbox" name="states[]" value="{{ $state->id }}" class="state-checkbox"> {{ $state->name }}
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,11 +27,13 @@
|
||||
</div>
|
||||
<div class="inn-group my-4">
|
||||
<label class="comm-head" for="">Subscription Charge</label>
|
||||
<input type="text" class="form-control other-input mt-3" value="$5000">
|
||||
<input type="text" class="form-control other-input mt-3" value="{{$isSubscribedUser->amount}}">
|
||||
</div>
|
||||
<div class="inn-group my-4">
|
||||
<label class="comm-head" for="">Renewal date</label>
|
||||
<input type="text" class="form-control other-input mt-3" value="September 15th, 2024">
|
||||
<input type="text" class="form-control other-input mt-3" value="{{
|
||||
|
||||
\Carbon\Carbon::parse($isSubscribedUser->next_payment_date)->format('j M, Y') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="my-5">
|
||||
@@ -107,8 +109,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="text-center para">If you cancel now, you can still access your subscription until September
|
||||
15th, 2024. After this date, you will no longer be able to redeem cocktails.
|
||||
<p class="text-center para">If you cancel now, you can still access your subscription until {{\Carbon\Carbon::now()->format('M d ,Y')}} After this date, you will no longer be able to redeem cocktails.
|
||||
</p>
|
||||
<p class="text-center mt-3 para">Are you sure you want to cancel?
|
||||
</p>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -16,17 +15,17 @@
|
||||
<th>Last Name</th>
|
||||
<th>Email</th>
|
||||
<th>State</th>
|
||||
<th>Created At</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($data as $user)
|
||||
<tr>
|
||||
<td>{{$loop->iteration}}
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $user->id }}</td>
|
||||
<td>{{ $user->first_name }}</td>
|
||||
<td>{{ $user->last_name }}</td>
|
||||
<td>{{ $user->email_address}}</td>
|
||||
<td>{{ $user->email_address }}</td>
|
||||
<td>{{ $user->state->name ?? 'N/A' }}</td>
|
||||
<td>{{ $user->created_at }}</td>
|
||||
</tr>
|
||||
@@ -37,26 +36,53 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sr No. </th>
|
||||
<th>Sr No.</th>
|
||||
<th>ID</th>
|
||||
<th>Customer First Name</th>
|
||||
<th>Customer Last Name</th>
|
||||
<th>Restaurant Name</th>
|
||||
<th>Redeem Date</th>
|
||||
<th>State</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($data as $redemption)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $redemption->id }}</td>
|
||||
<td>{{ $redemption->customer->first_name ?? 'N/A' }}</td>
|
||||
<td>{{ $redemption->customer->last_name ?? 'N/A' }}</td>
|
||||
<td>{{ $redemption->restaurant->name ?? 'N/A' }}</td>
|
||||
<td>{{ $redemption->redeem_date }}</td>
|
||||
<td>{{ $redemption->customer->state->name ?? 'N/A' }}</td>
|
||||
<td>{{$redemption->created_at ?? 'N/A'}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@elseif ($reportType === 'Redemptions for Specific Restaurants')
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sr No. </th>
|
||||
<th>Customer First Name</th>
|
||||
<th>Customer Last Name</th>
|
||||
<th>Restaurant Name</th>
|
||||
<th>Redeem Date</th>
|
||||
<th> Date </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($data as $redemption)
|
||||
<tr>
|
||||
<td>{{$loop->iteration}}</td>
|
||||
<td>{{ $redemption->id }}</td>
|
||||
<td>{{ $redemption->customer->first_name ?? 'N/A' }}</td>
|
||||
<td>{{ $redemption->customer->last_name ?? 'N/A' }}</td>
|
||||
<td>{{ $redemption->restaurant->name ?? 'N/A' }}</td>
|
||||
<td>{{ $redemption->customer->first_name }}</td>
|
||||
<td>{{ $redemption->customer->last_name }}</td>
|
||||
<td>{{ $redemption->restaurant->name }}</td>
|
||||
|
||||
<td>{{ $redemption->redeem_date }}</td>
|
||||
<td>{{ $redemption->customer->state->name ?? 'N/A' }}</td>
|
||||
<td>{{$redemption->created_at}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
@@ -172,6 +172,8 @@ Route::group(['middleware' => ['checkStatus']], function () {
|
||||
|
||||
//*******************************************************manage reports********************************************************
|
||||
Route::get('/manage-reports', [ManageReportsController::class, 'index'])->name('manage.reports');
|
||||
Route::post('/export-reports', [ManageReportsController::class, 'exportReports'])->name('export.reports');
|
||||
|
||||
//*******************************************************manage feedback********************************************************
|
||||
Route::get('/manage-feedback', [ManageFeedbackController::class, 'index'])->name('manage.feedback');
|
||||
Route::post('/delete_feedback/{id}', [ManageFeedbackController::class, 'delete_feedback'])->name('delete.feedback');
|
||||
@@ -218,10 +220,10 @@ Route::group(['middleware' => ['checkStatus']], function () {
|
||||
|
||||
|
||||
//subscription ROutes
|
||||
// Route::group(['middleware' => ['customer.jwt.verify']], function () {
|
||||
Route::group(['middleware' => ['customer.jwt.verify']], function () {
|
||||
|
||||
Route::get('my-subscription-page', [SubscriptionController::class, 'mySubscription'])->name('my-subscription-page');
|
||||
// });
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user