From d71d0d9dbc02efb613cca2688bf5f55c5db8d416 Mon Sep 17 00:00:00 2001 From: sayaliparab Date: Tue, 9 Jul 2024 12:46:01 +0530 Subject: [PATCH] RecentDash --- .../Controllers/Admin/DashboardController.php | 18 +++++++++- resources/views/Admin/dashboard.blade.php | 25 +------------ .../manage_reports/manage_reports.blade.php | 36 ++++++++++++++++--- routes/web.php | 2 +- 4 files changed, 51 insertions(+), 30 deletions(-) diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index 6bc7793..755477c 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -162,12 +162,28 @@ class DashboardController extends Controller Created at : 08 July 2024 Use : To Get Excel. */ + // public function exportRecentTransactions(Request $request) + // { + // try { + // if ($request->has('all_id')) { + // $recentTransaction = Subscriptions::with('subscription')->get()->toArray(); + // // return $recentTransaction; + // return Excel::download(new DashboardExportUser($recentTransaction), 'recent_transactions.xlsx'); + // } + + // $ids = $request->input('selected_id'); + // $fileName = 'selected_customer_transaction_data.xlsx'; + // return Excel::download(new DashboardSelectedExportUser($ids), $fileName); + // } catch (\Exception $e) { + // return response()->json(['error' => 'Export failed. Something went wrong.'], 500); + // } + // } + public function exportRecentTransactions(Request $request) { try { if ($request->has('all_id')) { $recentTransaction = Subscriptions::with('subscription')->get()->toArray(); - // return $recentTransaction; return Excel::download(new DashboardExportUser($recentTransaction), 'recent_transactions.xlsx'); } diff --git a/resources/views/Admin/dashboard.blade.php b/resources/views/Admin/dashboard.blade.php index 019dbf6..9c62af1 100644 --- a/resources/views/Admin/dashboard.blade.php +++ b/resources/views/Admin/dashboard.blade.php @@ -105,7 +105,7 @@ $currentPage = 'dashboard';
Recent Transactions
-
+ @csrf @@ -343,30 +343,7 @@ $currentPage = 'dashboard'; '' + '').insertBefore("#zero-config_filter label"); -// Select/Deselect all checkboxes - // $('#select-all-ids').click(function() { - // $('input[name="customer_ids"]').prop('checked', this.checked); - // }); - // // Download all data - // $('#download_all').click(function() { - // window.location.href = '{{ route("export.recent.transactions") }}?all_id=true'; - // }); - - // // Download selected data - // $('#download-selected').click(function() { - // var selectedIds = []; - // $('input[name="customer_ids"]:checked').each(function() { - // selectedIds.push($(this).val()); - // }); - - // if (selectedIds.length > 0) { - // var ids = selectedIds.join(','); - // window.location.href = '{{ route("export.recent.transactions") }}?selected_id=' + ids; - // } else { - // alert('Please select at least one transaction to export.'); - // } - // }); $("#zero-config").on("click", ".sub_admin_permission", function() { var Name = $(this).data('name'); var Price = $(this).data('price'); diff --git a/resources/views/Admin/pages/manage_reports/manage_reports.blade.php b/resources/views/Admin/pages/manage_reports/manage_reports.blade.php index 373b538..d80d2a1 100644 --- a/resources/views/Admin/pages/manage_reports/manage_reports.blade.php +++ b/resources/views/Admin/pages/manage_reports/manage_reports.blade.php @@ -142,8 +142,37 @@ $currentPage = 'manage-reports'; }); }); - // Refresh page after download - document.getElementById('reportForm').addEventListener('submit', function() { + // Form validation before submission + document.getElementById('reportForm').addEventListener('submit', function(event) { + var selectedRadio = document.querySelector('input[name="reportType"]:checked'); + var selectedCheckboxes = document.querySelectorAll('.state-checkboxes.show .state-checkbox:checked'); + var startDate = document.getElementById("startDate").value; + var endDate = document.getElementById("endDate").value; + + if (!startDate) { + event.preventDefault(); // Prevent form submission + toastr.error('Please select a start date.'); + return; + } + + if (!endDate) { + event.preventDefault(); // Prevent form submission + toastr.error('Please select an end date.'); + 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 state or restaurant.'); + return; + } + // Add a timeout to ensure the form data is sent before refreshing setTimeout(function() { location.reload(); @@ -152,8 +181,7 @@ $currentPage = 'manage-reports';