Merge pull request #4462 from devansh-webkul/issue-4420
This commit is contained in:
commit
04368520c9
|
|
@ -33,6 +33,7 @@
|
|||
"intervention/image": "^2.4",
|
||||
"intervention/imagecache": "^2.3",
|
||||
"kalnoy/nestedset": "5.0.1",
|
||||
"khaled.alshamaa/ar-php": "^5.5",
|
||||
"konekt/concord": "^1.2",
|
||||
"laravel/framework": "^7.0",
|
||||
"laravel/scout": "^8.0",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Sales;
|
||||
|
||||
use PDF;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
use Webkul\Sales\Repositories\InvoiceRepository;
|
||||
use PDF;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
|
|
@ -141,8 +141,30 @@ class InvoiceController extends Controller
|
|||
{
|
||||
$invoice = $this->invoiceRepository->findOrFail($id);
|
||||
|
||||
$pdf = PDF::loadView('admin::sales.invoices.pdf', compact('invoice'))->setPaper('a4');
|
||||
$html = view('admin::sales.invoices.pdf', compact('invoice'))->render();
|
||||
|
||||
return $pdf->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
|
||||
return PDF::loadHTML($this->adjustArabicAndPersianContent($html))
|
||||
->setPaper('a4')
|
||||
->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,11 +260,11 @@
|
|||
</div>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ core()->formatBasePrice($item->base_price) }}</td>
|
||||
<td>{!! core()->formatBasePrice($item->base_price, true) !!}</td>
|
||||
<td class="text-center">{{ $item->qty }}</td>
|
||||
<td class="text-center">{{ core()->formatBasePrice($item->base_total) }}</td>
|
||||
<td class="text-center">{{ core()->formatBasePrice($item->base_tax_amount) }}</td>
|
||||
<td class="text-center">{{ core()->formatBasePrice($item->base_total + $item->base_tax_amount) }}</td>
|
||||
<td class="text-center">{!! core()->formatBasePrice($item->base_total, true) !!}</td>
|
||||
<td class="text-center">{!! core()->formatBasePrice($item->base_tax_amount, true) !!}</td>
|
||||
<td class="text-center">{!! core()->formatBasePrice($item->base_total + $item->base_tax_amount, true) !!}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
|
|
@ -277,31 +277,31 @@
|
|||
<tr>
|
||||
<td>{{ __('admin::app.sales.orders.subtotal') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($invoice->base_sub_total) }}</td>
|
||||
<td>{!! core()->formatBasePrice($invoice->base_sub_total, true) !!}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ __('admin::app.sales.orders.shipping-handling') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($invoice->base_shipping_amount) }}</td>
|
||||
<td>{!! core()->formatBasePrice($invoice->base_shipping_amount, true) !!}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ __('admin::app.sales.orders.tax') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($invoice->base_tax_amount) }}</td>
|
||||
<td>{!! core()->formatBasePrice($invoice->base_tax_amount, true) !!}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>{{ __('admin::app.sales.orders.discount') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($invoice->base_discount_amount) }}</td>
|
||||
<td>{!! core()->formatBasePrice($invoice->base_discount_amount, true) !!}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><strong>{{ __('admin::app.sales.orders.grand-total') }}</strong></td>
|
||||
<td><strong>-</strong></td>
|
||||
<td><strong>{{ core()->formatBasePrice($invoice->base_grand_total) }}</strong></td>
|
||||
<td><strong>{!! core()->formatBasePrice($invoice->base_grand_total, true) !!}</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
|
|
@ -554,13 +554,15 @@ class Core
|
|||
}
|
||||
|
||||
/**
|
||||
* Format price with base currency symbol
|
||||
* Format price with base currency symbol. This method also give ability to encode
|
||||
* the base currency symbol and its optional.
|
||||
*
|
||||
* @param float $price
|
||||
* @param float $price
|
||||
* @param bool $isEncoded
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatBasePrice($price)
|
||||
public function formatBasePrice($price, $isEncoded = false)
|
||||
{
|
||||
if (is_null($price)) {
|
||||
$price = 0;
|
||||
|
|
@ -570,15 +572,17 @@ class Core
|
|||
|
||||
if ($symbol = $this->getBaseCurrency()->symbol) {
|
||||
if ($this->currencySymbol($this->getBaseCurrencyCode()) == $symbol) {
|
||||
return $formater->formatCurrency($price, $this->getBaseCurrencyCode());
|
||||
$content = $formater->formatCurrency($price, $this->getBaseCurrencyCode());
|
||||
} else {
|
||||
$formater->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $symbol);
|
||||
|
||||
return $formater->format($this->convertPrice($price));
|
||||
$content = $formater->format($this->convertPrice($price));
|
||||
}
|
||||
} else {
|
||||
return $formater->formatCurrency($price, $this->getBaseCurrencyCode());
|
||||
$content = $formater->formatCurrency($price, $this->getBaseCurrencyCode());
|
||||
}
|
||||
|
||||
return ! $isEncoded ? $content : htmlentities($content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue