2020-04-16 10:41:25 +02:00
|
|
|
<?php
|
2020-09-11 10:07:59 +02:00
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-04-16 10:41:25 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-04-16 10:41:25 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-04-16 10:41:25 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Utils;
|
|
|
|
|
2022-06-30 12:12:23 +02:00
|
|
|
use App\Helpers\SwissQr\SwissQrGenerator;
|
2020-04-16 10:41:25 +02:00
|
|
|
use App\Models\Country;
|
2020-10-27 12:57:12 +01:00
|
|
|
use App\Models\CreditInvitation;
|
2022-02-09 09:09:41 +01:00
|
|
|
use App\Models\GatewayType;
|
2020-10-27 12:57:12 +01:00
|
|
|
use App\Models\InvoiceInvitation;
|
|
|
|
use App\Models\QuoteInvitation;
|
|
|
|
use App\Models\RecurringInvoiceInvitation;
|
2021-05-31 12:19:56 +02:00
|
|
|
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
|
2021-09-26 04:13:03 +02:00
|
|
|
use App\Utils\Ninja;
|
2022-02-09 09:09:41 +01:00
|
|
|
use App\Utils\Number;
|
2022-07-28 02:58:13 +02:00
|
|
|
use App\Utils\Traits\AppSetup;
|
2020-10-24 05:38:53 +02:00
|
|
|
use App\Utils\Traits\MakesDates;
|
2021-09-26 04:13:03 +02:00
|
|
|
use App\Utils\transformTranslations;
|
2020-10-28 11:10:49 +01:00
|
|
|
use Exception;
|
2020-04-16 10:41:25 +02:00
|
|
|
use Illuminate\Support\Facades\App;
|
2022-07-28 02:58:13 +02:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2020-04-16 10:41:25 +02:00
|
|
|
|
|
|
|
class HtmlEngine
|
|
|
|
{
|
2020-10-24 05:38:53 +02:00
|
|
|
use MakesDates;
|
2022-07-28 02:58:13 +02:00
|
|
|
use AppSetup;
|
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
public $entity;
|
|
|
|
|
|
|
|
public $invitation;
|
|
|
|
|
|
|
|
public $client;
|
|
|
|
|
|
|
|
public $contact;
|
|
|
|
|
|
|
|
public $company;
|
|
|
|
|
|
|
|
public $settings;
|
|
|
|
|
|
|
|
public $entity_calc;
|
|
|
|
|
|
|
|
public $entity_string;
|
|
|
|
|
2020-12-25 12:12:43 +01:00
|
|
|
private $helpers;
|
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
public function __construct($invitation)
|
2020-10-26 20:10:04 +01:00
|
|
|
{
|
2020-04-16 10:41:25 +02:00
|
|
|
$this->invitation = $invitation;
|
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
$this->entity_string = $this->resolveEntityString();
|
|
|
|
|
|
|
|
$this->entity = $invitation->{$this->entity_string};
|
2020-04-16 10:41:25 +02:00
|
|
|
|
|
|
|
$this->company = $invitation->company;
|
|
|
|
|
2022-04-20 03:55:33 +02:00
|
|
|
$this->contact = $invitation->contact->load('client');
|
2021-10-13 06:47:56 +02:00
|
|
|
|
|
|
|
$this->client = $this->contact->client->load('company','country');
|
|
|
|
|
2021-10-08 06:00:17 +02:00
|
|
|
$this->entity->load('client');
|
2020-04-16 10:41:25 +02:00
|
|
|
|
|
|
|
$this->settings = $this->client->getMergedSettings();
|
|
|
|
|
|
|
|
$this->entity_calc = $this->entity->calc();
|
2020-12-25 12:12:43 +01:00
|
|
|
|
|
|
|
$this->helpers = new Helpers();
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2020-04-16 10:41:25 +02:00
|
|
|
|
2020-10-27 12:57:12 +01:00
|
|
|
private function resolveEntityString()
|
|
|
|
{
|
|
|
|
switch ($this->invitation) {
|
|
|
|
case ($this->invitation instanceof InvoiceInvitation):
|
|
|
|
return 'invoice';
|
|
|
|
break;
|
|
|
|
case ($this->invitation instanceof CreditInvitation):
|
|
|
|
return 'credit';
|
|
|
|
break;
|
|
|
|
case ($this->invitation instanceof QuoteInvitation):
|
|
|
|
return 'quote';
|
|
|
|
break;
|
|
|
|
case ($this->invitation instanceof RecurringInvoiceInvitation):
|
|
|
|
return 'recurring_invoice';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
# code...
|
|
|
|
break;
|
|
|
|
}
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
2020-07-29 04:13:12 +02:00
|
|
|
public function buildEntityDataArray() :array
|
2020-04-16 10:41:25 +02:00
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $this->client->currency()) {
|
2020-10-28 11:10:49 +01:00
|
|
|
throw new Exception(debug_backtrace()[1]['function'], 1);
|
2020-04-16 10:41:25 +02:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2021-09-26 04:13:03 +02:00
|
|
|
App::forgetInstance('translator');
|
|
|
|
$t = app('translator');
|
|
|
|
App::setLocale($this->contact->preferredLocale());
|
|
|
|
$t->replace(Ninja::transformTranslations($this->settings));
|
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
$data = [];
|
2022-07-21 05:20:29 +02:00
|
|
|
//$data['<html>'] = ['value' => '<html dir="rtl">', 'label' => ''];
|
2021-01-14 15:57:14 +01:00
|
|
|
$data['$global_margin'] = ['value' => '6.35mm', 'label' => ''];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$app_url'] = ['value' => $this->generateAppUrl(), 'label' => ''];
|
|
|
|
$data['$from'] = ['value' => '', 'label' => ctrans('texts.from')];
|
|
|
|
$data['$to'] = ['value' => '', 'label' => ctrans('texts.to')];
|
|
|
|
$data['$total_tax_labels'] = ['value' => $this->totalTaxLabels(), 'label' => ctrans('texts.taxes')];
|
|
|
|
$data['$total_tax_values'] = ['value' => $this->totalTaxValues(), 'label' => ctrans('texts.taxes')];
|
|
|
|
$data['$line_tax_labels'] = ['value' => $this->lineTaxLabels(), 'label' => ctrans('texts.taxes')];
|
|
|
|
$data['$line_tax_values'] = ['value' => $this->lineTaxValues(), 'label' => ctrans('texts.taxes')];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.date')];
|
2021-01-14 03:20:26 +01:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$invoice.date'] = &$data['$date'];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$invoiceDate'] = &$data['$date'];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$due_date'] = ['value' => $this->translateDate($this->entity->due_date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.'.$this->entity_string.'_due_date')];
|
2022-04-13 09:00:01 +02:00
|
|
|
|
|
|
|
$data['$partial_due_date'] = ['value' => $this->translateDate($this->entity->partial_due_date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.'.$this->entity_string.'_due_date')];
|
|
|
|
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$dueDate'] = &$data['$due_date'];
|
|
|
|
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$payment_due'] = ['value' => $this->translateDate($this->entity->due_date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.payment_due')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$invoice.due_date'] = &$data['$due_date'];
|
|
|
|
$data['$invoice.number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
|
|
|
|
$data['$invoice.po_number'] = ['value' => $this->entity->po_number ?: ' ', 'label' => ctrans('texts.po_number')];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$poNumber'] = &$data['$invoice.po_number'];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$entity.datetime'] = ['value' => $this->formatDatetime($this->entity->created_at, $this->client->date_format(), $this->client->locale()), 'label' => ctrans('texts.date')];
|
2021-01-08 03:15:55 +01:00
|
|
|
$data['$invoice.datetime'] = &$data['$entity.datetime'];
|
|
|
|
$data['$quote.datetime'] = &$data['$entity.datetime'];
|
|
|
|
$data['$credit.datetime'] = &$data['$entity.datetime'];
|
2021-10-06 06:05:16 +02:00
|
|
|
$data['$payment_button'] = ['value' => '<a class="button" href="'.$this->invitation->getPaymentLink().'">'.ctrans('texts.pay_now').'</a>', 'label' => ctrans('texts.pay_now')];
|
|
|
|
$data['$payment_link'] = ['value' => $this->invitation->getPaymentLink(), 'label' => ctrans('texts.pay_now')];
|
|
|
|
|
2021-01-08 03:15:55 +01:00
|
|
|
|
2021-01-15 03:02:55 +01:00
|
|
|
if ($this->entity_string == 'invoice' || $this->entity_string == 'recurring_invoice') {
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$entity'] = ['value' => '', 'label' => ctrans('texts.invoice')];
|
|
|
|
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
|
2021-08-18 12:38:03 +02:00
|
|
|
$data['$number_short'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number_short')];
|
2021-09-22 13:21:00 +02:00
|
|
|
$data['$entity.terms'] = ['value' => Helpers::processReservedKeywords(\nl2br($this->entity->terms), $this->client) ?: '', 'label' => ctrans('texts.invoice_terms')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$terms'] = &$data['$entity.terms'];
|
2021-01-18 23:29:20 +01:00
|
|
|
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$viewLink'] = &$data['$view_link'];
|
2021-08-06 00:51:47 +02:00
|
|
|
$data['$viewButton'] = &$data['$view_link'];
|
2021-09-20 13:19:03 +02:00
|
|
|
$data['$view_button'] = &$data['$view_link'];
|
2021-10-06 06:05:16 +02:00
|
|
|
$data['$paymentButton'] = &$data['$payment_button'];
|
2020-10-09 13:13:33 +02:00
|
|
|
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.invoice_date')];
|
2021-02-22 23:47:54 +01:00
|
|
|
|
2021-10-08 06:00:17 +02:00
|
|
|
if($this->entity->project) {
|
2021-02-22 23:47:54 +01:00
|
|
|
$data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project_name')];
|
2021-11-08 10:53:11 +01:00
|
|
|
$data['$invoice.project'] = &$data['$project.name'];
|
2021-03-02 15:42:42 +01:00
|
|
|
}
|
2022-02-07 10:52:11 +01:00
|
|
|
|
|
|
|
if($this->entity->vendor) {
|
|
|
|
$data['$invoice.vendor'] = ['value' => $this->entity->vendor->present()->name(), 'label' => ctrans('texts.vendor_name')];
|
|
|
|
}
|
2022-06-30 12:12:23 +02:00
|
|
|
|
|
|
|
if(strlen($this->company->getSetting('qr_iban')) > 5 && strlen($this->company->getSetting('besr_id')) > 1)
|
|
|
|
{
|
|
|
|
try{
|
|
|
|
$data['$swiss_qr'] = ['value' => (new SwissQrGenerator($this->entity, $this->company))->run(), 'label' => ''];
|
|
|
|
}
|
|
|
|
catch(\Exception $e){
|
|
|
|
$data['$swiss_qr'] = ['value' => '', 'label' => ''];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
}
|
2020-04-16 10:41:25 +02:00
|
|
|
|
|
|
|
if ($this->entity_string == 'quote') {
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$entity'] = ['value' => '', 'label' => ctrans('texts.quote')];
|
2021-02-16 14:57:37 +01:00
|
|
|
$data['$number'] = ['value' => $this->entity->number ?: '', 'label' => ctrans('texts.quote_number')];
|
2021-08-18 12:38:03 +02:00
|
|
|
$data['$number_short'] = ['value' => $this->entity->number ?: '', 'label' => ctrans('texts.quote_number_short')];
|
2022-02-18 01:56:43 +01:00
|
|
|
$data['$entity.terms'] = ['value' => Helpers::processReservedKeywords(\nl2br($this->entity->terms), $this->client) ?: '', 'label' => ctrans('texts.quote_terms')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$terms'] = &$data['$entity.terms'];
|
2021-01-18 23:29:20 +01:00
|
|
|
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$viewLink'] = &$data['$view_link'];
|
2021-09-05 11:40:50 +02:00
|
|
|
$data['$viewButton'] = &$data['$view_link'];
|
2021-09-30 00:13:48 +02:00
|
|
|
$data['$view_button'] = &$data['$view_link'];
|
2021-09-05 11:40:50 +02:00
|
|
|
$data['$approveButton'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.approve')];
|
2020-10-26 20:10:04 +01:00
|
|
|
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.quote_date')];
|
2022-03-12 00:27:59 +01:00
|
|
|
|
|
|
|
if($this->entity->project) {
|
|
|
|
$data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project_name')];
|
|
|
|
$data['$invoice.project'] = &$data['$project.name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if($this->entity->vendor) {
|
|
|
|
$data['$invoice.vendor'] = ['value' => $this->entity->vendor->present()->name(), 'label' => ctrans('texts.vendor_name')];
|
|
|
|
}
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
}
|
2020-04-16 10:41:25 +02:00
|
|
|
|
|
|
|
if ($this->entity_string == 'credit') {
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$entity'] = ['value' => '', 'label' => ctrans('texts.credit')];
|
2021-02-16 14:57:37 +01:00
|
|
|
$data['$number'] = ['value' => $this->entity->number ?: '', 'label' => ctrans('texts.credit_number')];
|
2021-08-18 12:38:03 +02:00
|
|
|
$data['$number_short'] = ['value' => $this->entity->number ?: '', 'label' => ctrans('texts.credit_number_short')];
|
2022-02-18 01:56:43 +01:00
|
|
|
$data['$entity.terms'] = ['value' => Helpers::processReservedKeywords(\nl2br($this->entity->terms), $this->client) ?: '', 'label' => ctrans('texts.credit_terms')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$terms'] = &$data['$entity.terms'];
|
2021-01-18 23:29:20 +01:00
|
|
|
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
|
2021-09-05 11:40:50 +02:00
|
|
|
$data['$viewButton'] = &$data['$view_link'];
|
2021-09-30 00:13:48 +02:00
|
|
|
$data['$view_button'] = &$data['$view_link'];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$viewLink'] = &$data['$view_link'];
|
2020-10-26 20:10:04 +01:00
|
|
|
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
|
2020-08-22 00:16:40 +02:00
|
|
|
// $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.credit_date')];
|
2020-09-06 11:38:10 +02:00
|
|
|
}
|
2020-04-16 10:41:25 +02:00
|
|
|
|
2021-04-19 03:19:00 +02:00
|
|
|
$data['$portal_url'] = ['value' => $this->invitation->getPortalLink(), 'label' =>''];
|
2021-05-05 17:58:59 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$entity_number'] = &$data['$number'];
|
|
|
|
$data['$invoice.discount'] = ['value' => Number::formatMoney($this->entity_calc->getTotalDiscount(), $this->client) ?: ' ', 'label' => ctrans('texts.discount')];
|
|
|
|
$data['$discount'] = &$data['$invoice.discount'];
|
|
|
|
$data['$subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.subtotal')];
|
2021-09-15 01:02:25 +02:00
|
|
|
$data['$gross_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getGrossSubTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.subtotal')];
|
2021-08-12 23:29:36 +02:00
|
|
|
|
|
|
|
if($this->entity->uses_inclusive_taxes)
|
2022-04-26 08:53:41 +02:00
|
|
|
$data['$net_subtotal'] = ['value' => Number::formatMoney(($this->entity_calc->getSubTotal() - $this->entity->total_taxes - $this->entity_calc->getTotalDiscount()), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
|
2021-08-12 23:29:36 +02:00
|
|
|
else
|
2022-04-26 08:53:41 +02:00
|
|
|
$data['$net_subtotal'] = ['value' => Number::formatMoney($this->entity_calc->getSubTotal() - $this->entity_calc->getTotalDiscount(), $this->client) ?: ' ', 'label' => ctrans('texts.net_subtotal')];
|
2021-08-12 23:29:36 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$invoice.subtotal'] = &$data['$subtotal'];
|
2020-11-13 12:52:11 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
if ($this->entity->partial > 0) {
|
2021-09-07 13:58:17 +02:00
|
|
|
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->partial, $this->client) ?: ' ', 'label' => ctrans('texts.partial_due')];
|
|
|
|
$data['$balance_due_raw'] = ['value' => $this->entity->partial, 'label' => ctrans('texts.partial_due')];
|
2021-10-09 09:07:05 +02:00
|
|
|
$data['$amount_raw'] = ['value' => $this->entity->partial, 'label' => ctrans('texts.partial_due')];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$due_date'] = ['value' => $this->translateDate($this->entity->partial_due_date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.'.$this->entity_string.'_due_date')];
|
2021-09-07 13:58:17 +02:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
} else {
|
2021-02-23 02:17:09 +01:00
|
|
|
|
2021-07-12 12:43:41 +02:00
|
|
|
if($this->entity->status_id == 1){
|
|
|
|
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->amount, $this->client) ?: ' ', 'label' => ctrans('texts.balance_due')];
|
|
|
|
$data['$balance_due_raw'] = ['value' => $this->entity->amount, 'label' => ctrans('texts.balance_due')];
|
2021-10-09 09:07:05 +02:00
|
|
|
$data['$amount_raw'] = ['value' => $this->entity->amount, 'label' => ctrans('texts.amount')];
|
2021-07-12 12:43:41 +02:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: ' ', 'label' => ctrans('texts.balance_due')];
|
2021-08-24 15:37:16 +02:00
|
|
|
$data['$balance_due_raw'] = ['value' => $this->entity->balance, 'label' => ctrans('texts.balance_due')];
|
2021-10-09 09:07:05 +02:00
|
|
|
$data['$amount_raw'] = ['value' => $this->entity->amount, 'label' => ctrans('texts.amount')];
|
2021-07-12 12:43:41 +02:00
|
|
|
}
|
2020-11-25 15:19:52 +01:00
|
|
|
}
|
2020-12-14 17:23:04 +01:00
|
|
|
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$quote.balance_due'] = &$data['$balance_due'];
|
|
|
|
$data['$invoice.balance_due'] = &$data['$balance_due'];
|
2021-12-30 21:41:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ($this->entity_string == 'credit') {
|
|
|
|
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: ' ', 'label' => ctrans('texts.credit_balance')];
|
|
|
|
$data['$balance_due_raw'] = ['value' => $this->entity->balance, 'label' => ctrans('texts.credit_balance')];
|
|
|
|
$data['$amount_raw'] = ['value' => $this->entity->amount, 'label' => ctrans('texts.amount')];
|
|
|
|
}
|
|
|
|
|
2021-01-14 03:20:26 +01:00
|
|
|
// $data['$balance_due'] = $data['$balance_due'];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$outstanding'] = &$data['$balance_due'];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$partial_due'] = ['value' => Number::formatMoney($this->entity->partial, $this->client) ?: ' ', 'label' => ctrans('texts.partial_due')];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$partial'] = &$data['$partial_due'];
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.total')];
|
|
|
|
$data['$amount'] = &$data['$total'];
|
2020-09-09 14:47:26 +02:00
|
|
|
$data['$amount_due'] = ['value' => &$data['$total']['value'], 'label' => ctrans('texts.amount_due')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$quote.total'] = &$data['$total'];
|
|
|
|
$data['$invoice.total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.invoice_total')];
|
2021-06-13 14:56:33 +02:00
|
|
|
$data['$invoice_total_raw'] = ['value' => $this->entity_calc->getTotal(), 'label' => ctrans('texts.invoice_total')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$invoice.amount'] = &$data['$total'];
|
|
|
|
$data['$quote.amount'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.quote_total')];
|
|
|
|
$data['$credit.total'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.credit_total')];
|
|
|
|
$data['$credit.number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.credit_number')];
|
2020-09-30 00:42:55 +02:00
|
|
|
$data['$credit.total'] = &$data['$credit.total'];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$credit.po_number'] = &$data['$invoice.po_number'];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$credit.date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()), 'label' => ctrans('texts.credit_date')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$balance'] = ['value' => Number::formatMoney($this->entity_calc->getBalance(), $this->client) ?: ' ', 'label' => ctrans('texts.balance')];
|
|
|
|
$data['$credit.balance'] = &$data['$balance'];
|
|
|
|
|
|
|
|
$data['$invoice.balance'] = &$data['$balance'];
|
|
|
|
$data['$taxes'] = ['value' => Number::formatMoney($this->entity_calc->getItemTotalTaxes(), $this->client) ?: ' ', 'label' => ctrans('texts.taxes')];
|
|
|
|
$data['$invoice.taxes'] = &$data['$taxes'];
|
|
|
|
|
2021-04-01 11:33:50 +02:00
|
|
|
$data['$user.name'] = ['value' => $this->entity->user->present()->name(), 'label' => ctrans('texts.name')];
|
2021-09-13 00:02:10 +02:00
|
|
|
$data['$user.first_name'] = ['value' => $this->entity->user->first_name, 'label' => ctrans('texts.first_name')];
|
|
|
|
$data['$user.last_name'] = ['value' => $this->entity->user->last_name, 'label' => ctrans('texts.last_name')];
|
2021-09-23 14:07:07 +02:00
|
|
|
$data['$created_by_user'] = &$data['$user.name'];
|
|
|
|
$data['$assigned_to_user'] = ['value' => $this->entity->assigned_user ? $this->entity->assigned_user->present()->name() : '', 'label' => ctrans('texts.name')];
|
|
|
|
|
2021-03-26 20:21:47 +01:00
|
|
|
$data['$user_iban'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')];
|
2022-06-30 12:12:23 +02:00
|
|
|
|
2020-12-25 12:27:23 +01:00
|
|
|
$data['$invoice.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice1')];
|
|
|
|
$data['$invoice.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice2')];
|
|
|
|
$data['$invoice.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice3')];
|
|
|
|
$data['$invoice.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice4')];
|
2021-09-22 13:21:00 +02:00
|
|
|
$data['$invoice.public_notes'] = ['value' => Helpers::processReservedKeywords(\nl2br($this->entity->public_notes), $this->client) ?: '', 'label' => ctrans('texts.public_notes')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$entity.public_notes'] = &$data['$invoice.public_notes'];
|
2021-01-24 21:50:40 +01:00
|
|
|
$data['$public_notes'] = &$data['$invoice.public_notes'];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$notes'] = &$data['$public_notes'];
|
2020-09-06 11:38:10 +02:00
|
|
|
|
|
|
|
$data['$entity_issued_to'] = ['value' => '', 'label' => ctrans("texts.{$this->entity_string}_issued_to")];
|
|
|
|
$data['$your_entity'] = ['value' => '', 'label' => ctrans("texts.your_{$this->entity_string}")];
|
|
|
|
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$quote.date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.quote_date')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$quote.number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.quote_number')];
|
|
|
|
$data['$quote.po_number'] = &$data['$invoice.po_number'];
|
|
|
|
$data['$quote.quote_number'] = &$data['$quote.number'];
|
|
|
|
$data['$quote_no'] = &$data['$quote.number'];
|
|
|
|
$data['$quote.quote_no'] = &$data['$quote.number'];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$quote.valid_until'] = ['value' => $this->translateDate($this->entity->due_date, $this->client->date_format(), $this->client->locale()), 'label' => ctrans('texts.valid_until')];
|
2021-06-04 09:41:12 +02:00
|
|
|
$data['$valid_until'] = &$data['$quote.valid_until'];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$credit_amount'] = ['value' => Number::formatMoney($this->entity_calc->getTotal(), $this->client) ?: ' ', 'label' => ctrans('texts.credit_amount')];
|
|
|
|
$data['$credit_balance'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: ' ', 'label' => ctrans('texts.credit_balance')];
|
2021-04-10 13:33:56 +02:00
|
|
|
$data['$quote.custom1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice1', $this->entity->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice1')];
|
|
|
|
$data['$quote.custom2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice2', $this->entity->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice2')];
|
|
|
|
$data['$quote.custom3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice3', $this->entity->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice3')];
|
|
|
|
$data['$quote.custom4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'invoice4', $this->entity->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'invoice4')];
|
2020-09-06 11:38:10 +02:00
|
|
|
|
|
|
|
$data['$credit_number'] = &$data['$number'];
|
|
|
|
$data['$credit_no'] = &$data['$number'];
|
|
|
|
$data['$credit.credit_no'] = &$data['$number'];
|
2020-04-16 10:41:25 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$invoice_no'] = &$data['$number'];
|
|
|
|
$data['$invoice.invoice_no'] = &$data['$number'];
|
2020-12-25 12:27:23 +01:00
|
|
|
$data['$client1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client1', $this->client->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client1')];
|
|
|
|
$data['$client2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client2', $this->client->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client2')];
|
|
|
|
$data['$client3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client3', $this->client->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client3')];
|
|
|
|
$data['$client4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'client4', $this->client->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'client4')];
|
2021-06-03 00:02:30 +02:00
|
|
|
$data['$client.custom1'] = &$data['$client1'];
|
|
|
|
$data['$client.custom2'] = &$data['$client2'];
|
|
|
|
$data['$client.custom3'] = &$data['$client3'];
|
|
|
|
$data['$client.custom4'] = &$data['$client4'];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$address1'] = ['value' => $this->client->address1 ?: ' ', 'label' => ctrans('texts.address1')];
|
|
|
|
$data['$address2'] = ['value' => $this->client->address2 ?: ' ', 'label' => ctrans('texts.address2')];
|
|
|
|
$data['$id_number'] = ['value' => $this->client->id_number ?: ' ', 'label' => ctrans('texts.id_number')];
|
2021-01-25 11:34:12 +01:00
|
|
|
$data['$client.number'] = ['value' => $this->client->number ?: ' ', 'label' => ctrans('texts.number')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$vat_number'] = ['value' => $this->client->vat_number ?: ' ', 'label' => ctrans('texts.vat_number')];
|
|
|
|
$data['$website'] = ['value' => $this->client->present()->website() ?: ' ', 'label' => ctrans('texts.website')];
|
|
|
|
$data['$phone'] = ['value' => $this->client->present()->phone() ?: ' ', 'label' => ctrans('texts.phone')];
|
2021-05-05 17:58:59 +02:00
|
|
|
$data['$country'] = ['value' => isset($this->client->country->name) ? ctrans('texts.country_' . $this->client->country->name) : '', 'label' => ctrans('texts.country')];
|
2022-03-10 01:32:04 +01:00
|
|
|
$data['$country_2'] = ['value' => isset($this->client->country) ? $this->client->country->iso_3166_2 : '', 'label' => ctrans('texts.country')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$email'] = ['value' => isset($this->contact) ? $this->contact->email : 'no contact email on record', 'label' => ctrans('texts.email')];
|
2022-05-24 13:46:52 +02:00
|
|
|
|
|
|
|
if(str_contains($data['$email']['value'], 'example.com'))
|
|
|
|
$data['$email'] = ['value' => '', 'label' => ctrans('texts.email')];
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$client_name'] = ['value' => $this->entity->present()->clientName() ?: ' ', 'label' => ctrans('texts.client_name')];
|
|
|
|
$data['$client.name'] = &$data['$client_name'];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$client'] = &$data['$client_name'];
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$client.address1'] = &$data['$address1'];
|
|
|
|
$data['$client.address2'] = &$data['$address2'];
|
2021-03-05 11:27:36 +01:00
|
|
|
$data['$client_address'] = ['value' => $this->client->present()->address() ?: ' ', 'label' => ctrans('texts.address')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$client.address'] = &$data['$client_address'];
|
2021-06-06 11:27:15 +02:00
|
|
|
$data['$client.postal_code'] = ['value' => $this->client->postal_code ?: ' ', 'label' => ctrans('texts.postal_code')];
|
2022-02-14 08:05:31 +01:00
|
|
|
$data['$client.public_notes'] = ['value' => $this->client->public_notes ?: ' ', 'label' => ctrans('texts.notes')];
|
2021-08-12 13:33:05 +02:00
|
|
|
$data['$client.city'] = ['value' => $this->client->city ?: ' ', 'label' => ctrans('texts.city')];
|
2021-12-27 07:42:43 +01:00
|
|
|
$data['$client.state'] = ['value' => $this->client->state ?: ' ', 'label' => ctrans('texts.state')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$client.id_number'] = &$data['$id_number'];
|
|
|
|
$data['$client.vat_number'] = &$data['$vat_number'];
|
|
|
|
$data['$client.website'] = &$data['$website'];
|
|
|
|
$data['$client.phone'] = &$data['$phone'];
|
|
|
|
$data['$city_state_postal'] = ['value' => $this->entity->present()->cityStateZip($this->client->city, $this->client->state, $this->client->postal_code, false) ?: ' ', 'label' => ctrans('texts.city_state_postal')];
|
|
|
|
$data['$client.city_state_postal'] = &$data['$city_state_postal'];
|
|
|
|
$data['$postal_city_state'] = ['value' => $this->entity->present()->cityStateZip($this->client->city, $this->client->state, $this->client->postal_code, true) ?: ' ', 'label' => ctrans('texts.postal_city_state')];
|
|
|
|
$data['$client.postal_city_state'] = &$data['$postal_city_state'];
|
|
|
|
$data['$client.country'] = &$data['$country'];
|
|
|
|
$data['$client.email'] = &$data['$email'];
|
2021-12-27 07:42:43 +01:00
|
|
|
|
|
|
|
$data['$client.billing_address'] = &$data['$client_address'];
|
|
|
|
$data['$client.billing_address1'] = &$data['$client.address1'];
|
|
|
|
$data['$client.billing_address2'] = &$data['$client.address2'];
|
|
|
|
$data['$client.billing_city'] = &$data['$client.city'];
|
|
|
|
$data['$client.billing_state'] = &$data['$client.state'];
|
|
|
|
$data['$client.billing_postal_code'] = &$data['$client.postal_code'];
|
|
|
|
$data['$client.billing_country'] = &$data['$client.country'];
|
|
|
|
|
|
|
|
$data['$client.shipping_address'] = ['value' => $this->client->present()->shipping_address() ?: ' ', 'label' => ctrans('texts.shipping_address')];
|
|
|
|
$data['$client.shipping_address1'] = ['value' => $this->client->shipping_address1 ?: ' ', 'label' => ctrans('texts.shipping_address1')];
|
|
|
|
$data['$client.shipping_address2'] = ['value' => $this->client->shipping_address2 ?: ' ', 'label' => ctrans('texts.shipping_address2')];
|
|
|
|
$data['$client.shipping_city'] = ['value' => $this->client->shipping_city ?: ' ', 'label' => ctrans('texts.shipping_city')];
|
|
|
|
$data['$client.shipping_state'] = ['value' => $this->client->shipping_state ?: ' ', 'label' => ctrans('texts.shipping_state')];
|
|
|
|
$data['$client.shipping_postal_code'] = ['value' => $this->client->shipping_postal_code ?: ' ', 'label' => ctrans('texts.shipping_postal_code')];
|
|
|
|
$data['$client.shipping_country'] = ['value' => isset($this->client->shipping_country->name) ? ctrans('texts.country_' . $this->client->shipping_country->name) : '', 'label' => ctrans('texts.shipping_country')];
|
2020-12-14 17:23:04 +01:00
|
|
|
|
2020-12-11 07:50:54 +01:00
|
|
|
$data['$client.currency'] = ['value' => $this->client->currency()->code, 'label' => ''];
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2022-03-23 11:32:55 +01:00
|
|
|
$data['$client.lang_2'] = ['value' => optional($this->client->language())->locale, 'label' => ''];
|
|
|
|
|
2020-09-11 00:30:12 +02:00
|
|
|
$data['$client.balance'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')];
|
2020-09-17 00:22:23 +02:00
|
|
|
$data['$client_balance'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')];
|
2021-03-03 11:04:10 +01:00
|
|
|
$data['$paid_to_date'] = ['value' => Number::formatMoney($this->entity->paid_to_date, $this->client), 'label' => ctrans('texts.paid_to_date')];
|
2020-09-08 06:06:46 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$contact.full_name'] = ['value' => $this->contact->present()->name(), 'label' => ctrans('texts.name')];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$contact'] = &$data['$contact.full_name'];
|
2021-08-24 15:37:16 +02:00
|
|
|
|
2022-05-24 13:46:52 +02:00
|
|
|
$data['$contact.email'] = &$data['$email'];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$contact.phone'] = ['value' => $this->contact->phone, 'label' => ctrans('texts.phone')];
|
|
|
|
|
2021-03-30 09:01:20 +02:00
|
|
|
$data['$contact.name'] = ['value' => isset($this->contact) ? $this->contact->present()->name() : $this->client->present()->name(), 'label' => ctrans('texts.contact_name')];
|
2020-11-01 06:09:09 +01:00
|
|
|
$data['$contact.first_name'] = ['value' => isset($this->contact) ? $this->contact->first_name : '', 'label' => ctrans('texts.first_name')];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$firstName'] = &$data['$contact.first_name'];
|
|
|
|
|
2020-11-01 06:09:09 +01:00
|
|
|
$data['$contact.last_name'] = ['value' => isset($this->contact) ? $this->contact->last_name : '', 'label' => ctrans('texts.last_name')];
|
2020-12-11 07:50:54 +01:00
|
|
|
|
2022-06-20 06:15:32 +02:00
|
|
|
$data['$portal_button'] = ['value' => '<a class="button" href="'.$this->contact->getLoginLink().'?client_hash='.$this->client->client_hash.'">'.ctrans('texts.view_client_portal').'</a>', 'label' => ctrans('view_client_portal')];
|
|
|
|
$data['$contact.portal_button'] = &$data['$portal_button'];
|
2022-07-25 15:36:37 +02:00
|
|
|
$data['$portalButton'] = &$data['$portal_button'];
|
2020-12-11 07:50:54 +01:00
|
|
|
|
2020-12-25 12:27:23 +01:00
|
|
|
$data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact1')];
|
|
|
|
$data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact2')];
|
|
|
|
$data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact3')];
|
|
|
|
$data['$contact.custom4'] = ['value' => isset($this->contact) ? $this->contact->custom_value4 : ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'contact4')];
|
2020-04-16 10:41:25 +02:00
|
|
|
|
|
|
|
$data['$company.city_state_postal'] = ['value' => $this->company->present()->cityStateZip($this->settings->city, $this->settings->state, $this->settings->postal_code, false) ?: ' ', 'label' => ctrans('texts.city_state_postal')];
|
|
|
|
$data['$company.postal_city_state'] = ['value' => $this->company->present()->cityStateZip($this->settings->city, $this->settings->state, $this->settings->postal_code, true) ?: ' ', 'label' => ctrans('texts.postal_city_state')];
|
2021-03-08 05:20:02 +01:00
|
|
|
$data['$company.name'] = ['value' => $this->settings->name ?: ctrans('texts.untitled_account'), 'label' => ctrans('texts.company_name')];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$account'] = &$data['$company.name'];
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$company.address1'] = ['value' => $this->settings->address1 ?: ' ', 'label' => ctrans('texts.address1')];
|
|
|
|
$data['$company.address2'] = ['value' => $this->settings->address2 ?: ' ', 'label' => ctrans('texts.address2')];
|
|
|
|
$data['$company.city'] = ['value' => $this->settings->city ?: ' ', 'label' => ctrans('texts.city')];
|
|
|
|
$data['$company.state'] = ['value' => $this->settings->state ?: ' ', 'label' => ctrans('texts.state')];
|
|
|
|
$data['$company.postal_code'] = ['value' => $this->settings->postal_code ?: ' ', 'label' => ctrans('texts.postal_code')];
|
|
|
|
$data['$company.country'] = ['value' => $this->getCountryName(), 'label' => ctrans('texts.country')];
|
2022-03-10 01:32:04 +01:00
|
|
|
$data['$company.country_2'] = ['value' => $this->getCountryCode(), 'label' => ctrans('texts.country')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$company.phone'] = ['value' => $this->settings->phone ?: ' ', 'label' => ctrans('texts.phone')];
|
|
|
|
$data['$company.email'] = ['value' => $this->settings->email ?: ' ', 'label' => ctrans('texts.email')];
|
|
|
|
$data['$company.vat_number'] = ['value' => $this->settings->vat_number ?: ' ', 'label' => ctrans('texts.vat_number')];
|
|
|
|
$data['$company.id_number'] = ['value' => $this->settings->id_number ?: ' ', 'label' => ctrans('texts.id_number')];
|
|
|
|
$data['$company.website'] = ['value' => $this->settings->website ?: ' ', 'label' => ctrans('texts.website')];
|
|
|
|
$data['$company.address'] = ['value' => $this->company->present()->address($this->settings) ?: ' ', 'label' => ctrans('texts.address')];
|
|
|
|
|
2021-03-14 11:32:09 +01:00
|
|
|
$data['$signature'] = ['value' => $this->settings->email_signature ?: ' ', 'label' => ''];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$emailSignature'] = &$data['$signature'];
|
2021-03-14 11:32:09 +01:00
|
|
|
|
2021-03-26 20:30:46 +01:00
|
|
|
$data['$spc_qr_code'] = ['value' => $this->company->present()->getSpcQrCode($this->client->currency()->code, $this->entity->number, $this->entity->balance, $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client)), 'label' => ''];
|
2021-01-21 13:34:21 +01:00
|
|
|
|
2021-07-26 11:09:11 +02:00
|
|
|
$logo = $this->company->present()->logo_base64($this->settings);
|
2020-04-16 10:41:25 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')];
|
|
|
|
$data['$company_logo'] = &$data['$company.logo'];
|
2020-12-25 12:27:23 +01:00
|
|
|
$data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')];
|
|
|
|
$data['$company2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company2', $this->settings->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company2')];
|
|
|
|
$data['$company3'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company3', $this->settings->custom_value3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company3')];
|
|
|
|
$data['$company4'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company4', $this->settings->custom_value4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company4')];
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2021-06-07 00:41:04 +02:00
|
|
|
$data['$company.custom1'] = &$data['$company1'];
|
|
|
|
$data['$company.custom2'] = &$data['$company2'];
|
|
|
|
$data['$company.custom3'] = &$data['$company3'];
|
|
|
|
$data['$company.custom4'] = &$data['$company4'];
|
|
|
|
|
2021-02-21 10:36:34 +01:00
|
|
|
$data['$custom_surcharge1'] = ['value' => Number::formatMoney($this->entity->custom_surcharge1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'surcharge1')];
|
|
|
|
$data['$custom_surcharge2'] = ['value' => Number::formatMoney($this->entity->custom_surcharge2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'surcharge2')];
|
|
|
|
$data['$custom_surcharge3'] = ['value' => Number::formatMoney($this->entity->custom_surcharge3, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'surcharge3')];
|
|
|
|
$data['$custom_surcharge4'] = ['value' => Number::formatMoney($this->entity->custom_surcharge4, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'surcharge4')];
|
2020-09-08 06:02:00 +02:00
|
|
|
|
2020-12-23 14:25:12 +01:00
|
|
|
$data['$product.item'] = ['value' => '', 'label' => ctrans('texts.item')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$product.date'] = ['value' => '', 'label' => ctrans('texts.date')];
|
|
|
|
$data['$product.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
|
|
|
|
$data['$product.product_key'] = ['value' => '', 'label' => ctrans('texts.product_key')];
|
2020-11-16 00:42:21 +01:00
|
|
|
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
|
|
|
|
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$product.quantity'] = ['value' => '', 'label' => ctrans('texts.quantity')];
|
|
|
|
$data['$product.tax_name1'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$product.tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$product.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$product.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$product.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
|
2021-12-28 11:34:53 +01:00
|
|
|
$data['$product.gross_line_total'] = ['value' => '', 'label' => ctrans('texts.gross_line_total')];
|
2020-11-15 09:24:57 +01:00
|
|
|
$data['$product.description'] = ['value' => '', 'label' => ctrans('texts.description')];
|
|
|
|
$data['$product.unit_cost'] = ['value' => '', 'label' => ctrans('texts.unit_cost')];
|
2020-12-25 12:27:23 +01:00
|
|
|
$data['$product.product1'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product1')];
|
|
|
|
$data['$product.product2'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product2')];
|
|
|
|
$data['$product.product3'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product3')];
|
|
|
|
$data['$product.product4'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'product4')];
|
2020-09-06 11:38:10 +02:00
|
|
|
|
|
|
|
$data['$task.date'] = ['value' => '', 'label' => ctrans('texts.date')];
|
|
|
|
$data['$task.discount'] = ['value' => '', 'label' => ctrans('texts.discount')];
|
2020-12-08 16:44:35 +01:00
|
|
|
$data['$task.service'] = ['value' => '', 'label' => ctrans('texts.service')];
|
2020-11-16 00:42:21 +01:00
|
|
|
$data['$task.description'] = ['value' => '', 'label' => ctrans('texts.description')];
|
2020-11-04 11:22:43 +01:00
|
|
|
$data['$task.rate'] = ['value' => '', 'label' => ctrans('texts.rate')];
|
2021-04-01 15:00:09 +02:00
|
|
|
$data['$task.cost'] = ['value' => '', 'label' => ctrans('texts.rate')];
|
2020-11-04 11:22:43 +01:00
|
|
|
$data['$task.hours'] = ['value' => '', 'label' => ctrans('texts.hours')];
|
2020-09-06 11:38:10 +02:00
|
|
|
$data['$task.tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$task.tax_name1'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$task.tax_name2'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$task.tax_name3'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['$task.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')];
|
2021-12-28 11:34:53 +01:00
|
|
|
$data['$task.gross_line_total'] = ['value' => '', 'label' => ctrans('texts.gross_line_total')];
|
2020-12-01 15:18:48 +01:00
|
|
|
$data['$task.service'] = ['value' => '', 'label' => ctrans('texts.service')];
|
2021-03-30 15:50:39 +02:00
|
|
|
$data['$task.task1'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'task1')];
|
|
|
|
$data['$task.task2'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'task2')];
|
|
|
|
$data['$task.task3'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'task3')];
|
|
|
|
$data['$task.task4'] = ['value' => '', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'task4')];
|
2020-11-04 06:22:51 +01:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
if ($this->settings->signature_on_pdf) {
|
2020-11-04 06:22:51 +01:00
|
|
|
$data['$contact.signature'] = ['value' => $this->invitation->signature_base64, 'label' => ctrans('texts.signature')];
|
2020-11-25 15:19:52 +01:00
|
|
|
} else {
|
2020-11-04 06:22:51 +01:00
|
|
|
$data['$contact.signature'] = ['value' => '', 'label' => ''];
|
2020-11-25 15:19:52 +01:00
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
|
|
|
|
$data['$thanks'] = ['value' => '', 'label' => ctrans('texts.thanks')];
|
|
|
|
$data['$from'] = ['value' => '', 'label' => ctrans('texts.from')];
|
|
|
|
$data['$to'] = ['value' => '', 'label' => ctrans('texts.to')];
|
2020-09-16 12:16:56 +02:00
|
|
|
$data['$details'] = ['value' => '', 'label' => ctrans('texts.details')];
|
2020-09-06 11:38:10 +02:00
|
|
|
|
|
|
|
$data['_rate1'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['_rate2'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
|
|
|
$data['_rate3'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
2020-08-13 13:46:53 +02:00
|
|
|
|
2020-10-01 13:37:34 +02:00
|
|
|
$data['$font_size'] = ['value' => $this->settings->font_size . 'px', 'label' => ''];
|
2021-10-27 16:45:50 +02:00
|
|
|
$data['$font_name'] = ['value' => Helpers::resolveFont($this->settings->primary_font)['name'], 'label' => ''];
|
|
|
|
$data['$font_url'] = ['value' => Helpers::resolveFont($this->settings->primary_font)['url'], 'label' => ''];
|
2020-09-09 17:14:55 +02:00
|
|
|
|
2021-03-02 14:26:34 +01:00
|
|
|
$data['$invoiceninja.whitelabel'] = ['value' => 'https://raw.githubusercontent.com/invoiceninja/invoiceninja/v5-develop/public/images/new_logo.png', 'label' => ''];
|
2020-09-17 14:28:55 +02:00
|
|
|
|
2020-10-01 13:20:32 +02:00
|
|
|
$data['$primary_color'] = ['value' => $this->settings->primary_color, 'label' => ''];
|
|
|
|
$data['$secondary_color'] = ['value' => $this->settings->secondary_color, 'label' => ''];
|
|
|
|
|
2020-11-09 14:30:50 +01:00
|
|
|
$data['$item'] = ['value' => '', 'label' => ctrans('texts.item')];
|
|
|
|
$data['$description'] = ['value' => '', 'label' => ctrans('texts.description')];
|
|
|
|
|
2021-02-11 22:00:42 +01:00
|
|
|
//$data['$entity_footer'] = ['value' => $this->client->getSetting("{$this->entity_string}_footer"), 'label' => ''];
|
2021-09-22 13:21:00 +02:00
|
|
|
$data['$entity_footer'] = ['value' => Helpers::processReservedKeywords(\nl2br($this->entity->footer), $this->client), 'label' => ''];
|
2022-02-15 11:23:51 +01:00
|
|
|
$data['$footer'] = &$data['$entity_footer'];
|
|
|
|
|
2021-04-08 17:49:28 +02:00
|
|
|
$data['$page_size'] = ['value' => $this->settings->page_size, 'label' => ''];
|
2021-04-14 06:49:53 +02:00
|
|
|
$data['$page_layout'] = ['value' => property_exists($this->settings, 'page_layout') ? $this->settings->page_layout : 'Portrait', 'label' => ''];
|
2021-04-08 17:49:28 +02:00
|
|
|
|
2021-05-27 15:12:52 +02:00
|
|
|
$data['$tech_hero_image'] = ['value' => asset('images/pdf-designs/tech-hero-image.jpg'), 'label' => ''];
|
2021-06-23 23:55:29 +02:00
|
|
|
$data['$autoBill'] = ['value' => ctrans('texts.auto_bill_notification_placeholder'), 'label' => ''];
|
|
|
|
$data['$auto_bill'] = &$data['$autoBill'];
|
2021-05-27 15:12:52 +02:00
|
|
|
|
2021-08-06 00:51:47 +02:00
|
|
|
/*Payment Aliases*/
|
2021-10-06 06:05:16 +02:00
|
|
|
$data['$paymentLink'] = &$data['$payment_link'];
|
2021-10-08 06:00:17 +02:00
|
|
|
$data['$payment_url'] = &$data['$payment_link'];
|
2022-07-25 01:44:57 +02:00
|
|
|
|
2022-07-21 05:20:29 +02:00
|
|
|
$data['$dir'] = ['value' => in_array(optional($this->client->language())->locale, ['ar', 'he']) ? 'rtl' : 'ltr', 'label' => ''];
|
|
|
|
$data['$dir_text_align'] = ['value' => in_array(optional($this->client->language())->locale, ['ar', 'he']) ? 'right' : 'left', 'label' => ''];
|
2021-08-16 11:11:34 +02:00
|
|
|
|
2021-08-24 15:37:16 +02:00
|
|
|
$data['$payment.date'] = ['value' => ' ', 'label' => ctrans('texts.payment_date')];
|
2021-08-23 14:22:22 +02:00
|
|
|
$data['$method'] = ['value' => ' ', 'label' => ctrans('texts.method')];
|
2021-08-20 15:39:54 +02:00
|
|
|
|
2021-09-24 11:56:10 +02:00
|
|
|
$data['$statement_amount'] = ['value' => '', 'label' => ctrans('texts.amount')];
|
2021-09-17 20:06:41 +02:00
|
|
|
$data['$statement'] = ['value' => '', 'label' => ctrans('texts.statement')];
|
2021-09-17 19:49:40 +02:00
|
|
|
|
2021-11-08 21:20:55 +01:00
|
|
|
$data['$entity_images'] = ['value' => $this->generateEntityImagesMarkup(), 'label' => ''];
|
|
|
|
|
2022-02-09 09:09:41 +01:00
|
|
|
$data['$payments'] = ['value' => '', 'label' => ctrans('texts.payments')];
|
|
|
|
|
|
|
|
if ($this->entity_string == 'invoice' && $this->entity->payments()->exists()) {
|
|
|
|
|
|
|
|
$payment_list = '<br><br>';
|
|
|
|
|
|
|
|
foreach ($this->entity->payments as $payment) {
|
|
|
|
$payment_list .= ctrans('texts.payment_subject') . ": " . $this->formatDate($payment->date, $this->client->date_format()) . " :: " . Number::formatMoney($payment->amount, $this->client) ." :: ". GatewayType::getAlias($payment->gateway_type_id) . "<br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['$payments'] = ['value' => $payment_list, 'label' => ctrans('texts.payments')];
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
$arrKeysLength = array_map('strlen', array_keys($data));
|
|
|
|
array_multisort($arrKeysLength, SORT_DESC, $data);
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2020-10-28 07:27:10 +01:00
|
|
|
public function makeValues() :array
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
$values = $this->buildEntityDataArray();
|
|
|
|
|
|
|
|
foreach ($values as $key => $value) {
|
|
|
|
$data[$key] = $value['value'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
public function generateLabelsAndValues()
|
2020-04-16 10:41:25 +02:00
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
$values = $this->buildEntityDataArray();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
foreach ($values as $key => $value) {
|
|
|
|
$data['values'][$key] = $value['value'];
|
|
|
|
$data['labels'][$key.'_label'] = $value['label'];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function totalTaxLabels() :string
|
|
|
|
{
|
|
|
|
$data = '';
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $this->entity_calc->getTotalTaxMap()) {
|
2020-04-16 10:41:25 +02:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($this->entity_calc->getTotalTaxMap() as $tax) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$data .= '<span>'.$tax['name'].'</span>';
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function totalTaxValues() :string
|
|
|
|
{
|
|
|
|
$data = '';
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $this->entity_calc->getTotalTaxMap()) {
|
2020-04-16 10:41:25 +02:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($this->entity_calc->getTotalTaxMap() as $tax) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$data .= '<span>'.Number::formatMoney($tax['total'], $this->client).'</span>';
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function lineTaxLabels() :string
|
|
|
|
{
|
|
|
|
$tax_map = $this->entity_calc->getTaxMap();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
$data = '';
|
|
|
|
|
|
|
|
foreach ($tax_map as $tax) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$data .= '<span>'.$tax['name'].'</span>';
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getCountryName() :string
|
|
|
|
{
|
2022-07-28 02:58:13 +02:00
|
|
|
|
|
|
|
$countries = Cache::get('countries');
|
|
|
|
|
|
|
|
if (! $countries) {
|
|
|
|
$this->buildCache(true);
|
|
|
|
|
|
|
|
$countries = Cache::get('countries');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($countries){
|
|
|
|
|
|
|
|
|
|
|
|
$country = $countries->filter(function ($item) {
|
|
|
|
return $item->id == $this->settings->country_id;
|
|
|
|
})->first();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$country = Country::find($this->settings->country_id);
|
2020-04-16 10:41:25 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if ($country) {
|
2021-05-06 10:23:12 +02:00
|
|
|
return ctrans('texts.country_' . $country->name);
|
2020-09-06 11:38:10 +02:00
|
|
|
}
|
2020-04-16 10:41:25 +02:00
|
|
|
|
|
|
|
return ' ';
|
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2022-03-10 01:32:04 +01:00
|
|
|
|
|
|
|
private function getCountryCode() :string
|
|
|
|
{
|
|
|
|
$country = Country::find($this->settings->country_id);
|
|
|
|
|
2022-03-13 09:48:57 +01:00
|
|
|
if($country)
|
|
|
|
return $country->iso_3166_2;
|
|
|
|
// if ($country) {
|
|
|
|
// return ctrans('texts.country_' . $country->iso_3166_2);
|
|
|
|
// }
|
2022-03-10 01:32:04 +01:00
|
|
|
|
|
|
|
return ' ';
|
|
|
|
}
|
2020-04-16 10:41:25 +02:00
|
|
|
/**
|
|
|
|
* Due to the way we are compiling the blade template we
|
|
|
|
* have no ability to iterate, so in the case
|
|
|
|
* of line taxes where there are multiple rows,
|
2020-09-06 11:38:10 +02:00
|
|
|
* we use this function to format a section of rows.
|
2020-04-16 10:41:25 +02:00
|
|
|
*
|
|
|
|
* @return string a collection of <tr> rows with line item
|
|
|
|
* aggregate data
|
|
|
|
*/
|
|
|
|
private function makeLineTaxes() :string
|
|
|
|
{
|
|
|
|
$tax_map = $this->entity_calc->getTaxMap();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
$data = '';
|
|
|
|
|
|
|
|
foreach ($tax_map as $tax) {
|
|
|
|
$data .= '<tr class="line_taxes">';
|
2020-09-06 11:38:10 +02:00
|
|
|
$data .= '<td>'.$tax['name'].'</td>';
|
|
|
|
$data .= '<td>'.Number::formatMoney($tax['total'], $this->client).'</td></tr>';
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function lineTaxValues() :string
|
|
|
|
{
|
|
|
|
$tax_map = $this->entity_calc->getTaxMap();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
$data = '';
|
|
|
|
|
|
|
|
foreach ($tax_map as $tax) {
|
2020-09-06 11:38:10 +02:00
|
|
|
$data .= '<span>'.Number::formatMoney($tax['total'], $this->client).'</span>';
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-04-16 10:41:25 +02:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function makeTotalTaxes() :string
|
|
|
|
{
|
|
|
|
$data = '';
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $this->entity_calc->getTotalTaxMap()) {
|
2020-04-16 10:41:25 +02:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($this->entity_calc->getTotalTaxMap() as $tax) {
|
2020-09-04 13:17:30 +02:00
|
|
|
$data .= '<tr>';
|
|
|
|
$data .= '<td colspan="{ count($this->entity->company->settings->pdf_variables->total_columns) - 2 }"></td>';
|
2020-09-06 11:38:10 +02:00
|
|
|
$data .= '<td>'.$tax['name'].'</td>';
|
|
|
|
$data .= '<td>'.Number::formatMoney($tax['total'], $this->client).'</td></tr>';
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function parseLabelsAndValues($labels, $values, $section) :string
|
|
|
|
{
|
|
|
|
$section = strtr($section, $labels);
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
return strtr($section, $values);
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
| Ensures the URL doesn't have duplicated trailing slash
|
|
|
|
*/
|
|
|
|
public function generateAppUrl()
|
|
|
|
{
|
2020-07-14 11:55:28 +02:00
|
|
|
//return rtrim(config('ninja.app_url'), "/");
|
|
|
|
return config('ninja.app_url');
|
2020-04-16 10:41:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds CSS to assist with the generation
|
2020-09-06 11:38:10 +02:00
|
|
|
* of Repeating headers and footers on the PDF.
|
2020-04-16 10:41:25 +02:00
|
|
|
* @return string The css string
|
|
|
|
*/
|
|
|
|
private function generateCustomCSS() :string
|
|
|
|
{
|
|
|
|
$header_and_footer = '
|
|
|
|
.header, .header-space {
|
|
|
|
height: 160px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.footer, .footer-space {
|
|
|
|
height: 160px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.footer {
|
|
|
|
position: fixed;
|
|
|
|
bottom: 0;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
position: fixed;
|
|
|
|
top: 0mm;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media print {
|
2020-10-09 16:03:27 +02:00
|
|
|
thead {display: table-header-group;}
|
2020-04-16 10:41:25 +02:00
|
|
|
tfoot {display: table-footer-group;}
|
|
|
|
button {display: none;}
|
|
|
|
body {margin: 0;}
|
|
|
|
}';
|
|
|
|
|
|
|
|
$header = '
|
|
|
|
.header, .header-space {
|
|
|
|
height: 160px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
position: fixed;
|
|
|
|
top: 0mm;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media print {
|
2020-10-09 16:03:27 +02:00
|
|
|
thead {display: table-header-group;}
|
2020-04-16 10:41:25 +02:00
|
|
|
button {display: none;}
|
|
|
|
body {margin: 0;}
|
|
|
|
}';
|
|
|
|
|
|
|
|
$footer = '
|
|
|
|
|
|
|
|
.footer, .footer-space {
|
|
|
|
height: 160px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.footer {
|
|
|
|
position: fixed;
|
|
|
|
bottom: 0;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media print {
|
|
|
|
tfoot {display: table-footer-group;}
|
|
|
|
button {display: none;}
|
|
|
|
body {margin: 0;}
|
|
|
|
}';
|
|
|
|
$css = '';
|
|
|
|
|
|
|
|
if ($this->settings->all_pages_header && $this->settings->all_pages_footer) {
|
|
|
|
$css .= $header_and_footer;
|
2020-09-06 11:38:10 +02:00
|
|
|
} elseif ($this->settings->all_pages_header && ! $this->settings->all_pages_footer) {
|
2020-04-16 10:41:25 +02:00
|
|
|
$css .= $header;
|
2020-09-06 11:38:10 +02:00
|
|
|
} elseif (! $this->settings->all_pages_header && $this->settings->all_pages_footer) {
|
2020-04-16 10:41:25 +02:00
|
|
|
$css .= $footer;
|
|
|
|
}
|
|
|
|
|
|
|
|
$css .= '
|
|
|
|
.page {
|
|
|
|
page-break-after: always;
|
|
|
|
}
|
|
|
|
|
|
|
|
@page {
|
|
|
|
margin: 0mm
|
|
|
|
}
|
|
|
|
|
|
|
|
html {
|
|
|
|
';
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$css .= 'font-size:'.$this->settings->font_size.'px;';
|
2020-04-16 10:41:25 +02:00
|
|
|
// $css .= 'font-size:14px;';
|
|
|
|
|
|
|
|
$css .= '}';
|
|
|
|
|
|
|
|
return $css;
|
|
|
|
}
|
2021-11-08 21:20:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate markup for HTML images on entity.
|
|
|
|
*
|
|
|
|
* @return string|void
|
|
|
|
*/
|
|
|
|
protected function generateEntityImagesMarkup()
|
|
|
|
{
|
|
|
|
if ($this->client->getSetting('embed_documents') === false) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$dom = new \DOMDocument('1.0', 'UTF-8');
|
|
|
|
|
|
|
|
$container = $dom->createElement('div');
|
|
|
|
$container->setAttribute('style', 'display:grid; grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr);');
|
|
|
|
|
|
|
|
foreach ($this->entity->documents as $document) {
|
2021-11-09 17:30:17 +01:00
|
|
|
if (!$document->isImage()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-11-08 21:20:55 +01:00
|
|
|
$image = $dom->createElement('img');
|
|
|
|
|
|
|
|
$image->setAttribute('src', $document->generateUrl());
|
|
|
|
$image->setAttribute('style', 'max-height: 100px; margin-top: 20px;');
|
|
|
|
|
|
|
|
$container->appendChild($image);
|
|
|
|
}
|
|
|
|
|
|
|
|
$dom->appendChild($container);
|
|
|
|
|
|
|
|
return $dom->saveHTML();
|
|
|
|
}
|
2020-09-06 11:38:10 +02:00
|
|
|
}
|