2013-11-26 13:45:07 +01:00
|
|
|
@extends('header')
|
|
|
|
|
2013-12-08 20:08:17 +01:00
|
|
|
@section('head')
|
|
|
|
@parent
|
|
|
|
|
2014-01-05 15:03:29 +01:00
|
|
|
<script src="{{ asset('js/pdf_viewer.js') }}" type="text/javascript"></script>
|
|
|
|
<script src="{{ asset('js/compatibility.js') }}" type="text/javascript"></script>
|
2013-12-08 20:08:17 +01:00
|
|
|
@stop
|
|
|
|
|
2013-11-26 13:45:07 +01:00
|
|
|
@section('content')
|
|
|
|
|
2014-04-06 12:18:34 +02:00
|
|
|
@if ($invoice->client->account->isGatewayConfigured() && !$invoice->isPaid())
|
2014-01-09 00:22:56 +01:00
|
|
|
<div class="pull-right" style="width:270px">
|
2014-04-02 15:10:00 +02:00
|
|
|
{{ Button::normal(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}
|
|
|
|
{{ Button::primary_link(URL::to('payment/' . $invitation->invitation_key), trans('texts.pay_now'), array('class' => 'btn-lg pull-right')) }}
|
2014-01-09 00:22:56 +01:00
|
|
|
</div>
|
|
|
|
@else
|
|
|
|
<div class="pull-right">
|
2014-01-06 19:03:00 +01:00
|
|
|
{{ Button::primary('Download PDF', array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}
|
2014-01-09 00:22:56 +01:00
|
|
|
</div>
|
|
|
|
@endif
|
|
|
|
|
2013-12-08 20:08:17 +01:00
|
|
|
<div class="clearfix"></div><p> </p>
|
|
|
|
|
2014-02-18 22:56:18 +01:00
|
|
|
<iframe id="theFrame" frameborder="1" width="100%" height="1180" style="display:none;margin: 0 auto"></iframe>
|
2013-12-31 00:19:17 +01:00
|
|
|
<canvas id="theCanvas" style="display:none;width:100%;border:solid 1px #CCCCCC;"></canvas>
|
2013-11-26 13:45:07 +01:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
$(function() {
|
2013-12-08 20:08:17 +01:00
|
|
|
window.invoice = {{ $invoice->toJson() }};
|
2014-04-14 13:33:43 +02:00
|
|
|
window.logoImages = {};
|
2014-03-23 13:53:16 +01:00
|
|
|
|
2014-04-14 13:33:43 +02:00
|
|
|
logoImages.imageLogo1 = "{{ HTML::image_data('images/report_logo1.jpg') }}";
|
|
|
|
logoImages.imageLogoWidth1 =120;
|
|
|
|
logoImages.imageLogoHeight1 = 40
|
2014-03-23 13:53:16 +01:00
|
|
|
|
2014-04-14 13:33:43 +02:00
|
|
|
logoImages.imageLogo2 = "{{ HTML::image_data('images/report_logo2.jpg') }}";
|
|
|
|
logoImages.imageLogoWidth2 =325/2;
|
|
|
|
logoImages.imageLogoHeight2 = 81/2;
|
2014-03-23 13:53:16 +01:00
|
|
|
|
2014-04-14 13:33:43 +02:00
|
|
|
logoImages.imageLogo3 = "{{ HTML::image_data('images/report_logo3.jpg') }}";
|
|
|
|
logoImages.imageLogoWidth3 =325/2;
|
|
|
|
logoImages.imageLogoHeight3 = 81/2;
|
2014-03-23 13:53:16 +01:00
|
|
|
|
2013-11-26 13:45:07 +01:00
|
|
|
@if (file_exists($invoice->client->account->getLogoPath()))
|
|
|
|
invoice.image = "{{ HTML::image_data($invoice->client->account->getLogoPath()) }}";
|
|
|
|
invoice.imageWidth = {{ $invoice->client->account->getLogoWidth() }};
|
|
|
|
invoice.imageHeight = {{ $invoice->client->account->getLogoHeight() }};
|
|
|
|
@endif
|
2014-01-06 19:03:00 +01:00
|
|
|
var doc = generatePDF(invoice, true);
|
2014-01-14 12:52:56 +01:00
|
|
|
if (!doc) return;
|
2013-11-26 13:45:07 +01:00
|
|
|
var string = doc.output('datauristring');
|
2014-04-14 13:33:43 +02:00
|
|
|
|
2014-01-27 23:40:40 +01:00
|
|
|
if (isFirefox || (isChrome && !isChromium)) {
|
2013-12-31 00:19:17 +01:00
|
|
|
$('#theFrame').attr('src', string).show();
|
|
|
|
} else {
|
|
|
|
var pdfAsArray = convertDataURIToBinary(string);
|
|
|
|
PDFJS.getDocument(pdfAsArray).then(function getPdfHelloWorld(pdf) {
|
2013-12-08 20:08:17 +01:00
|
|
|
|
2013-12-31 00:19:17 +01:00
|
|
|
pdf.getPage(1).then(function getPageHelloWorld(page) {
|
|
|
|
var scale = 1.5;
|
|
|
|
var viewport = page.getViewport(scale);
|
2013-12-08 20:08:17 +01:00
|
|
|
|
2013-12-31 00:19:17 +01:00
|
|
|
var canvas = document.getElementById('theCanvas');
|
|
|
|
var context = canvas.getContext('2d');
|
|
|
|
canvas.height = viewport.height;
|
|
|
|
canvas.width = viewport.width;
|
2013-12-08 20:08:17 +01:00
|
|
|
|
2013-12-31 00:19:17 +01:00
|
|
|
page.render({canvasContext: context, viewport: viewport});
|
|
|
|
$('#theCanvas').show();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2013-11-26 13:45:07 +01:00
|
|
|
});
|
2014-03-23 13:53:16 +01:00
|
|
|
|
|
|
|
var invoiceLabels = {{ json_encode($invoiceLabels) }};
|
2013-11-26 13:45:07 +01:00
|
|
|
|
2013-12-08 20:08:17 +01:00
|
|
|
function onDownloadClick() {
|
|
|
|
var doc = generatePDF(invoice);
|
|
|
|
doc.save('Invoice-' + invoice.invoice_number + '.pdf');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-26 13:45:07 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
@stop
|