fix invoice preview opening in current tab (#3454)
This commit is contained in:
@@ -127,8 +127,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="w-min text-center">
|
<td class="w-min text-center">
|
||||||
{{ widgets.action_button('print', {'url': '#', 'onclick': 'return singleInvoice(this)', 'title': 'button.preview'|trans, 'target': '_blank', 'class': 'btn btn-sm', 'attr': {'data-customer': model.customer.id, 'data-template': model.template.id, 'data-href': path('invoice_preview', {'customer': model.customer.id, 'token': csrf_token('invoice.preview')})}}) }}
|
{{ widgets.action_button('print', {'url': '#', 'onclick': 'return singleInvoice(this, true)', 'title': 'button.preview'|trans, 'target': '_blank', 'class': 'btn btn-sm', 'attr': {'data-customer': model.customer.id, 'data-template': model.template.id, 'data-href': path('invoice_preview', {'customer': model.customer.id, 'token': csrf_token('invoice.preview')})}}) }}
|
||||||
{{ widgets.action_button('save', {'url': '#', 'onclick': 'return singleInvoice(this)', 'title': 'action.save'|trans, 'class': 'btn btn-sm', 'attr': {'data-customer': model.customer.id, 'data-template': model.template.id, 'data-href': path('invoice_create', {'customer': model.customer.id, 'template': model.template.id, 'token': csrf_token('invoice.create')})}}, 'success') }}
|
{{ widgets.action_button('save', {'url': '#', 'onclick': 'return singleInvoice(this, false)', 'title': 'action.save'|trans, 'class': 'btn btn-sm', 'attr': {'data-customer': model.customer.id, 'data-template': model.template.id, 'data-href': path('invoice_create', {'customer': model.customer.id, 'template': model.template.id, 'token': csrf_token('invoice.create')})}}, 'success') }}
|
||||||
</td>
|
</td>
|
||||||
<td class="w-min text-right hidden-xs">
|
<td class="w-min text-right hidden-xs">
|
||||||
{{ model.calculator.timeWorked|duration(isDecimal) }}
|
{{ model.calculator.timeWorked|duration(isDecimal) }}
|
||||||
@@ -238,20 +238,26 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function singleInvoice(link)
|
function singleInvoice(link, preview)
|
||||||
{
|
{
|
||||||
const formPlugin = kimai.getPlugin('form');
|
const formPlugin = kimai.getPlugin('form');
|
||||||
const overwrites = {'customers[]': link.dataset['customer'], 'template': link.dataset['template']};
|
const overwrites = {'customers[]': link.dataset['customer'], 'template': link.dataset['template']};
|
||||||
const uri = formPlugin.convertFormDataToQueryString(document.getElementById('{{ formId }}'), overwrites);
|
const uri = formPlugin.convertFormDataToQueryString(document.getElementById('{{ formId }}'), overwrites);
|
||||||
|
const invoiceUrl = link.dataset['href'] + '?' + uri;
|
||||||
|
|
||||||
|
if (!preview) {
|
||||||
link.classList.toggle('disabled');
|
link.classList.toggle('disabled');
|
||||||
link.href = 'javascript: void(0)';
|
link.href = 'javascript: void(0)';
|
||||||
|
|
||||||
document.location = link.dataset['href'] + '?' + uri;
|
document.location = invoiceUrl;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
link.href = invoiceUrl;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function saveAllInvoices(link)
|
function saveAllInvoices(link)
|
||||||
{
|
{
|
||||||
const formPlugin = kimai.getPlugin('form');
|
const formPlugin = kimai.getPlugin('form');
|
||||||
|
|||||||
Reference in New Issue
Block a user