2017-01-06 11:52:36 +01:00
|
|
|
@if (empty($hide_pdf))
|
2017-02-09 19:49:30 +01:00
|
|
|
<object id="pdfObject" type="application/pdf" style="display:block;background-color:#525659;border:solid 2px #9a9a9a;" frameborder="1" width="100%" height="{{ isset($pdfHeight) ? $pdfHeight : 1180 }}px"></object>
|
|
|
|
<div id="pdfCanvas" style="display:none;width:100%;background-color:#525659;border:solid 2px #9a9a9a;padding-top:40px;text-align:center">
|
2017-01-05 11:46:03 +01:00
|
|
|
<canvas id="theCanvas" style="max-width:100%;border:solid 1px #CCCCCC;"></canvas>
|
2017-01-02 21:35:58 +01:00
|
|
|
</div>
|
2017-12-27 11:54:50 +01:00
|
|
|
<canvas id="signatureCanvas" style="display:none;"></canvas>
|
2017-01-06 11:52:36 +01:00
|
|
|
@endif
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2015-07-07 22:08:16 +02:00
|
|
|
@if (!Utils::isNinja() || !Utils::isPro())
|
2015-03-16 22:45:25 +01:00
|
|
|
<div class="modal fade" id="moreDesignsModal" tabindex="-1" role="dialog" aria-labelledby="moreDesignsModalLabel" 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">×</button>
|
|
|
|
<h4 class="modal-title">{{ trans('texts.more_designs_title') }}</h4>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
@if (Utils::isNinja())
|
|
|
|
<h3>{{ trans('texts.more_designs_cloud_header') }}</h3>
|
2016-05-15 22:16:08 +02:00
|
|
|
<p>{{ trans('texts.more_designs_cloud_text') }}</p>
|
2015-03-16 22:45:25 +01:00
|
|
|
@else
|
2016-05-15 22:16:08 +02:00
|
|
|
<h3>{{ trans('texts.more_designs_self_host_header', ['price' => INVOICE_DESIGNS_PRICE]) }}</h3>
|
2015-03-16 22:45:25 +01:00
|
|
|
<p>{{ trans('texts.more_designs_self_host_text') }}</p>
|
|
|
|
@endif
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<center id="designThumbs">
|
|
|
|
<p> </p>
|
2016-02-25 11:16:27 +01:00
|
|
|
<a href="{{ asset('/images/designs/business.png') }}" data-lightbox="more-designs" data-title="Business">
|
|
|
|
<img src="{{ BLANK_IMAGE }}" data-src="{{ asset('/images/designs/business_thumb.png') }}"/>
|
|
|
|
</a>
|
|
|
|
<a href="{{ asset('/images/designs/creative.png') }}" data-lightbox="more-designs" data-title="Creative">
|
|
|
|
<img src="{{ BLANK_IMAGE }}" data-src="{{ asset('/images/designs/creative_thumb.png') }}"/>
|
|
|
|
</a>
|
|
|
|
<a href="{{ asset('/images/designs/elegant.png') }}" data-lightbox="more-designs" data-title="Elegant">
|
|
|
|
<img src="{{ BLANK_IMAGE }}" data-src="{{ asset('/images/designs/elegant_thumb.png') }}"/>
|
|
|
|
</a>
|
2015-03-16 22:45:25 +01:00
|
|
|
<p> </p>
|
2016-02-25 11:16:27 +01:00
|
|
|
<a href="{{ asset('/images/designs/hipster.png') }}" data-lightbox="more-designs" data-title="Hipster">
|
|
|
|
<img src="{{ BLANK_IMAGE }}" data-src="{{ asset('/images/designs/hipster_thumb.png') }}"/>
|
|
|
|
</a>
|
|
|
|
<a href="{{ asset('/images/designs/playful.png') }}" data-lightbox="more-designs" data-title="Playful">
|
|
|
|
<img src="{{ BLANK_IMAGE }}" data-src="{{ asset('/images/designs/playful_thumb.png') }}"/>
|
|
|
|
</a>
|
|
|
|
<a href="{{ asset('/images/designs/photo.png') }}" data-lightbox="more-designs" data-title="Photo">
|
|
|
|
<img src="{{ BLANK_IMAGE }}" data-src="{{ asset('/images/designs/photo_thumb.png') }}"/>
|
|
|
|
</a>
|
2015-03-16 22:45:25 +01:00
|
|
|
<p> </p>
|
|
|
|
</center>
|
|
|
|
|
2016-05-15 22:16:08 +02:00
|
|
|
<div class="modal-footer" id="signUpFooter">
|
2015-03-16 22:45:25 +01:00
|
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
|
2016-05-15 22:16:08 +02:00
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
@if (Utils::isNinjaProd())
|
2016-10-16 15:38:04 +02:00
|
|
|
<a class="btn btn-primary" href="javascript:showUpgradeModal()">{{ trans('texts.go_pro') }}</a>
|
2015-03-16 22:45:25 +01:00
|
|
|
@else
|
|
|
|
<button type="button" class="btn btn-primary" onclick="buyProduct('{{ INVOICE_DESIGNS_AFFILIATE_KEY }}', '{{ PRODUCT_INVOICE_DESIGNS }}')">{{ trans('texts.buy') }}</button>
|
|
|
|
@endif
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-07-07 22:08:16 +02:00
|
|
|
@endif
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
window.logoImages = {};
|
2016-05-15 22:16:08 +02:00
|
|
|
|
2016-03-02 14:36:42 +01:00
|
|
|
logoImages.imageLogo1 = "{{ Form::image_data('images/report_logo1.jpg') }}";
|
2015-03-16 22:45:25 +01:00
|
|
|
logoImages.imageLogoWidth1 =120;
|
|
|
|
logoImages.imageLogoHeight1 = 40
|
|
|
|
|
2016-03-02 14:36:42 +01:00
|
|
|
logoImages.imageLogo2 = "{{ Form::image_data('images/report_logo2.jpg') }}";
|
2015-03-16 22:45:25 +01:00
|
|
|
logoImages.imageLogoWidth2 =325/2;
|
|
|
|
logoImages.imageLogoHeight2 = 81/2;
|
|
|
|
|
2016-06-29 21:48:56 +02:00
|
|
|
logoImages.imageLogo3 = "{{ Form::image_data('images/report_logo3.png') }}";
|
2015-03-16 22:45:25 +01:00
|
|
|
logoImages.imageLogoWidth3 =325/2;
|
|
|
|
logoImages.imageLogoHeight3 = 81/2;
|
|
|
|
|
2016-01-18 15:09:06 +01:00
|
|
|
@if ($account->hasLogo())
|
2016-03-22 21:19:55 +01:00
|
|
|
window.accountLogo = "{{ Form::image_data($account->getLogoRaw(), true) }}";
|
2015-03-16 22:45:25 +01:00
|
|
|
if (window.invoice) {
|
2015-07-21 20:51:56 +02:00
|
|
|
invoice.image = window.accountLogo;
|
2015-03-16 22:45:25 +01:00
|
|
|
invoice.imageWidth = {{ $account->getLogoWidth() }};
|
2016-05-15 22:16:08 +02:00
|
|
|
invoice.imageHeight = {{ $account->getLogoHeight() }};
|
2015-03-16 22:45:25 +01:00
|
|
|
}
|
|
|
|
@endif
|
|
|
|
|
2018-04-11 22:18:01 +02:00
|
|
|
@if ($account->isEnterprise() && $account->background_image_id && $account->background_image)
|
2018-04-17 20:12:10 +02:00
|
|
|
window.accountBackground = "{{ Form::image_data($account->background_image->getRawCached(), true) }}";
|
2018-04-11 22:18:01 +02:00
|
|
|
@endif
|
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
var NINJA = NINJA || {};
|
2016-04-19 04:35:18 +02:00
|
|
|
@if ($account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN))
|
2015-10-13 09:11:44 +02:00
|
|
|
NINJA.primaryColor = "{{ $account->primary_color }}";
|
|
|
|
NINJA.secondaryColor = "{{ $account->secondary_color }}";
|
|
|
|
NINJA.fontSize = {{ $account->font_size }};
|
2016-01-13 07:18:26 +01:00
|
|
|
NINJA.headerFont = {!! json_encode($account->getHeaderFontName()) !!};
|
|
|
|
NINJA.bodyFont = {!! json_encode($account->getBodyFontName()) !!};
|
2016-03-06 22:25:00 +01:00
|
|
|
@else
|
|
|
|
NINJA.primaryColor = "";
|
|
|
|
NINJA.secondaryColor = "";
|
|
|
|
NINJA.fontSize = 9;
|
|
|
|
NINJA.headerFont = "Roboto";
|
2016-05-15 22:16:08 +02:00
|
|
|
NINJA.bodyFont = "Roboto";
|
2015-10-13 09:11:44 +02:00
|
|
|
@endif
|
2016-05-15 22:16:08 +02:00
|
|
|
|
2017-05-08 21:10:39 +02:00
|
|
|
var invoiceLabels = {!! json_encode($account->getInvoiceLabels()) !!};
|
2015-03-16 22:45:25 +01:00
|
|
|
var isRefreshing = false;
|
|
|
|
var needsRefresh = false;
|
|
|
|
|
2015-07-21 20:51:56 +02:00
|
|
|
function refreshPDF(force) {
|
2017-10-30 10:55:33 +01:00
|
|
|
try {
|
2017-05-24 10:00:35 +02:00
|
|
|
return getPDFString(refreshPDFCB, force);
|
|
|
|
} catch (exception) {
|
2017-08-10 18:05:21 +02:00
|
|
|
@if (Utils::isTravis())
|
|
|
|
var message = exception.message || '';
|
|
|
|
if (message.indexOf('Attempting to change value of a readonly property') >= 0) {
|
|
|
|
// do nothing
|
|
|
|
} else {
|
|
|
|
throw exception;
|
|
|
|
}
|
|
|
|
@else
|
2018-04-29 16:27:55 +02:00
|
|
|
console.log(exception);
|
2017-08-10 18:05:21 +02:00
|
|
|
console.warn('Failed to generate PDF: %s', exception.message);
|
|
|
|
var href = location.href;
|
|
|
|
if (href.indexOf('/view/') > 0 && href.indexOf('phantomjs') == -1) {
|
|
|
|
var url = href.replace('/view/', '/download/') + '?base64=true';
|
|
|
|
$.get(url, function(result) {
|
|
|
|
if (result && result.indexOf('data:application/pdf') == 0) {
|
|
|
|
refreshPDFCB(result);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
@endif
|
2017-05-24 10:00:35 +02:00
|
|
|
}
|
2015-04-13 08:02:33 +02:00
|
|
|
}
|
2016-05-15 22:16:08 +02:00
|
|
|
|
2015-04-13 08:02:33 +02:00
|
|
|
function refreshPDFCB(string) {
|
|
|
|
if (!string) return;
|
2017-01-06 11:52:36 +01:00
|
|
|
@if ( !empty($hide_pdf))
|
|
|
|
return;
|
|
|
|
@endif
|
2015-03-16 22:45:25 +01:00
|
|
|
PDFJS.workerSrc = '{{ asset('js/pdf_viewer.worker.js') }}';
|
2016-12-20 13:43:43 +01:00
|
|
|
var forceJS = {{ Auth::check() && Auth::user()->force_pdfjs ? 'true' : 'false' }};
|
|
|
|
// Use the browser's built in PDF viewer
|
2017-01-16 14:31:24 +01:00
|
|
|
if ((isChrome || isFirefox) && ! forceJS && ! isMobile) {
|
2017-02-09 19:49:30 +01:00
|
|
|
document.getElementById('pdfObject').data = string;
|
2016-12-20 13:43:43 +01:00
|
|
|
// Use PDFJS to view the PDF
|
2016-05-15 22:16:08 +02:00
|
|
|
} else {
|
2015-03-16 22:45:25 +01:00
|
|
|
if (isRefreshing) {
|
2016-03-23 23:40:42 +01:00
|
|
|
needsRefresh = true;
|
2015-03-16 22:45:25 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
isRefreshing = true;
|
2016-05-15 22:16:08 +02:00
|
|
|
var pdfAsArray = convertDataURIToBinary(string);
|
2015-03-16 22:45:25 +01:00
|
|
|
PDFJS.getDocument(pdfAsArray).then(function getPdfHelloWorld(pdf) {
|
|
|
|
|
|
|
|
pdf.getPage(1).then(function getPageHelloWorld(page) {
|
|
|
|
var scale = 1.5;
|
|
|
|
var viewport = page.getViewport(scale);
|
|
|
|
|
|
|
|
var canvas = document.getElementById('theCanvas');
|
|
|
|
var context = canvas.getContext('2d');
|
|
|
|
canvas.height = viewport.height;
|
|
|
|
canvas.width = viewport.width;
|
|
|
|
|
|
|
|
page.render({canvasContext: context, viewport: viewport});
|
2017-02-09 19:49:30 +01:00
|
|
|
$('#pdfObject').hide();
|
|
|
|
$('#pdfCanvas').show();
|
2015-03-16 22:45:25 +01:00
|
|
|
isRefreshing = false;
|
|
|
|
if (needsRefresh) {
|
|
|
|
needsRefresh = false;
|
|
|
|
refreshPDF();
|
|
|
|
}
|
|
|
|
});
|
2016-05-15 22:16:08 +02:00
|
|
|
});
|
2015-03-16 22:45:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showMoreDesigns() {
|
2016-02-25 11:16:27 +01:00
|
|
|
loadImages('#designThumbs');
|
2015-06-01 15:06:18 +02:00
|
|
|
trackEvent('/account', '/view_more_designs');
|
2015-03-16 22:45:25 +01:00
|
|
|
$('#moreDesignsModal').modal('show');
|
|
|
|
}
|
|
|
|
|
2017-12-27 12:10:59 +01:00
|
|
|
window.signatureAsPNG = false;
|
2017-12-27 11:54:50 +01:00
|
|
|
function convertSignature(invoice) {
|
|
|
|
if (! invoice || ! invoice.invitations || ! invoice.invitations.length) {
|
|
|
|
return invoice;
|
|
|
|
}
|
|
|
|
|
2017-12-28 09:02:59 +01:00
|
|
|
for (var i=0; i<invoice.invitations.length; i++) {
|
|
|
|
var invitation = invoice.invitations[i];
|
|
|
|
if (invitation.signature_base64) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! invitation.signature_base64) {
|
|
|
|
return invoice;
|
|
|
|
}
|
|
|
|
|
|
|
|
var sourceSVG = invitation.signature_base64;
|
2017-12-27 11:54:50 +01:00
|
|
|
if (! sourceSVG || sourceSVG.indexOf('data:image') == 0) {
|
|
|
|
return invoice;
|
|
|
|
}
|
2017-12-27 12:10:59 +01:00
|
|
|
if (window.signatureAsPNG) {
|
|
|
|
invoice.invitations[0].signature_base64 = window.signatureAsPNG;
|
|
|
|
return invoice;
|
|
|
|
} else {
|
|
|
|
var signatureDiv = $('#signatureCanvas')[0];
|
|
|
|
var ctx = signatureDiv.getContext('2d');
|
|
|
|
var img = new Image();
|
|
|
|
img.src = "data:image/svg+xml;base64," + sourceSVG;
|
|
|
|
img.onload = function() {
|
|
|
|
ctx.drawImage(img, 0, 0);
|
|
|
|
var blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=';
|
|
|
|
var image = signatureDiv.toDataURL("image/png") || blankImage;
|
|
|
|
window.signatureAsPNG = invoice.invitations[0].signature_base64 = image;
|
|
|
|
refreshPDF();
|
|
|
|
}
|
2017-12-27 11:54:50 +01:00
|
|
|
|
2017-12-27 12:10:59 +01:00
|
|
|
return false;
|
2017-12-27 11:54:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-15 22:16:08 +02:00
|
|
|
</script>
|