2017-02-05 13:48:26 +01:00
|
|
|
<script type="text/javascript">
|
|
|
|
|
2018-03-26 10:09:13 +02:00
|
|
|
function renderEmailTemplate(str, invoice, entityType) {
|
2017-02-05 13:48:26 +01:00
|
|
|
if (!str) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2018-03-26 10:09:13 +02:00
|
|
|
if (invoice && invoice.invoice_type_id == {{ INVOICE_TYPE_QUOTE }} || entityType == '{{ ENTITY_QUOTE }}') {
|
2018-03-27 11:52:37 +02:00
|
|
|
var viewButton = {!! json_encode(Form::flatButton('view_quote', '#0b4d78')) !!} + '$password';
|
2018-03-26 10:09:13 +02:00
|
|
|
} else if (entityType == '{{ ENTITY_PROPOSAL }}') {
|
2018-03-27 11:52:37 +02:00
|
|
|
var viewButton = {!! json_encode(Form::flatButton('view_proposal', '#0b4d78')) !!} + '$password';
|
2018-03-26 10:09:13 +02:00
|
|
|
} else {
|
2018-03-27 11:52:37 +02:00
|
|
|
var viewButton = {!! json_encode(Form::flatButton('view_invoice', '#0b4d78')) !!} + '$password';
|
2018-03-26 10:09:13 +02:00
|
|
|
}
|
|
|
|
|
2018-03-27 11:52:37 +02:00
|
|
|
var passwordHtml = {!! $account->isPro() && $account->enable_portal_password && $account->send_portal_password ? json_encode('<br/>' . trans('texts.password') . ': XXXXXXXXX<br/>') : json_encode('') !!};
|
2017-02-05 13:48:26 +01:00
|
|
|
|
|
|
|
@if ($account->isPro())
|
2018-03-27 11:52:37 +02:00
|
|
|
var documentsHtml = {!! json_encode(trans('texts.email_documents_header') . '<ul><li><a>' . trans('texts.email_documents_example_1') . '</a></li><li><a>' . trans('texts.email_documents_example_2') . '</a></li></ul>') !!};
|
2017-02-05 13:48:26 +01:00
|
|
|
@else
|
|
|
|
var documentsHtml = "";
|
|
|
|
@endif
|
|
|
|
|
|
|
|
var keys = {
|
|
|
|
'footer': {!! json_encode($account->getEmailFooter()) !!},
|
2017-04-20 12:11:42 +02:00
|
|
|
'emailSignature': {!! json_encode($account->getEmailFooter()) !!},
|
2017-02-05 13:48:26 +01:00
|
|
|
'account': "{{ $account->getDisplayName() }}",
|
2017-10-26 21:18:56 +02:00
|
|
|
'dueDate': invoice ? invoice.partial_due_date || invoice.due_date : "{{ $account->formatDate($account->getDateTime()) }}",
|
2017-04-27 19:22:05 +02:00
|
|
|
'invoiceDate': invoice ? invoice.invoice_date : "{{ $account->formatDate($account->getDateTime()) }}",
|
2017-03-22 22:23:08 +01:00
|
|
|
'client': invoice ? getClientDisplayName(invoice.client) : "{{ trans('texts.client_name') }}",
|
2017-11-30 21:07:01 +01:00
|
|
|
'idNumber' : invoice ? invoice.client.id_number : '12345678',
|
|
|
|
'vatNumber' : invoice ? invoice.client.vat_number : '12345678',
|
2017-02-05 22:29:11 +01:00
|
|
|
'amount': invoice ? formatMoneyInvoice(parseFloat(invoice.partial) || parseFloat(invoice.balance_amount), invoice) : formatMoneyAccount(100, account),
|
2017-05-30 15:02:15 +02:00
|
|
|
'balance': invoice ? formatMoneyInvoice(parseFloat(invoice.balance), invoice) : formatMoneyAccount(100, account),
|
|
|
|
'total': invoice ? formatMoneyInvoice(parseFloat(invoice.amount), invoice) : formatMoneyAccount(100, account),
|
2017-09-02 21:03:45 +02:00
|
|
|
'partial': invoice ? formatMoneyInvoice(parseFloat(invoice.partial), invoice) : formatMoneyAccount(10, account),
|
2017-02-05 13:48:26 +01:00
|
|
|
'contact': invoice ? getContactDisplayName(invoice.client.contacts[0]) : 'Contact Name',
|
|
|
|
'firstName': invoice ? invoice.client.contacts[0].first_name : 'First Name',
|
|
|
|
'invoice': invoice ? invoice.invoice_number : '0001',
|
|
|
|
'quote': invoice ? invoice.invoice_number : '0001',
|
2017-09-02 21:03:45 +02:00
|
|
|
'number': invoice ? invoice.invoice_number : '0001',
|
2017-02-05 13:48:26 +01:00
|
|
|
'password': passwordHtml,
|
|
|
|
'documents': documentsHtml,
|
2017-12-03 14:04:17 +01:00
|
|
|
'viewLink': '{{ link_to('#', auth()->user()->account->getBaseUrl() . '/...') }}$password',
|
2018-03-26 10:09:13 +02:00
|
|
|
'viewButton': viewButton,
|
2017-12-03 14:04:17 +01:00
|
|
|
'paymentLink': '{{ link_to('#', auth()->user()->account->getBaseUrl() . '/...') }}$password',
|
2018-03-27 11:52:37 +02:00
|
|
|
'paymentButton': {!! json_encode(Form::flatButton('pay_now', '#36c157')) !!} + '$password',
|
2017-02-05 13:48:26 +01:00
|
|
|
'autoBill': '{{ trans('texts.auto_bill_notification_placeholder') }}',
|
2017-12-03 14:04:17 +01:00
|
|
|
'portalLink': "{{ auth()->user()->account->getBaseUrl() . '/...' }}",
|
2018-03-27 11:52:37 +02:00
|
|
|
'portalButton': {!! json_encode(Form::flatButton('view_portal', '#36c157')) !!},
|
2017-02-05 13:48:26 +01:00
|
|
|
'customClient1': invoice ? invoice.client.custom_value1 : 'custom value',
|
|
|
|
'customClient2': invoice ? invoice.client.custom_value2 : 'custom value',
|
2017-04-16 13:31:14 +02:00
|
|
|
'customContact1': invoice ? invoice.client.contacts[0].custom_value1 : 'custom value',
|
|
|
|
'customContact2': invoice ? invoice.client.contacts[0].custom_value2 : 'custom value',
|
2017-06-13 10:13:41 +02:00
|
|
|
'customInvoice1': invoice ? invoice.custom_text_value1 : 'custom value',
|
|
|
|
'customInvoice2': invoice ? invoice.custom_text_value2 : 'custom value',
|
2017-02-05 13:48:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Add any available payment method links
|
|
|
|
@foreach (\App\Models\Gateway::$gatewayTypes as $type)
|
|
|
|
@if ($type != GATEWAY_TYPE_TOKEN)
|
2017-12-03 14:04:17 +01:00
|
|
|
{!! "keys['" . Utils::toCamelCase(\App\Models\GatewayType::getAliasFromId($type)) . "Link'] = '" . auth()->user()->account->getBaseUrl() . "/...';" !!}
|
2017-02-05 13:48:26 +01:00
|
|
|
{!! "keys['" . Utils::toCamelCase(\App\Models\GatewayType::getAliasFromId($type)) . "Button'] = '" . Form::flatButton('pay_now', '#36c157') . "';" !!}
|
|
|
|
@endif
|
|
|
|
@endforeach
|
|
|
|
|
|
|
|
var includesPasswordPlaceholder = str.indexOf('$password') != -1;
|
|
|
|
|
|
|
|
for (var key in keys) {
|
|
|
|
var val = keys[key];
|
|
|
|
var regExp = new RegExp('\\$'+key, 'g');
|
|
|
|
str = str.replace(regExp, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!includesPasswordPlaceholder){
|
|
|
|
var lastSpot = str.lastIndexOf('$password')
|
|
|
|
str = str.slice(0, lastSpot) + str.slice(lastSpot).replace('$password', passwordHtml);
|
|
|
|
}
|
|
|
|
str = str.replace(/\$password/g,'');
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
2017-04-21 13:06:01 +02:00
|
|
|
|
|
|
|
<div class="modal fade" id="templateHelpModal" tabindex="-1" role="dialog" aria-labelledby="templateHelpModalLabel" aria-hidden="true" style="z-index:10001">
|
|
|
|
<div class="modal-dialog" style="min-width:150px">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
|
|
<h4 class="modal-title" id="templateHelpModalLabel">{{ trans('texts.template_help_title') }}</h4>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="container" style="width: 100%; padding-bottom: 0px !important">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-body">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
|
|
|
<p>{{ trans('texts.company_variables') }}</p>
|
|
|
|
<ul>
|
|
|
|
@foreach([
|
|
|
|
'account',
|
|
|
|
'emailSignature',
|
|
|
|
] as $field)
|
|
|
|
<li>${{ $field }}</li>
|
|
|
|
@endforeach
|
|
|
|
</ul>
|
|
|
|
<p>{{ trans('texts.invoice_variables') }}</p>
|
|
|
|
<ul>
|
|
|
|
@foreach([
|
2017-09-02 21:03:45 +02:00
|
|
|
'number',
|
2017-04-21 13:06:01 +02:00
|
|
|
'amount',
|
2017-05-30 15:02:15 +02:00
|
|
|
'total',
|
|
|
|
'balance',
|
2017-09-02 21:03:45 +02:00
|
|
|
'partial',
|
2017-04-21 13:06:01 +02:00
|
|
|
'invoiceDate',
|
|
|
|
'dueDate',
|
|
|
|
'documents',
|
|
|
|
] as $field)
|
|
|
|
<li>${{ $field }}</li>
|
|
|
|
@endforeach
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
2017-09-02 21:03:45 +02:00
|
|
|
<p>{{ trans('texts.client_variables') }}</p>
|
|
|
|
<ul>
|
|
|
|
@foreach([
|
|
|
|
'client',
|
|
|
|
'contact',
|
|
|
|
'firstName',
|
|
|
|
'password',
|
|
|
|
'autoBill',
|
|
|
|
] as $field)
|
|
|
|
<li>${{ $field }}</li>
|
|
|
|
@endforeach
|
|
|
|
</ul>
|
2017-04-21 13:06:01 +02:00
|
|
|
<p>{{ trans('texts.navigation_variables') }}</p>
|
|
|
|
<ul>
|
|
|
|
@foreach([
|
|
|
|
'viewLink',
|
|
|
|
'viewButton',
|
|
|
|
'paymentLink',
|
|
|
|
'paymentButton',
|
|
|
|
'portalLink',
|
|
|
|
'portalButton',
|
|
|
|
] as $field)
|
|
|
|
<li>${{ $field }}</li>
|
|
|
|
@endforeach
|
|
|
|
@foreach (\App\Models\Gateway::$gatewayTypes as $type)
|
|
|
|
@if ($account->getGatewayByType($type))
|
|
|
|
@if ($type != GATEWAY_TYPE_TOKEN)
|
|
|
|
<li>${{ Utils::toCamelCase(\App\Models\GatewayType::getAliasFromId($type)) }}Link</li>
|
|
|
|
<li>${{ Utils::toCamelCase(\App\Models\GatewayType::getAliasFromId($type)) }}Button</li>
|
|
|
|
@endif
|
|
|
|
@endif
|
|
|
|
@endforeach
|
|
|
|
</ul>
|
2018-04-04 15:24:59 +02:00
|
|
|
@if ($account->customLabel('client1') || $account->customLabel('contact1') || $account->customLabel('invoice_text1'))
|
2017-04-21 13:06:01 +02:00
|
|
|
<p>{{ trans('texts.custom_variables') }}</p>
|
|
|
|
<ul>
|
2018-04-04 15:24:59 +02:00
|
|
|
@if ($account->customLabel('client1'))
|
2017-04-21 13:06:01 +02:00
|
|
|
<li>$customClient1</li>
|
|
|
|
@endif
|
2018-04-04 15:24:59 +02:00
|
|
|
@if ($account->customLabel('client2'))
|
2017-04-21 13:06:01 +02:00
|
|
|
<li>$customClient2</li>
|
|
|
|
@endif
|
2018-04-04 15:24:59 +02:00
|
|
|
@if ($account->customLabel('contact1'))
|
2017-04-21 13:06:01 +02:00
|
|
|
<li>$customContact1</li>
|
|
|
|
@endif
|
2018-04-04 15:24:59 +02:00
|
|
|
@if ($account->customLabel('contact2'))
|
2017-04-21 13:06:01 +02:00
|
|
|
<li>$customContact2</li>
|
|
|
|
@endif
|
2018-04-04 15:24:59 +02:00
|
|
|
@if ($account->customLabel('invoice_text1'))
|
2017-04-21 13:06:01 +02:00
|
|
|
<li>$customInvoice1</li>
|
|
|
|
@endif
|
2018-04-04 15:24:59 +02:00
|
|
|
@if ($account->customLabel('invoice_text2'))
|
2017-04-21 13:06:01 +02:00
|
|
|
<li>$customInvoice2</li>
|
|
|
|
@endif
|
|
|
|
</ul>
|
|
|
|
@endif
|
|
|
|
</div>
|
2018-02-14 11:45:31 +01:00
|
|
|
</div><br/>
|
|
|
|
<div class="text-muted">
|
|
|
|
{{ trans('texts.amount_variable_help') }}
|
2017-04-21 13:06:01 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ trans('texts.close') }}</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|