Fixed Euro Currency Support

This commit is contained in:
Devansh 2022-01-19 20:43:28 +05:30
parent e3eaadb47f
commit c89120cc4d
3 changed files with 42 additions and 6 deletions

View File

@ -331,9 +331,15 @@
</tr>
<tr>
<td><strong>{{ __('admin::app.sales.orders.grand-total') }}</strong></td>
<td><strong>-</strong></td>
<td><strong>{!! core()->formatBasePrice($invoice->base_grand_total, true) !!}</strong></td>
<td colspan="3">
<hr>
</td>
</tr>
<tr>
<td>{{ __('admin::app.sales.orders.grand-total') }}</td>
<td>-</td>
<td>{!! core()->formatBasePrice($invoice->base_grand_total, true) !!}</td>
</tr>
</table>

View File

@ -94,9 +94,13 @@ class OrderController extends Controller
abort(404);
}
$pdf = PDF::loadView('shop::customers.account.orders.pdf', compact('invoice'))->setPaper('a4');
$html = view('shop::customers.account.orders.pdf', compact('invoice'))->render();
return $pdf->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
$html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
return PDF::loadHTML($this->adjustArabicAndPersianContent($html))
->setPaper('a4')
->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
}
/**
@ -125,4 +129,24 @@ class OrderController extends Controller
return redirect()->back();
}
/**
* Adjust arabic and persian content.
*
* @param string $html
* @return string
*/
private function adjustArabicAndPersianContent($html)
{
$arabic = new \ArPHP\I18N\Arabic();
$p = $arabic->arIdentify($html);
for ($i = count($p) - 1; $i >= 0; $i -= 2) {
$utf8ar = $arabic->utf8Glyphs(substr($html, $p[$i - 1], $p[$i] - $p[$i - 1]));
$html = substr_replace($html, $utf8ar, $p[$i - 1], $p[$i] - $p[$i - 1]);
}
return $html;
}
}

View File

@ -347,7 +347,13 @@
<td>{{ core()->formatPrice($invoice->tax_amount, $invoice->order->order_currency_code) }}</td>
</tr>
<tr class="bold">
<tr>
<td colspan="3">
<hr>
</td>
</tr>
<tr>
<td>{{ __('shop::app.customer.account.order.view.grand-total') }}</td>
<td>-</td>
<td>{{ core()->formatPrice($invoice->grand_total, $invoice->order->order_currency_code) }}</td>