1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 17:31:35 +02:00
invoiceninja/resources/views/invoices/view.blade.php

354 lines
14 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
2016-11-04 14:34:15 +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
2016-06-21 11:40:10 +02:00
@if (!empty($transactionToken) && $accountGateway->gateway_id == GATEWAY_BRAINTREE)
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() {
2016-06-20 16:14:43 +02:00
var paypalLink = $('.dropdown-menu 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;
$('.dropdown-menu a[href$="#braintree_paypal"]').each(function(){
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();
checkout.paypal.initAuthFlow();
})
});
</script>
@elseif(!empty($enableWePayACH))
<script type="text/javascript" src="https://static.wepay.com/js/tokenization.v2.js"></script>
<script type="text/javascript">
$(function() {
2016-06-21 18:10:22 +02:00
var achLink = $('.dropdown-menu a[href$="/bank_transfer"]'),
achUrl = achLink.attr('href');
WePay.set_endpoint('{{ WEPAY_ENVIRONMENT }}');
achLink.click(function(e) {
e.preventDefault();
$('#wepay-error').remove();
var email = {!! json_encode($contact->email) !!} || prompt('{{ trans('texts.ach_email_prompt') }}');
if(!email)return;
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));
}
});
});
});
</script>
2016-05-07 04:33:03 +02:00
@endif
2015-03-16 22:45:25 +01:00
@stop
@section('content')
<div class="container">
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">
2016-05-29 14:34:44 +02:00
@if ($invoice->isQuote())
{!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}&nbsp;&nbsp;
@if ($showApprove)
{!! Button::success(trans('texts.approve'))->asLinkTo(URL::to('/approve/' . $invitation->invitation_key))->large() !!}
@endif
2016-11-06 12:44:58 +01:00
@elseif ($invoice->client->account->isGatewayConfigured() && floatval($invoice->balance) && !$invoice->is_recurring)
{!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}&nbsp;&nbsp;
@if (count($paymentTypes) > 1)
{!! DropdownButton::success(trans('texts.pay_now'))->withContents($paymentTypes)->large() !!}
2016-09-26 11:33:30 +02:00
@elseif (count($paymentTypes) == 1)
<a href='{!! $paymentURL !!}' class="btn btn-success btn-lg">{{ trans('texts.pay_now') }}</a>
2016-05-29 14:34:44 +02:00
@endif
2016-05-11 08:22:43 +02:00
@else
{!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}
2016-05-11 08:22:43 +02:00
@if ($account->isNinjaAccount())
{!! Button::primary(trans('texts.return_to_app'))->asLinkTo(URL::to('/settings/account_management'))->large() !!}
2016-05-11 08:22:43 +02:00
@endif
@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>
@foreach ($invoice->documents as $document)
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
@endforeach
@foreach ($invoice->expenses as $expense)
@foreach ($expense->documents as $document)
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
@endforeach
@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">
2015-03-31 19:42:37 +02:00
window.invoice = {!! $invoice->toJson() !!};
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' }};
2015-03-31 19:42:37 +02:00
invoice.contact = {!! $contact->toJson() !!};
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++;
}
2015-03-16 22:45:25 +01:00
$(function() {
2015-09-17 21:01:06 +02:00
@if (Input::has('phantomjs'))
doc = getPDFString();
doc.getDataUrl(function(pdfString) {
document.write(pdfString);
document.close();
2016-05-29 14:34:44 +02:00
2015-11-21 22:10:26 +01:00
if (window.hasOwnProperty('pjsc_meta')) {
window['pjsc_meta'].remainingTasks--;
}
2015-09-17 21:01:06 +02:00
});
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->showAuthenticatePanel($invoice))
$('#paymentButtons a').on('click', function(e) {
e.preventDefault();
window.pendingPaymentHref = $(this).attr('href');
@if ($account->showSignature($invoice))
if (window.pendingPaymentInit) {
$("#signature").jSignature('reset');
}
@endif
@if ($account->showAcceptTerms($invoice))
$('#termsCheckbox').attr('checked', false);
@endif
$('#authenticationModal').modal('show');
});
@if ($account->showSignature($invoice))
$('#authenticationModal').on('shown.bs.modal', function () {
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
2015-03-16 22:45:25 +01:00
function onDownloadClick() {
var doc = generatePDF(invoice, invoice.invoice_design.javascript, true);
2015-04-27 14:28:40 +02:00
var fileName = invoice.is_quote ? invoiceLabels.quote : invoiceLabels.invoice;
2015-03-16 22:45:25 +01:00
doc.save(fileName + '-' + invoice.invoice_number + '.pdf');
}
2016-09-26 11:33:30 +02:00
function showCustomModal() {
$('#customGatewayModal').modal('show');
}
2016-11-04 14:34:15 +01:00
function onModalPayNowClick() {
@if ($account->showSignature($invoice))
var data = {
signature: $('#signature').jSignature('getData', 'svgbase64')[1]
};
$.ajax({
url: "{{ URL::to('sign/' . $invitation->invitation_key) }}",
type: 'PUT',
data: data,
success: function(response) {
redirectToPayment();
}
});
@else
redirectToPayment();
@endif
}
function redirectToPayment() {
$('#authenticationModal').modal('hide');
location.href = window.pendingPaymentHref;
}
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>
@include('invoices.pdf', ['account' => $invoice->client->account, 'viewPDF' => true])
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
@if (isset($customGatewayName))
<div class="modal fade" id="customGatewayModal" tabindex="-1" role="dialog" aria-labelledby="customGatewayModalLabel" aria-hidden="true">
<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>
<h4 class="modal-title">{{ $customGatewayName }}</h4>
</div>
<div class="panel-body">
{!! nl2br(e($customGatewayText)) !!}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.close') }}</button>
</div>
</div>
</div>
</div>
@endif
2016-11-04 14:34:15 +01:00
@if ($account->showAuthenticatePanel($invoice))
<div class="modal fade" id="authenticationModal" tabindex="-1" role="dialog" aria-labelledby="authenticationModalLabel" aria-hidden="true">
<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">
2016-11-06 12:44:58 +01:00
<div class="well" style="max-height:300px;overflow-y:scroll">
2016-11-04 14:34:15 +01:00
{!! nl2br(e($invoice->terms)) !!}
</div>
@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
<button id="modalPayNowButton" type="button" class="btn btn-success" onclick="onModalPayNowClick()" disabled="">{{ trans('texts.pay_now') }}</button>
</div>
</div>
</div>
</div>
@endif
2015-03-27 10:32:45 +01:00
@stop