Totalsub
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -11,9 +11,36 @@ class Subscriptions extends Model
|
||||
|
||||
protected $table = 'subscriptions';
|
||||
protected $guarded = [];
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -119,10 +119,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 +153,8 @@ $currentPage = 'manage-reports';
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.state-checkboxes-container {
|
||||
|
||||
.state-checkboxes-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user