diff --git a/routes/web.php b/routes/web.php index 861f5bdf..8f075e00 100644 --- a/routes/web.php +++ b/routes/web.php @@ -539,6 +539,108 @@ Route::get('/group/text/{id}', function($id){ } })->name('group.text'); +Route::get('/group/excel/{id}', function($id){ + + $group = \App\Models\Group::where('id', $id)->first(); + + echo 'Transaction Details'; + echo ''; + echo ''; + echo ''; + + echo '

Transaction Details

'; + + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + foreach ($group->transactions as $i => $transaction) { + $booking = $transaction->owner->owner; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo '
RATEDATENo.Bank DetailsBank NameBank BranchBank Account NumberOrder Amount
' . $group->currency_rate . '' . $group->created_at . '' . ($i + 1) . '' . $booking->bank->holder_name . '' . $booking->bank->bank_name . '' . $booking->bank->bank_branch . '' . $booking->bank->account_no . '' . $transaction->original_currency->short_code . ' ' . round($transaction->original_amount, 2) . '
'; + + echo ''; + + + /* + $group = \App\Models\Group::where('id', $id)->first(); + + // Send headers to tell the browser it's a CSV file with UTF-8 encoding + header('Content-Type: text/csv; charset=utf-8'); + header('Content-Disposition: attachment; filename="transactions.csv"'); + + // Create a file handle for output + $output = fopen('php://output', 'w'); + + // Write the BOM (Byte Order Mark) to indicate UTF-8 encoding + fputs($output, "\xEF\xBB\xBF"); + + // Write the headers row + fputcsv($output, ['RATE', 'DATE', 'No.', 'Bank Details', 'Bank Name', 'Bank Branch', 'Bank Account Number', 'Order Amount']); + + // Loop through transactions + foreach ($group->transactions as $i => $transaction) { + $booking = $transaction->owner->owner; + + // Write transaction details row + fputcsv($output, [ + $group->currency_rate, + $group->created_at, + $i + 1, + $booking->bank->holder_name, + $booking->bank->bank_name, + $booking->bank->bank_branch, + '"' . $booking->bank->account_no . '"', + $transaction->original_currency->short_code . ' ' . round($transaction->original_amount, 2), + ]); + } + + // Close the file handle + fclose($output); + + // Exit to prevent any additional output + exit(); + */ + +})->name('group.excel'); + Route::get('/wallet/audit', function (Request $request) { $wallets = \App\Models\Wallet::all();