exportExcecl
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DashboardExportUser implements FromArray, WithHeadings
|
||||
{
|
||||
@@ -21,13 +22,14 @@ class DashboardExportUser implements FromArray, WithHeadings
|
||||
'ID' => $transaction['id'],
|
||||
'Customer Name' => $transaction['iam_principal']['first_name'] . ' ' . $transaction['iam_principal']['last_name'],
|
||||
'Customer ID' => $transaction['iam_principal']['id'],
|
||||
'Amount' => $transaction['amount'],
|
||||
'Amount' => '$' . number_format($transaction['amount'], 2),
|
||||
'Product Name' => $transaction['subscription_product']['product_name'],
|
||||
'Product Details' => $transaction['subscription_product']['product_details'],
|
||||
'Subscription Status' => $transaction['subscription_status'],
|
||||
'Subscription Period Start' => $transaction['current_period_start'],
|
||||
'Subscription Period End' => $transaction['current_period_end'],
|
||||
'Next Payment Date' => $transaction['next_payment_date'],
|
||||
'Subscription Period Start' => Carbon::parse($transaction['current_period_start'])->format('m/d/Y h:i A'),
|
||||
'Subscription Period End' => Carbon::parse($transaction['current_period_end'])->format('m/d/Y h:i A'),
|
||||
'Next Payment Date' => Carbon::parse($transaction['next_payment_date'])->format('m/d/Y h:i A'),
|
||||
|
||||
];
|
||||
}, $this->data);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ class ReportExport implements FromView
|
||||
|
||||
$data = $query->get();
|
||||
} elseif ($this->reportType === 'Total Users') {
|
||||
$query = IamPrincipal::query();
|
||||
$query = IamPrincipal::query()->where('principal_type_xid',3);
|
||||
// $query = Subscriptions::query()->where('is_cancelled_subscription', 1);
|
||||
|
||||
if (!empty($this->states)) {
|
||||
$query->whereIn('state_xid', $this->states);
|
||||
|
||||
@@ -96,9 +96,10 @@ $currentPage = 'manage-reports';
|
||||
|
||||
@section('section_script')
|
||||
<script>
|
||||
// Initialize Flatpickr for the date range with placeholders
|
||||
// Initialize Flatpickr for the date range with placeholders and set maxDate to today
|
||||
flatpickr("#startDate", {
|
||||
dateFormat: "Y-m-d",
|
||||
maxDate: "today",
|
||||
onChange: function (selectedDates, dateStr) {
|
||||
// Set the minimum date for the end date input
|
||||
flatpickr("#endDate").set("minDate", dateStr);
|
||||
@@ -107,6 +108,7 @@ $currentPage = 'manage-reports';
|
||||
|
||||
flatpickr("#endDate", {
|
||||
dateFormat: "Y-m-d",
|
||||
maxDate: "today",
|
||||
});
|
||||
|
||||
// Show/hide checkboxes based on selected radio button
|
||||
@@ -146,6 +148,7 @@ $currentPage = 'manage-reports';
|
||||
var selectedCheckboxes = document.querySelectorAll('.state-checkboxes.show .state-checkbox:checked');
|
||||
var startDate = document.getElementById("startDate").value;
|
||||
var endDate = document.getElementById("endDate").value;
|
||||
var today = new Date().toISOString().split('T')[0]; // Get today's date in YYYY-MM-DD format
|
||||
|
||||
if (!startDate) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
@@ -159,29 +162,24 @@ $currentPage = 'manage-reports';
|
||||
return;
|
||||
}
|
||||
|
||||
if (new Date(startDate) > new Date(today) || new Date(endDate) > new Date(today)) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
toastr.error('Please select a date within the allowed range.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selectedRadio) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
toastr.error('Please select a report type.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (selectedCheckboxes.length === 0) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
toastr.error('Please select at least one record.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Add a timeout to ensure the form data is sent before refreshing
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
<body>
|
||||
<h1>{{ $reportType }} Report</h1>
|
||||
|
||||
@if ($data->isEmpty())
|
||||
<p>No data available</p>
|
||||
@else
|
||||
|
||||
@if ($reportType === 'Total Subscribed')
|
||||
<table>
|
||||
<thead>
|
||||
@@ -185,6 +190,7 @@
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
|
||||
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user