RecentDash
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ $currentPage = 'dashboard';
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5>Recent Transactions</h5>
|
||||
<form method="POST" id="customer-form">
|
||||
<form action="{{ route('export.recent.transactions') }}" method="POST" id="customer-form">
|
||||
@csrf
|
||||
<input type="hidden" name="selected_id" id="ids" disabled>
|
||||
<input type="hidden" name="all_id" id="all_id" value="all" disabled>
|
||||
@@ -343,30 +343,7 @@ $currentPage = 'dashboard';
|
||||
'</ul>' +
|
||||
'</button>').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');
|
||||
|
||||
@@ -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';
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.state-checkboxes-container {
|
||||
.state-checkboxes-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ Route::group(['middleware' => ['checkStatus']], function () {
|
||||
|
||||
|
||||
Route::get('/dashboard', [DashboardController::class, 'showDashboard'])->name('dashboard');
|
||||
Route::post('/export_recent_transaction', [DashboardController::class, 'exportRecentTransactions'])->name('export.recent.transactions');
|
||||
Route::post('/export/recent-transactions', [DashboardController::class, 'exportRecentTransactions'])->name('export.recent.transactions');
|
||||
|
||||
Route::get('/profile', [ManageProfileController::class, 'index'])->name('profile');
|
||||
Route::post('/update_profile', [ManageProfileController::class, 'update_profile'])->name('update.profile');
|
||||
|
||||
Reference in New Issue
Block a user