mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
impl: pdf to excel table format
This commit is contained in:
+45
-56
@@ -542,6 +542,7 @@ Route::get('/group/text/{id}', function($id){
|
||||
Route::get('/group/excel/{id}', function($id){
|
||||
|
||||
$group = \App\Models\Group::where('id', $id)->first();
|
||||
$totalSum = 0;
|
||||
|
||||
echo '<title>Transaction Details</title>';
|
||||
echo '<style>';
|
||||
@@ -561,20 +562,21 @@ Route::get('/group/excel/{id}', function($id){
|
||||
echo '</head>';
|
||||
echo '<body>';
|
||||
|
||||
echo '<table>';
|
||||
echo '<h2>Transaction Details</h2>';
|
||||
|
||||
echo '<td>' . $group->issuerCompany->name . '</td>';
|
||||
echo '<td>' . $group->created_at->format('d-m-Y') . '</td>';
|
||||
echo '</table> <br>';
|
||||
|
||||
echo '<table>';
|
||||
echo '<thead>';
|
||||
echo '<tr>';
|
||||
echo '<th>RATE</th>';
|
||||
echo '<th>DATE</th>';
|
||||
echo '<th>No.</th>';
|
||||
echo '<th>Bank Details</th>';
|
||||
echo '<th>Bank Name</th>';
|
||||
echo '<th>Bank Branch</th>';
|
||||
echo '<th>Bank Account Number</th>';
|
||||
echo '<th>Order Amount</th>';
|
||||
echo '<th>REFERENCE</th>';
|
||||
echo '<th>MARKING</th>';
|
||||
echo '<th>RATE</th>';
|
||||
echo '<th>AMOUNT</th>';
|
||||
echo '<th>Bank-In Details</th>';
|
||||
echo '</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
@@ -582,63 +584,50 @@ Route::get('/group/excel/{id}', function($id){
|
||||
foreach ($group->transactions as $i => $transaction) {
|
||||
$booking = $transaction->owner->owner;
|
||||
echo '<tr>';
|
||||
echo '<td>' . $group->currency_rate . '</td>';
|
||||
echo '<td>' . $group->created_at . '</td>';
|
||||
echo '<td>' . ($i + 1) . '</td>';
|
||||
echo '<td>' . $booking->bank->holder_name . '</td>';
|
||||
echo '<td>' . $booking->bank->bank_name . '</td>';
|
||||
echo '<td>' . $booking->bank->bank_branch . '</td>';
|
||||
echo '<td>' . $booking->bank->account_no . '</td>';
|
||||
echo '<td>' . $transaction->original_currency->short_code . ' ' . round($transaction->original_amount, 2) . '</td>';
|
||||
echo '<td>' . $group->reference .'</td>';
|
||||
echo '<td>' . $booking->marking .'</td>';
|
||||
echo '<td>' . $group->currency_rate . '</td>';
|
||||
echo '<td>' . $transaction->currency->short_code . ' ' . number_format($transaction->original_amount, 2) . '</td>';
|
||||
echo '<td>';
|
||||
echo 'Account Holder Name:' . $booking->bank->holder_name . '<br>';
|
||||
echo 'Bank Name:' . $booking->bank->bank_name . '<br>';
|
||||
echo 'Bank Branch:' . $booking->bank->bank_branch . '<br>';
|
||||
echo 'Account No.:' . $booking->bank->account_no . '<br>';
|
||||
echo 'Bank In Amount:'. $transaction->original_currency->short_code . ' ' . round($transaction->original_amount, 2) . '<br>';
|
||||
$totalSum += round($transaction->original_amount, 2);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '</tbody>';
|
||||
echo '<tr>';
|
||||
echo '<td colspan="5" style="text-align: right;">Sub total booking amount:</td>';
|
||||
echo '<td>'. $transaction->original_currency->short_code . ' '. $totalSum . '</td>';
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo '<td colspan="5" style="text-align: right;">Transfer Fee:</td>';
|
||||
echo '<td>' . $transaction->original_currency->short_code . '</td>';
|
||||
echo '<tr>';
|
||||
echo '<td colspan="5" style="text-align: right;">Total booking amount:</td>';
|
||||
echo '<td>' . $totalSum . '</td>';
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo '<td colspan="5" style="text-align: right;">Sub total amount:</td>';
|
||||
echo '<td>' . $transaction->currency->short_code . '</td>';
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo '<td colspan="5" style="text-align: right;">Service Charge:</td>';
|
||||
echo '<td>' . $transaction->currency->short_code . '</td>';
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo '<td colspan="5" style="text-align: right;">Total Amount:</td>';
|
||||
echo '<td>' . $transaction->currency->short_code . '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
|
||||
echo '</body>';
|
||||
|
||||
|
||||
/*
|
||||
$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) {
|
||||
|
||||
Reference in New Issue
Block a user