This commit is contained in:
sayliraut
2024-07-05 19:48:08 +05:30
9 changed files with 494 additions and 213 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Exports;
use App\Models\IamPrincipal;
use App\Models\RedeemRestaurant;
use App\Models\Subscriptions;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
@@ -28,7 +29,25 @@ class ReportExport implements FromView
{
$data = collect();
if ($this->reportType === 'Total Users') {
if ($this->reportType === 'Total Subscribed') {
$query = Subscriptions::with(['iamPrincipal.state']);
if (!empty($this->states)) {
$query->whereHas('iamPrincipal', function ($q) {
$q->whereIn('state_xid', $this->states);
});
}
if ($this->startDate) {
$query->whereDate('created_at', '>=', $this->startDate);
}
if ($this->endDate) {
$query->whereDate('created_at', '<=', $this->endDate);
}
$data = $query->get();
} elseif ($this->reportType === 'Total Users') {
$query = IamPrincipal::query();
if (!empty($this->states)) {

View File

@@ -94,7 +94,7 @@ class SubscriptionController extends Controller
public function createStripeProduct(Request $request)
{
try {
DB::beginTransaction();
@@ -257,98 +257,85 @@ class SubscriptionController extends Controller
public function cancelSubscription(Request $request)
{
try {
Log::info("Razorpay Cancel subscriptions Begin: ");
DB::beginTransaction();
$stripeSecret = (config('constants.subscription.stripe_secret_key'));
// $stripeSecret = env('STRIPE_SECRET');
$validator = $this->validateCancelSubscriptionForm($request);
$stripe = new \Stripe\StripeClient($stripeSecret);
$userId = $request->iam_principal_xid;
if ($validator->fails()) {
$validationErrors = $validator->errors()->all();
Log::error("Razorpay Cancel subscriptions validation error: " . implode(", ", $validationErrors));
return jsonResponseWithErrorMessageApi($validationErrors, 203);
}
// dd($request->all(),$stripeSecret);
$iamPrincipalId = $request->iam_principal_xid;
$razorpaySubscriptionId = $request->subscription_id;
$subscriptionXid = $request->subscription_xid;
$getSubscriptionData = Subscriptions::where('iam_principal_xid', $userId)->where('subscription_status', 'active')->first();
$getSubscriptionData = RazorpaySubscriptions::where(['id' => $subscriptionXid, 'iam_principal_xid' => $iamPrincipalId, 'subscription_id' => $razorpaySubscriptionId, 'isCancelledSubscription' => 0])->first();
$subscriptionId = $getSubscriptionData->subscription_id;
$cancelledSubscription = $stripe->subscriptions->update(
$subscriptionId,
['cancel_at_period_end' => true]
);
if (!$getSubscriptionData) {
return response()->json(['status' => 502, 'message' => 'Something went wrong while cancelling Subscription']);
}
$api = new Api(config('constants.razorpay.key_id'), config('constants.razorpay.key_secret'));
$options = ['cancel_at_cycle_end' => 1];
// Call the subscription create method with request parameters
$response = $api->subscription->fetch($razorpaySubscriptionId)->cancel($options);
$subscriptionFromDatabase = Subscriptions::where('subscription_id', $subscriptionId)->first();
$subscriptionFromDatabase->cancelled_at = date('Y-m-d H:i:s', $cancelledSubscription->canceled_at);
$subscriptionFromDatabase->subscription_status = $cancelledSubscription->status;
$subscriptionFromDatabase->is_cancelled_subscription = 1; //2 for cancelled
$subscriptionFromDatabase->status = "cancelled";
$subscriptionFromDatabase->save();
$getSubscription = $stripe->subscriptions->retrieve($subscriptionFromDatabase->subscription_id, []);
$getSubscribeCustomer = $stripe->customers->retrieve(
$subscriptionFromDatabase->stripe_customer_id,
[]
);
$endAt = date('Y-m-d H:i:s', $response->end_at);
$dateTime = now();
$currentDateTime = $dateTime->format('Y-m-d H:i:s');
$getSubscriptionData->isCancelledSubscription = 1;
$getSubscriptionData->cancelled_at = $currentDateTime;
$getSubscriptionData->save();
DB::commit();
Log::info("Razorpay Cancel subscriptions end: ");
return redirect()->back()->with(['success' => "Your Subscription Cancelled Successfully!"]);
return response()->json(['status' => 200, 'end_date' => $endAt]);
// return response()->json(['status' => 200, 'message' => 'Your Subscription has been cancelled Sucessfully']);
} catch (Exception $e) {
} catch (\Exception $e) {
DB::rollBack();
Log::error("An error occurred in " . _METHOD_ . ": " . $e->getMessage(), ['exception' => $e]);
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
return redirect()->back()->with(['error' => "Something went wrong while cancelling subscription!" . $e->getMessage()]);
// Log::error("An error occurred in " . _METHOD_ . ": " . $e->getMessage(), ['exception' => $e]);
// return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
}
}
public function validateCancelSubscriptionForm(Request $request)
/**
* Created By : Hritik
* Created at : 05 Jult 2024
* Use : To Apply Referral Code and return the User Id.
*/
public function applyReferralCode(Request $request)
{
return Validator::make(
$request->all(),
[
'iam_principal_xid' => 'required',
'subscription_id' => 'required',
'subscription_xid' => 'required',
]
);
try {
$referralCode = $request->input('referral_code');
$currentUserId = $request->input('current_iam_principal_xid');
$code = IamPrincipal::where('referral_code', $referralCode)->where('id', '!=', $currentUserId)->where('principal_type_xid', 3)->first();
if ($code) {
return response()->json(['success' => true, 'message' => 'Referral code applied successfully.', 'referralUserId' => $code->id]);
} else {
return response()->json(['success' => false, 'message' => 'Invalid referral code.']);
}
} catch (\Exception $e) {
Log::error("An error occurred in " . __METHOD__ . ": " . $e->getMessage(), ['exception' => $e]);
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'));
}
}
// public function subscriptionUpgrade(Request $request)
// {
// // dd($request->all());
// $razorPaysubscriptionProductXid = $request->razorpay_plan_id;
// $productTypeId = $request->product_type_xid;
// $productTierId = $request->product_tier_xid;
// $iamId = $request->iam_principal_xid;
// $user_id = 12; // Change this to dynamic user ID
// // Retrieve the current monthly subscription
// $currentSubscription = RazorpaySubscriptions::where('iam_principal_xid', $user_id)->first();
// if (!$currentSubscription) {
// return response()->json(['status' => 502, 'message' => 'Something went wrong current user Subscription not found']);
// }
// $products = Products::where('product_type_xid', $productTypeId)
// ->where('product_tier_xid', $productTierId)
// ->where('razorpay_plan_id', $razorPaysubscriptionProductXid)
// ->where('is_active', '1')->first();
// if (!$products) {
// return response()->json(['status' => 502, 'message' => 'Something went wrong current product not found']);
// }
// $api = new Api(config('constants.razorpay.key_id'), config('constants.razorpay.key_secret'));
// $plan_id = $products->razorpay_plan_id;
// // Call the subscription create method with request parameters
// }
}

View File

@@ -18,6 +18,35 @@ class Subscriptions extends Model
}
protected $fillable = [
'id',
'subscription_product_xid',
'iam_principal_xid',
'amount',
'stripe_customer_id',
'payment_intent_id',
'payment_intent_client_secret',
'subscription_id',
'subscription_status',
'current_period_start',
'current_period_end',
'status',
'next_payment_date',
'is_cancelled_subscription',
'cancelled_at',
'is_active',
'deleted_at',
'created_by',
'modified_by',
'created_at',
'updated_at'
];
public function iamPrincipal()
{
return $this->belongsTo(IamPrincipal::class, 'iam_principal_xid', 'id');
}
}

View File

@@ -56,9 +56,14 @@ class AuthServices
do {
$referral_code = \Str::random(10);
} while (IamPrincipal::where('referral_code', $referral_code)->exists());
if ($request->one_signal_player_id == "null") {
$playerId = null;
} else {
$playerId = $request->one_signal_player_id;
}
$user = IamPrincipal::create([
'one_signal_player_id' => $request->one_signal_player_id,
'one_signal_player_id' => $playerId,
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'email_address' => $request->email_address,
@@ -118,8 +123,13 @@ class AuthServices
Log::error('Customer Login Failed');
return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403);
}
if ($request->one_signal_player_id == "null") {
$playerId = null;
} else {
$playerId = $request->one_signal_player_id;
}
$isExistEmail->one_signal_player_id = $request->one_signal_player_id;
$isExistEmail->one_signal_player_id = $playerId ;
$isExistEmail->save();
$response = [
'iam_principal_xid' => $isExistEmail->id,

View File

@@ -34,7 +34,6 @@ $currentPage = 'manage-reports';
$points = [
'Total Subscribed',
'Total Users',
'New Subscribed',
'Redemptions',
'Redemptions for Specific Restaurants',
'Referrals Made',
@@ -119,10 +118,16 @@ $currentPage = 'manage-reports';
radio.addEventListener('change', function() {
document.querySelectorAll('.state-checkboxes').forEach(function(checkboxDiv) {
checkboxDiv.classList.remove('show');
checkboxDiv.querySelectorAll('.state-checkbox').forEach(function(checkbox) {
checkbox.disabled = true;
});
});
var selectedPoint = this.value;
document.querySelectorAll('.state-checkboxes[data-point="' + selectedPoint + '"]').forEach(function(checkboxDiv) {
checkboxDiv.classList.add('show');
checkboxDiv.querySelectorAll('.state-checkbox').forEach(function(checkbox) {
checkbox.disabled = false;
});
});
});
});
@@ -147,7 +152,8 @@ $currentPage = 'manage-reports';
</script>
<style>
.state-checkboxes-container {
.state-checkboxes-container {
display: flex;
flex-wrap: wrap;
}

View File

@@ -3,11 +3,32 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
{{-- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/css/toastr.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script> --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"
integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css"
integrity="sha512-3pIirOrwegjM6erE5gPSwkUzO+3cTjpnV9lexlNZqvupR64iZBnOOTiiLPb9M36zpMScbmUNIcHUqKD47M719g=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css"
integrity="sha512-vKMx8UnXk60zUwyUnUPM3HbQo8QfmNx7+ltw8Pm5zLusl1XIfwcxo8DbWCqMGKaWeNxWA8yrx5v3SaVpMvR3CA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.css"
integrity="sha512-3pIirOrwegjM6erE5gPSwkUzO+3cTjpnV9lexlNZqvupR64iZBnOOTiiLPb9M36zpMScbmUNIcHUqKD47M719g=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="{{ asset('resources/views/Admin/pages/subscriptions/subscription-style.css') }}" />
<title>List Of Products</title>
</head>
@@ -62,15 +83,26 @@
</div>
</div>
<hr class="my-5" style="border-top: 2px dashed; color: #042857;">
<div class="input-group mb-5 d-flex align-items-center justify-content-between">
<div class="input-group d-flex align-items-center justify-content-between">
<div class="in-group">
<label class="comm-head" for="">Enter coupon code</label>
<label class="comm-head" for="">Enter Referral code</label>
</div>
<div class="apply-btn">
<button class="apply" type="button">Apply</button>
<button class="apply" type="button" onclick="applyReferralCode()">Apply</button>
</div>
<input type="text" class="form-control coupon-input mt-3" placeholder="Enter coupon code">
<input type="text" class="form-control coupon-input mt-3" name ="referral_code"
id="referral_code" placeholder="Enter Referral code" maxlength="10">
<input type="hidden" class="form-control coupon-input mt-3" name ="iam_principal_xid"
id="iam_principal_xid" value="{{ $userData->id }}">
</div>
<div id="result-message" class="mt-3"></div>
<div id="loader" style="display: none;">Loading...</div>
<hr>
{{-- <div class="main-text">
<div>
@@ -87,6 +119,7 @@
@csrf
<input type="hidden" name="user_id" value="{{ $userData->id }}" />
<input type="hidden" name="subscription_product_xid" value="{{ $productList->id }}" />
<input type="hidden" name="referral_user_id" id="referral_user_id" />
<div class="main-text">
<div>
<p class="comm-head">Total Payment</p>
@@ -96,10 +129,11 @@
<p class="price">${{ $productList->product_value }}</p>
</div>
</div>
<button type="submit"class="subscribe-button w-75">SUBSCRIBE NOW</button>
<button type="submit" class="subscribe-button w-75">SUBSCRIBE NOW</button>
</form>
{{-- <button class="subscribe-button w-75" type="button" data-bs-toggle="modal" data-bs-target="#exampleModal">SUBSCRIBE NOW</button> --}}
<p class="grey-para text-center mt-3">You will be charged ${{ $productList->product_value }} every month
<p class="grey-para text-center mt-3">You will be charged ${{ $productList->product_value }} every
month
after your free trial period ends.
</p>
<p class="grey-para text-center mt-2">Subscription will be renewed monthly until cancelled.</p>
@@ -175,9 +209,15 @@
<!-- Modal end -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.js"></script>
<script type="module">
import {
@@ -199,7 +239,106 @@
}, 3000);
});
</script>
<script>
url_path = "{{ url('/') }}";
</script>
<script>
function applyReferralCode() {
var referralCode = document.getElementById('referral_code').value;
var currentUserId = document.getElementById('iam_principal_xid').value;
var loader = document.getElementById('loader');
var resultMessage = document.getElementById('result-message');
var referralUserIdToStore = document.getElementById('referral_user_id');
// Show the loader
loader.style.display = 'block';
resultMessage.innerHTML = '';
let base_url = url_path;
console.log();
if (referralCode == null || referralCode == '') {
toastr.error('Kindly Enter Referral Code');
setTimeout(function() {
}, 100000)
// alert('kindly apply referral code');
loader.style.display = 'none';
return false;
}
$.ajax({
url: base_url + '/apply-referral-code',
type: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}' // Include CSRF token
},
data: JSON.stringify({
referral_code: referralCode,
current_iam_principal_xid: currentUserId
}),
processData: false,
contentType: false,
success: function(result) {
if (result.success) {
resultMessage.innerHTML =
'<span class="text-success">Successfully applied Referral code!</span>';
console.log("success", result);
referralUserIdToStore.value = result.referralUserId;
loader.style.display = 'none';
} else {
resultMessage.innerHTML = '<span class="text-danger">Invalid referral code.</span>';
loader.style.display = 'none';
}
},
error: function(xhr, status, error) {
toastr.error('Something went Wrong');
setTimeout(function() {
loader.style.display = 'none';
}, 4000)
// alert('something went wrong');
// toastr.error('Something went wrong');
// $('#update_location').attr('disabled', false);
// $('#update_location').text('Save');
}
});
// AJAX request
// fetch('/apply-referral-code', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// 'X-CSRF-TOKEN': '{{ csrf_token() }}' // Include CSRF token
// },
// body: JSON.stringify({
// referral_code: referralCode
// })
// })
// .then(response => response.json())
// .then(data => {
// // Hide the loader
// loader.style.display = 'none';
// // Show the result message
// if (data.success) {
// resultMessage.innerHTML =
// '<span class="text-success">Successfully applied referral code!</span>';
// } else {
// resultMessage.innerHTML = '<span class="text-danger">Invalid referral code.</span>';
// }
// })
// .catch(error => {
// loader.style.display = 'none';
// resultMessage.innerHTML = '<span class="text-danger">An error occurred. Please try again.</span>';
// });
}
</script>
</body>

View File

@@ -2,47 +2,82 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="{{ asset('resources/views/Admin/pages/subscriptions/subscription-style.css') }}" />
<title>My Subscription</title>
<title>My Subscription</title>
</head>
<body>
<section class="new-subs-main">
<div class="container">
<h3 class="comm-head mt-3 d-flex gap-2" style="font-size: 20px;">
<a href="subscription.html">
{{-- <img src="images/arrow-left.png" alt=""> --}}
</a>
My Active Plan
</h3>
<div class="main-inn">
<div class="inn-group my-4">
<label class="comm-head" for="">Plan Name</label>
<input type="text" class="form-control other-input mt-3" placeholder="Monthly Plan">
</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="{{$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="{{
\Carbon\Carbon::parse($isSubscribedUser->next_payment_date)->format('j M, Y') }}">
</div>
</div>
<div class="my-5">
<a href="" class="anch" type="button" data-bs-toggle="modal" data-bs-target="#exampleModal">Cancel
Subscription</a>
</div>
</section>
<section class="new-subs-main">
<div class="row">
<div class="col-md-12">
@if (session('success'))
<div class="alert alert-success" id="alert-success">
{{ session('success') }}
</div>
@endif
<!-- <section class="mt-3 mb-5">
</div>
<div class="col-md-12">
@if (session('error'))
<div class="alert alert-danger" id="alert-danger">
{{ session('error') }}
</div>
@endif
</div>
</div>
<div class="container">
<h3 class="comm-head mt-3 d-flex gap-2" style="font-size: 20px;">
<a href="subscription.html">
{{-- <img src="images/arrow-left.png" alt=""> --}}
</a>
My Active Plan
</h3>
<div class="main-inn">
<div class="inn-group my-4">
<label class="comm-head" for="">Plan Name</label>
<input type="text" class="form-control other-input mt-3" readonly placeholder="Monthly Plan">
</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" readonly
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" readonly
value="{{ \Carbon\Carbon::parse($isSubscribedUser->next_payment_date)->format('j M, Y') }}">
</div>
</div>
<div class="my-3">
<hr>
@if ($isSubscribedUser->is_cancelled_subscription == 0)
<a href="" class="subscribe-button mt-0" type="button" data-bs-toggle="modal"
data-bs-target="#exampleModal">Cancel
Subscription</a>
@else
<div class="inn-group my-4">
<label class="comm-head" for="">You cancelled your subscription on :-</label>
<h6 style="font-weight: bold;"> {{ \Carbon\Carbon::parse($isSubscribedUser->cancelled_at)->format('j M, Y') }}</h6>
</div>
<div class="inn-group my-4">
<label class="comm-head" for="">Your current Plan will expire on :-</label>
<h6 style="font-weight: bold;"> {{ \Carbon\Carbon::parse($isSubscribedUser->next_payment_date)->format('j M, Y') }}</h6>
</div>
@endif
</div>
</section>
<!-- <section class="mt-3 mb-5">
<div class="container">
<h3 class=" head my-4">Subscription FAQs</h3>
<div data-ui-tablist class="ui-accordion ui-accordion--outlined" data-ui-transition="collapse-fade">
@@ -79,11 +114,11 @@
</div>
</div>
</section> -->
{{-- <section class="mt-3 mb-5">
{{-- <section class="mt-3 mb-5">
<div class="container">
<h3 class="head my-4">Subscription FAQs</h3>
<div data-ui-tablist class="ui-accordion ui-accordion--outlined" data-ui-transition="collapse-fade">
@foreach($faqs as $faq)
@foreach ($faqs as $faq)
<div class="ui-accordion-item">
<button data-ui-tablist-tab class="ui-accordion-header">{{ $faq->question }}</button>
<div data-ui-tablist-tabpanel {{ $loop->first ? '' : 'hidden' }}>
@@ -97,72 +132,106 @@
</div>
</section> --}}
<!-- Modal start -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel"></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<img src="{{ asset('resources/views/Admin/pages/subscriptions/images/x.svg') }}" alt="">
<!-- Modal start -->
<form is="cancelSubscriptionForm" action="{{ route('cancel-subscription') }}" method="POST">
@csrf
<input type ="hidden" name="iam_principal_xid" value="{{ $isSubscribedUser->iam_principal_xid }}" />
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel"></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<img src="{{ asset('resources/views/Admin/pages/subscriptions/images/x.svg') }}"
alt="">
</button>
</div>
<div class="modal-body">
<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>
</div>
<div class="modal-footer justify-content-center gap-3 my-4">
<button type="button" class="no-btn" data-bs-dismiss="modal">No</button>
<button type="button" class="yes-btn" data-bs-toggle="modal" data-bs-target="#tar-mod">Yes</button>
</div>
</div>
</div>
</div>
</button>
</div>
<div class="modal-body">
<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>
</div>
<div class="modal-footer justify-content-center gap-3 my-4">
<button type="button" class="no-btn" data-bs-dismiss="modal">No</button>
<button type="submit" class="yes-btn" data-bs-toggle="modal" data-bs-target="#tar-mod"
id="confirmCancellation">Yes</button>
<!-- Modal end -->
<!-- Modal start target -->
<div class="modal fade bottom-mod" id="tar-mod" tabindex="-1" aria-labelledby="tar-modLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-bottom">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="tar-modLabel"></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<img src="{{ asset('resources/views/Admin/pages/subscriptions/images/x.svg') }}" alt="">
</button>
</div>
</div>
</div>
</div>
<div class="modal-body mb-4">
<div class="mod-img d-flex align-items-center justify-content-center mb-3">
{{-- <img src="images/dull.png" alt=""> --}}
<img src="{{ asset('resources/views/Admin/pages/subscriptions/images/dull.png') }}" alt="">
</div>
<p class="para-mid text-center">Your subscription has been cancelled successfully!</p>
</div>
<!-- <div class="modal-footer">
</form>
<!-- Modal end -->
<!-- Modal start target -->
<div class="modal fade bottom-mod" id="tar-mod" tabindex="-1" aria-labelledby="tar-modLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-bottom">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="tar-modLabel"></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
<img src="{{ asset('resources/views/Admin/pages/subscriptions/images/x.svg') }}"
alt="">
</button>
</div>
<div class="modal-body mb-4">
<div class="mod-img d-flex align-items-center justify-content-center mb-3">
{{-- <img src="images/dull.png" alt=""> --}}
<img src="{{ asset('resources/views/Admin/pages/subscriptions/images/dull.png') }}"
alt="">
</div>
<p class="para-mid text-center">Your subscription has been cancelled successfully!</p>
</div>
<!-- <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div> -->
</div>
</div>
</div>
</div>
</div>
<!-- Modal end -->
<!-- Modal end -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
</script>
<script type="module">
import { Tablist } from "https://cdn.jsdelivr.net/npm/jolty@0.6.2/dist/jolty.esm.min.js";
document.addEventListener('DOMContentLoaded', () => {
Tablist.initAll();
});
</script>
<script type="module">
import {
Tablist
} from "https://cdn.jsdelivr.net/npm/jolty@0.6.2/dist/jolty.esm.min.js";
document.addEventListener('DOMContentLoaded', () => {
Tablist.initAll();
});
// $(document).ready(function () {
// // Handle the confirmation modal
// $('#confirmCancellation').click(function () {
// $('#cancelSubscriptionForm').submit();
// });
// });
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
// Hide the alert after 3 seconds (3000 milliseconds)
setTimeout(function() {
$('#alert-success').fadeOut('slow');
}, 3000);
setTimeout(function() {
$('#alert-danger').fadeOut('slow');
}, 3000);
});
</script>
</body>

View File

@@ -5,18 +5,41 @@
</head>
<body>
<h1>{{ $reportType }} Report</h1>
@if ($reportType === 'Total Users')
@if ($reportType === 'Total Subscribed')
<table>
<thead>
<tr>
<th>Sr No.</th>
<th>ID</th>
<th>Subscription ID</th>
<th>User First Name</th>
<th>User Last Name</th>
<th>State</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
@foreach($data as $subscription)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $subscription->id }}</td>
<td>{{ $subscription->iamPrincipal->first_name ?? 'N/A' }}</td>
<td>{{ $subscription->iamPrincipal->last_name ?? 'N/A' }}</td>
<td>{{ $subscription->iamPrincipal->state->name ?? 'N/A' }}</td>
<td>{{ $subscription->created_at ?? 'N/A' }}</td>
</tr>
@endforeach
</tbody>
</table>
@elseif ($reportType === 'Total Users')
<table>
<thead>
<tr>
<th>Sr No.</th>
<th>User ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Phone Number</th>
<th>Email</th>
<th>State</th>
<th>Date</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
@@ -26,11 +49,9 @@
<td>{{ $user->id }}</td>
<td>{{ $user->first_name }}</td>
<td>{{ $user->last_name }}</td>
<td>{{ $user->phone_number }}</td>
<td>{{ $user->email_address }}</td>
<td>{{ $user->state->name ?? 'N/A' }}</td>
<td>{{ $user->created_at ?? 'N/A'}}</td>
</tr>
<td>{{ $user->state->name }}</td>
<td>{{ $user->created_at }}</td>
</tr>
@endforeach
</tbody>
</table>
@@ -39,13 +60,11 @@
<thead>
<tr>
<th>Sr No.</th>
<th>ID</th>
<th>Customer First Name</th>
<th>Customer Last Name</th>
<th>Redemption ID</th>
<th>Restaurant Name</th>
<th>Redeem Date</th>
<th>Customer Name</th>
<th>State</th>
<th>Date</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
@@ -53,12 +72,10 @@
<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>
<td>{{ $redemption->restaurant->name }}</td>
<td>{{ $redemption->customer->first_name }} {{ $redemption->customer->last_name }}</td>
<td>{{ $redemption->customer->state->name }}</td>
<td>{{ $redemption->created_at }}</td>
</tr>
@endforeach
</tbody>
@@ -67,26 +84,26 @@
<table>
<thead>
<tr>
<th>Sr No. </th>
<th>Customer First Name</th>
<th>Customer Last Name</th>
<th>Sr No.</th>
<th>Redemption ID</th>
<th>Restaurant Name</th>
<th>Redeem Date</th>
<th> Date </th>
<th>Customer Name</th>
<th>State</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
@foreach($data as $redemption)
<tr>
<td>{{$loop->iteration}}</td>
<td>{{ $redemption->customer->first_name }}</td>
<td>{{ $redemption->customer->last_name }}</td>
<td>{{ $loop->iteration }}</td>
<td>{{ $redemption->id }}</td>
<td>{{ $redemption->restaurant->name }}</td>
<td>{{ $redemption->redeem_date }}</td>
<td>{{$redemption->created_at}}</td>
<td>{{ $redemption->customer->first_name }} {{ $redemption->customer->last_name }}</td>
<td>{{ $redemption->customer->state->name }}</td>
<td>{{ $redemption->created_at }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif

View File

@@ -236,6 +236,11 @@ Route::group(['middleware' => ['customer.jwt.verify']], function () {
// });
Route::post('subscribe-to-plan', [SubscriptionController::class, 'subscriptionToPlan'])->name('subscribe-to-plan');
Route::get('thank-you', [SubscriptionController::class, 'thankyou'])->name('thankyou');
Route::post('cancel-subscription',[SubscriptionController::class,'cancelSubscription'])->name('cancel-subscription');
Route::post('apply-referral-code', [SubscriptionController::class, 'applyReferralCode'])->name('apply-referral-code');
// Route::post('subscribe-to-product', [SubscriptionController::class, 'subscribeToProduct'])->name('subscribe-to-product');
// Route::post('cancel-subscription', [SubscriptionController::class, 'cancelSubscription'])->name('cancel-subscription');
// Route::get('cancel-thank-you', [SubscriptionController::class, 'cancelThankYou'])->name('cancel-thank-you');