1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 23:52:33 +01:00
invoiceninja/resources/views/invoices/view.blade.php

467 lines
17 KiB
PHP
Raw Normal View History

2015-03-16 22:45:25 +01:00
@extends('public.header')
@section('head')
@parent
@include('money_script')
2016-05-29 14:34:44 +02:00
2016-01-07 08:08:30 +01:00
@foreach ($invoice->client->account->getFontFolders() as $font)
2016-11-04 14:34:15 +01:00
<script src="{{ asset('js/vfs_fonts/'.$font.'.js') }}" type="text/javascript"></script>
2016-01-07 08:08:30 +01:00
@endforeach
2016-11-04 14:34:15 +01:00
2016-06-05 21:55:23 +02:00
<script src="{{ asset('pdf.built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script>
2016-05-29 14:34:44 +02:00
2016-11-04 14:34:15 +01:00
@if ($account->showSignature($invoice))
<script src="{{ asset('js/jSignature.min.js') }}"></script>
@endif
2015-03-16 22:45:25 +01:00
<style type="text/css">
body {
2016-05-29 14:34:44 +02:00
background-color: #f8f8f8;
2015-03-16 22:45:25 +01:00
}
2016-04-29 23:50:21 +02:00
.dropdown-menu li a{
overflow:hidden;
margin-top:5px;
margin-bottom:5px;
}
2016-11-04 14:34:15 +01:00
#signature {
border: 2px dotted black;
background-color:lightgrey;
}
2015-03-16 22:45:25 +01:00
</style>
2016-05-07 04:33:03 +02:00
2018-03-29 16:06:23 +02:00
@if (!empty($transactionToken) && $accountGateway->gateway_id == GATEWAY_BRAINTREE && $accountGateway->getPayPalEnabled())
2016-06-20 16:14:43 +02:00
<div id="paypal-container"></div>
2016-05-07 04:33:03 +02:00
<script type="text/javascript" src="https://js.braintreegateway.com/js/braintree-2.23.0.min.js"></script>
<script type="text/javascript" >
$(function() {
2017-12-07 08:54:42 +01:00
var paypalLink = $('a[href$="paypal"]'),
2016-05-07 04:33:03 +02:00
paypalUrl = paypalLink.attr('href'),
checkout;
paypalLink.parent().attr('id', 'paypal-container');
2016-06-20 16:14:43 +02:00
braintree.setup("{{ $transactionToken }}", "custom", {
2016-05-07 04:33:03 +02:00
onReady: function (integration) {
checkout = integration;
2017-12-07 08:54:42 +01:00
$('a[href$="#braintree_paypal"]').each(function(){
2016-05-07 04:33:03 +02:00
var el=$(this);
el.attr('href', el.attr('href').replace('#braintree_paypal','?device_data='+encodeURIComponent(integration.deviceData)))
})
},
paypal: {
container: "paypal-container",
singleUse: false,
enableShippingAddress: false,
enableBillingAddress: false,
headless: true,
2016-06-20 16:14:43 +02:00
locale: "{{ $invoice->client->language ? $invoice->client->language->locale : $invoice->account->language->locale }}"
2016-05-07 04:33:03 +02:00
},
dataCollector: {
paypal: true
},
onPaymentMethodReceived: function (obj) {
2016-06-20 16:14:43 +02:00
window.location.href = paypalUrl.replace('#braintree_paypal', '') + '/' + encodeURIComponent(obj.nonce) + "?device_data=" + encodeURIComponent(JSON.stringify(obj.details));
2016-05-07 04:33:03 +02:00
}
});
paypalLink.click(function(e){
e.preventDefault();
@if ($account->requiresAuthorization($invoice))
window.pendingPaymentFunction = checkout.paypal.initAuthFlow;
showAuthorizationModal();
@else
checkout.paypal.initAuthFlow();
@endif
2016-05-07 04:33:03 +02:00
})
});
</script>
@elseif(!empty($enableWePayACH))
<script type="text/javascript" src="https://static.wepay.com/js/tokenization.v2.js"></script>
<script type="text/javascript">
2017-12-07 08:54:42 +01:00
function payWithWepay() {
var achLink = $('a[href$="/bank_transfer"]');
$('#wepay-error').remove();
var email = {!! json_encode($contact->email) !!} || prompt('{{ trans('texts.ach_email_prompt') }}');
if (!email) {
return;
}
2017-12-07 08:54:42 +01:00
WePay.bank_account.create({
'client_id': '{{ WEPAY_CLIENT_ID }}',
'email':email
}, function(data){
dataObj = JSON.parse(data);
if(dataObj.bank_account_id) {
window.location.href = achLink.attr('href') + '/' + dataObj.bank_account_id + "?details=" + encodeURIComponent(data);
} else if(dataObj.error) {
$('#wepay-error').remove();
achLink.closest('.container').prepend($('<div id="wepay-error" style="margin-top:20px" class="alert alert-danger"></div>').text(dataObj.error_description));
}
});
}
2017-12-07 08:54:42 +01:00
$(function() {
var achLink = $('a[href$="/bank_transfer"]');
WePay.set_endpoint('{{ WEPAY_ENVIRONMENT }}');
achLink.click(function(e) {
e.preventDefault();
@if ($account->requiresAuthorization($invoice))
window.pendingPaymentFunction = window.payWithWepay;
showAuthorizationModal();
@else
payWithWepay();
@endif
});
});
</script>
2017-11-27 16:29:25 +01:00
@elseif (! empty($accountGateway) && $accountGateway->getApplePayEnabled())
<script type="text/javascript" src="https://js.stripe.com/v3/"></script>
<script type="text/javascript">
// https://stripe.com/docs/stripe-js/elements/payment-request-button
2018-03-07 16:23:25 +01:00
var stripe = Stripe('{{ $accountGateway->getPublishableKey() }}');
2017-11-27 16:29:25 +01:00
var paymentRequest = stripe.paymentRequest({
country: '{{ $invoice->client->getCountryCode() }}',
currency: '{{ strtolower($invoice->client->getCurrencyCode()) }}',
total: {
label: '{{ trans('texts.invoice') . ' ' . $invitation->invoice->invoice_number }}',
amount: {{ $invitation->invoice->getRequestedAmount() * 100 }},
},
});
var elements = stripe.elements();
var prButton = elements.create('paymentRequestButton', {
paymentRequest: paymentRequest,
});
$(function() {
// Check the availability of the Payment Request API first.
paymentRequest.canMakePayment().then(function(result) {
2018-01-15 21:43:30 +01:00
if (! result) {
$('#paymentButtons ul.dropdown-menu li').find('a[href$="apple_pay"]').remove();
2017-11-27 16:29:25 +01:00
}
});
});
</script>
2017-11-27 15:50:06 +01:00
@endif
2015-03-16 22:45:25 +01:00
@stop
@section('content')
<div class="container">
2018-04-09 13:45:38 +02:00
@if ($message = $invoice->client->customMessage($invoice->getCustomMessageType()))
@include('invited.custom_message', ['message' => $message])
2018-04-08 15:55:25 +02:00
@endif
2016-06-21 11:40:10 +02:00
@if (!empty($partialView))
2016-06-20 16:14:43 +02:00
@include($partialView)
@else
2016-11-04 14:34:15 +01:00
<div id="paymentButtons" class="pull-right" style="text-align:right">
@if ($invoice->isQuote() && $approveRequired)
2018-03-15 10:11:34 +01:00
{!! Button::normal(trans('texts.download'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}&nbsp;&nbsp;
@if ($showApprove)
2019-01-30 12:00:26 +01:00
{!! Button::success(trans('texts.approve'))->withAttributes(['id' => 'approveButton', 'onclick' => 'onApproveClick()', 'class' => 'require-authorization'])->large() !!}
@elseif ($invoiceLink = $invoice->getInvoiceLinkForQuote($contact->id))
{!! Button::success(trans('texts.view_invoice'))->asLinkTo($invoiceLink)->large() !!}
@endif
@elseif ($invoice->isQuote() && $invoiceLink = $invoice->getInvoiceLinkForQuote($contact->id))
{!! Button::normal(trans('texts.download'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}
{!! Button::success(trans('texts.view_invoice'))->asLinkTo($invoiceLink)->large() !!}
@elseif ( ! $invoice->canBePaid())
2018-03-15 10:11:34 +01:00
{!! Button::normal(trans('texts.download'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}
2016-11-06 12:44:58 +01:00
@elseif ($invoice->client->account->isGatewayConfigured() && floatval($invoice->balance) && !$invoice->is_recurring)
2018-03-15 10:11:34 +01:00
{!! Button::normal(trans('texts.download'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}&nbsp;&nbsp;
2019-01-30 12:00:26 +01:00
<span class="require-authorization">
@if (count($paymentTypes) > 1)
{!! DropdownButton::success(trans('texts.pay_now'))->withContents($paymentTypes)->large() !!}
@elseif (count($paymentTypes) == 1)
<a href='{{ $paymentURL }}' class="btn btn-success btn-lg">{{ trans('texts.pay_now') }} {!! $invoice->present()->gatewayFee($gatewayTypeId) !!}</a>
@endif
</span>
2016-05-11 08:22:43 +02:00
@else
2018-03-15 10:11:34 +01:00
{!! Button::normal(trans('texts.download'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}
@endif
@if ($account->isNinjaAccount())
{!! Button::primary(trans('texts.return_to_app'))->asLinkTo(URL::to('/settings/account_management'))->large() !!}
@endif
</div>
@endif
2015-03-16 22:45:25 +01:00
2016-06-20 16:14:43 +02:00
<div class="pull-left">
@if(!empty($documentsZipURL))
{!! Button::normal(trans('texts.download_documents', array('size'=>Form::human_filesize($documentsZipSize))))->asLinkTo($documentsZipURL)->large() !!}
@endif
</div>
2015-03-16 22:45:25 +01:00
<div class="clearfix"></div><p>&nbsp;</p>
@if ($account->isPro() && $invoice->hasDocuments())
<div class="invoice-documents">
<h3>{{ trans('texts.documents_header') }}</h3>
<ul>
2017-07-21 13:01:48 +02:00
@foreach ($invoice->allDocuments() as $document)
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
@endforeach
</ul>
</div>
@endif
2016-05-29 14:34:44 +02:00
@if ($account->hasFeature(FEATURE_DOCUMENTS) && $account->invoice_embed_documents)
2016-03-23 23:40:42 +01:00
@foreach ($invoice->documents as $document)
@if($document->isPDFEmbeddable())
<script src="{{ $document->getClientVFSJSUrl() }}" type="text/javascript" async></script>
@endif
2016-03-23 23:40:42 +01:00
@endforeach
@foreach ($invoice->expenses as $expense)
@foreach ($expense->documents as $document)
@if($document->isPDFEmbeddable())
<script src="{{ $document->getClientVFSJSUrl() }}" type="text/javascript" async></script>
@endif
@endforeach
@endforeach
2016-03-23 23:40:42 +01:00
@endif
2015-03-16 22:45:25 +01:00
<script type="text/javascript">
2017-05-08 21:10:39 +02:00
window.invoice = {!! $invoice !!};
invoice.features = {
customize_invoice_design:{{ $invoice->client->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
2016-04-19 22:01:44 +02:00
remove_created_by:{{ $invoice->client->account->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
invoice_settings:{{ $invoice->client->account->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
};
2016-05-29 14:34:44 +02:00
invoice.is_quote = {{ $invoice->isQuote() ? 'true' : 'false' }};
2017-05-08 21:10:39 +02:00
invoice.contact = {!! $contact !!};
2015-03-16 22:45:25 +01:00
function getPDFString(cb) {
2015-09-17 21:01:06 +02:00
return generatePDF(invoice, invoice.invoice_design.javascript, true, cb);
2015-03-16 22:45:25 +01:00
}
2015-11-21 22:10:26 +01:00
if (window.hasOwnProperty('pjsc_meta')) {
window['pjsc_meta'].remainingTasks++;
}
2018-02-18 19:15:37 +01:00
function waitForSignature() {
2018-04-27 11:07:12 +02:00
if (window.signatureAsPNG || ! invoice.invitations[0].signature_base64) {
2018-02-18 19:15:37 +01:00
writePdfAsString();
} else {
window.setTimeout(waitForSignature, 100);
}
}
function writePdfAsString() {
doc = getPDFString();
doc.getDataUrl(function(pdfString) {
document.write(pdfString);
document.close();
if (window.hasOwnProperty('pjsc_meta')) {
window['pjsc_meta'].remainingTasks--;
}
});
}
2015-03-16 22:45:25 +01:00
$(function() {
2015-09-17 21:01:06 +02:00
@if (Input::has('phantomjs'))
2017-07-03 12:15:06 +02:00
@if (Input::has('phantomjs_balances'))
document.write(calculateAmounts(invoice).total_amount);
document.close();
if (window.hasOwnProperty('pjsc_meta')) {
window['pjsc_meta'].remainingTasks--;
}
@else
2018-02-18 19:15:37 +01:00
@if ($account->signature_on_pdf)
refreshPDF();
waitForSignature();
@else
writePdfAsString();
@endif
2017-07-03 12:15:06 +02:00
@endif
2016-05-29 14:34:44 +02:00
@else
2015-09-17 21:01:06 +02:00
refreshPDF();
@endif
2016-11-04 14:34:15 +01:00
@if ($account->requiresAuthorization($invoice) && ! $invitation->signature_date)
2019-01-30 12:00:26 +01:00
$('.require-authorization a').on('click', function(e) {
2016-11-04 14:34:15 +01:00
e.preventDefault();
window.pendingPaymentHref = $(this).attr('href');
showAuthorizationModal();
2016-11-04 14:34:15 +01:00
});
@if ($account->showSignature($invoice))
$('#authorizationModal').on('shown.bs.modal', function () {
2016-11-04 14:34:15 +01:00
if ( ! window.pendingPaymentInit) {
window.pendingPaymentInit = true;
$("#signature").jSignature().bind('change', function(e) {
setModalPayNowEnabled();
});;
}
});
@endif
@endif
2015-03-16 22:45:25 +01:00
});
2016-05-29 14:34:44 +02:00
function showAuthorizationModal() {
@if ($account->showSignature($invoice))
if (window.pendingPaymentInit) {
$("#signature").jSignature('reset');
}
@endif
@if ($account->showAcceptTerms($invoice))
$('#termsCheckbox').attr('checked', false);
@endif
$('#authorizationModal').modal('show');
}
2017-12-14 12:10:05 +01:00
function onApproveClick() {
@if ($account->requiresAuthorization($invoice))
window.pendingPaymentFunction = approveQuote;
showAuthorizationModal();
@else
approveQuote();
@endif
}
function approveQuote() {
2017-12-14 12:10:05 +01:00
$('#approveButton').prop('disabled', true);
2017-12-14 12:33:08 +01:00
location.href = "{{ url('/approve/' . $invitation->invitation_key) }}";
2017-12-14 12:10:05 +01:00
}
2015-03-16 22:45:25 +01:00
function onDownloadClick() {
2017-05-24 10:28:11 +02:00
try {
var doc = generatePDF(invoice, invoice.invoice_design.javascript, true);
var fileName = invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice;
doc.save(fileName + '_' + invoice.invoice_number + '.pdf');
2017-05-24 10:28:11 +02:00
} catch (exception) {
2017-05-25 19:29:47 +02:00
if (location.href.indexOf('/view/') > 0) {
2017-05-24 10:28:11 +02:00
location.href = location.href.replace('/view/', '/download/');
}
}
2015-03-16 22:45:25 +01:00
}
2018-04-13 12:50:38 +02:00
function showCustom1Modal() {
$('#custom1GatewayModal').modal('show');
}
function showCustom2Modal() {
$('#custom2GatewayModal').modal('show');
}
function showCustom3Modal() {
$('#custom3GatewayModal').modal('show');
2016-09-26 11:33:30 +02:00
}
2016-11-04 14:34:15 +01:00
function onModalPayNowClick() {
@if ($account->showSignature($invoice))
var data = {
signature: $('#signature').jSignature('getData', 'svgbase64')[1]
};
@else
var data = false;
2016-11-04 14:34:15 +01:00
@endif
$.ajax({
url: "{{ URL::to('authorize/' . $invitation->invitation_key) }}",
type: 'PUT',
data: data,
success: function(response) {
redirectToPayment();
2017-03-21 09:13:48 +01:00
},
error: function(response) {
2017-03-21 09:45:33 +01:00
alert("{{ trans('texts.error_refresh_page') }}");
2017-03-21 09:13:48 +01:00
}
});
2016-11-04 14:34:15 +01:00
}
function redirectToPayment() {
$('#authorizationModal').modal('hide');
if (window.pendingPaymentFunction) {
window.pendingPaymentFunction();
} else {
location.href = window.pendingPaymentHref;
}
2016-11-04 14:34:15 +01:00
}
function setModalPayNowEnabled() {
var disabled = false;
@if ($account->showAcceptTerms($invoice))
if ( ! $('#termsCheckbox').is(':checked')) {
disabled = true;
}
@endif
@if ($account->showSignature($invoice))
if ( ! $('#signature').jSignature('isModified')) {
disabled = true;
}
@endif
$('#modalPayNowButton').attr('disabled', disabled);
}
2015-03-16 22:45:25 +01:00
</script>
2016-12-20 13:43:43 +01:00
@include('invoices.pdf', ['account' => $invoice->client->account])
2015-03-16 22:45:25 +01:00
<p>&nbsp;</p>
2016-03-23 23:40:42 +01:00
</div>
2016-09-26 11:33:30 +02:00
2018-04-13 12:50:38 +02:00
@if ($customGateway = $account->getGatewayByType(GATEWAY_TYPE_CUSTOM1))
@include('invited.custom_gateway', ['customGateway' => $customGateway, 'number' => 1])
@endif
@if ($customGateway = $account->getGatewayByType(GATEWAY_TYPE_CUSTOM2))
@include('invited.custom_gateway', ['customGateway' => $customGateway, 'number' => 2])
@endif
@if ($customGateway = $account->getGatewayByType(GATEWAY_TYPE_CUSTOM3))
@include('invited.custom_gateway', ['customGateway' => $customGateway, 'number' => 3])
@endif
2016-11-04 14:34:15 +01:00
@if ($account->requiresAuthorization($invoice))
<div class="modal fade" id="authorizationModal" tabindex="-1" role="dialog" aria-labelledby="authorizationModalLabel" aria-hidden="true">
2016-11-04 14:34:15 +01:00
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
2016-11-06 12:44:58 +01:00
<h4 class="modal-title">{{ trans('texts.authorization') }}</h4>
2016-11-04 14:34:15 +01:00
</div>
<div class="panel-body">
2017-01-01 12:27:22 +01:00
@if ($invoice->terms)
<div class="well" style="max-height:300px;overflow-y:scroll">
{!! nl2br(e($invoice->terms)) !!}
</div>
@endif
2016-11-04 14:34:15 +01:00
@if ($account->showSignature($invoice))
<div>
{{ trans('texts.sign_here') }}
</div>
<div id="signature"></div><br/>
@endif
</div>
<div class="modal-footer">
@if ($account->showAcceptTerms($invoice))
<div class="pull-left">
<label for="termsCheckbox" style="font-weight:normal">
<input id="termsCheckbox" type="checkbox" onclick="setModalPayNowEnabled()"/>
&nbsp;{{ trans('texts.i_agree') }}
</label>
</div>
@endif
2017-01-01 12:27:22 +01:00
<button id="modalPayNowButton" type="button" class="btn btn-success" onclick="onModalPayNowClick()" disabled="">
{{ $invoice->isQuote() ? trans('texts.approve') : trans('texts.pay_now') }}
</button>
2016-11-04 14:34:15 +01:00
</div>
</div>
</div>
</div>
@endif
2015-03-27 10:32:45 +01:00
@stop