bug fixes

This commit is contained in:
Hillel Coren 2013-12-08 21:08:17 +02:00
parent ccd7a9f3a7
commit 352cf9182a
8 changed files with 75 additions and 37 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/app/config/staging /app/config/staging
/public/logo
/bootstrap/compiled.php /bootstrap/compiled.php
/vendor /vendor
composer.phar composer.phar

View File

@ -55,4 +55,5 @@ Configure config/database.php and then initialize the database
* [Intervention/image](https://github.com/Intervention/image) - PHP Image Manipulation * [Intervention/image](https://github.com/Intervention/image) - PHP Image Manipulation
* [webpatser/laravel-countries](https://github.com/webpatser/laravel-countries) - Almost ISO 3166_2, 3166_3, currency, Capital and more for all countries * [webpatser/laravel-countries](https://github.com/webpatser/laravel-countries) - Almost ISO 3166_2, 3166_3, currency, Capital and more for all countries
* [briannesbitt/Carbon](https://github.com/briannesbitt/Carbon) - A simple API extension for DateTime with PHP 5.3+ * [briannesbitt/Carbon](https://github.com/briannesbitt/Carbon) - A simple API extension for DateTime with PHP 5.3+
* [thomaspark/bootswatch](https://github.com/thomaspark/bootswatch) - Themes for Bootstrap * [thomaspark/bootswatch](https://github.com/thomaspark/bootswatch) - Themes for Bootstrap
* [mozilla/pdf.js)](https://github.com/mozilla/pdf.js) - PDF Reader in JavaScript

View File

@ -20,7 +20,7 @@
) )
) )
, array('id'=>'actionDropDown'))->split(); }} , array('id'=>'actionDropDown'))->split(); }}
{{ Button::primary_link(URL::to('invoices/create/' . $client->id), 'Create Invoice') }} {{ Button::primary_link(URL::to('invoices/create/' . $client->public_id), 'Create Invoice') }}
{{ Former::close() }} {{ Former::close() }}
</div> </div>

View File

@ -153,7 +153,7 @@
<!-- <textarea rows="20" cols="120" id="pdfText" onkeyup="runCode()"></textarea> --> <!-- <textarea rows="20" cols="120" id="pdfText" onkeyup="runCode()"></textarea> -->
<!-- <iframe frameborder="1" width="100%" height="600" style="display:block;margin: 0 auto"></iframe> --> <!-- <iframe frameborder="1" width="100%" height="600" style="display:block;margin: 0 auto"></iframe> -->
<!-- <iframe frameborder="1" width="100%" height="500"></iframe> --> <!-- <iframe frameborder="1" width="100%" height="500"></iframe> -->
<canvas id="the-canvas" style="width:100%"></canvas> <canvas id="the-canvas" style="width:100%;border:solid 1px #CCCCCC;"></canvas>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
@ -262,7 +262,7 @@
//enableHoverClick($('.combobox-container input.form-control'), $('.combobox-container input[name=client]'), '{{ URL::to('clients') }}'); //enableHoverClick($('.combobox-container input.form-control'), $('.combobox-container input[name=client]'), '{{ URL::to('clients') }}');
@if ($client) @if ($client)
$('input#invoice_number').focus(); $('#invoice_number').focus();
@else @else
//$('[name="client_combobox"]').focus(); //$('[name="client_combobox"]').focus();
@endif @endif
@ -386,21 +386,6 @@
} }
var BASE64_MARKER = ';base64,';
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
}
return array;
}
function _refreshPDF() { function _refreshPDF() {
var invoice = createInvoiceModel(); var invoice = createInvoiceModel();
var doc = generatePDF(invoice); var doc = generatePDF(invoice);
@ -421,8 +406,7 @@
page.render({canvasContext: context, viewport: viewport}); page.render({canvasContext: context, viewport: viewport});
}); });
}); });
//$('iframe').attr('src', string); //$('iframe').attr('src', string);
} }
@ -430,7 +414,7 @@
function onDownloadClick() { function onDownloadClick() {
var invoice = createInvoiceModel(); var invoice = createInvoiceModel();
var doc = generatePDF(invoice); var doc = generatePDF(invoice);
doc.save('Invoice-' + $('#number').val() + '.pdf'); doc.save('Invoice-' + $('#invoice_number').val() + '.pdf');
} }
function onEmailClick() { function onEmailClick() {
@ -460,13 +444,12 @@
$('select#client').combobox('setSelected'); $('select#client').combobox('setSelected');
$('input[name=client]').val('-1'); $('input[name=client]').val('-1');
$('.client_select input.form-control').val(name); $('.client_select input.form-control').val(name);
$('.client_select').addClass('combobox-selected'); $('.client_select .combobox-container').addClass('combobox-selected');
$('#nameError').css( "display", "none" ); $('#nameError').css( "display", "none" );
$('#modalLink').text('Edit client details'); $('#modalLink').text('Edit client details');
$('#myModal').modal('hide'); $('#myModal').modal('hide');
$('.client_select input.form-control').focus(); $('.client_select input.form-control').focus();
//$('[name="client_combobox"]').focus();
refreshPDF(); refreshPDF();
} }

View File

@ -1,18 +1,29 @@
@extends('header') @extends('header')
@section('head')
@parent
<script type="text/javascript" src="{{ asset('js/pdf_viewer.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/compatibility.js') }}"></script>
@stop
@section('content') @section('content')
@if ($invoice->client->account->isGatewayConfigured()) <div class="pull-right">
{{ Button::primary_link(URL::to('payment/' . $invitation->invitation_key), 'Pay Now', array('class' => 'btn-lg pull-right')) }} {{ Button::normal('Download PDF', array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}
<div class="clearfix"></div><p>&nbsp;</p> @if ($invoice->client->account->isGatewayConfigured())
@endif {{ Button::primary_link(URL::to('payment/' . $invitation->invitation_key), 'Pay Now', array('class' => 'btn-lg pull-right')) }}
@endif
</div>
<div class="clearfix"></div><p>&nbsp;</p>
<!-- <iframe frameborder="1" width="100%" height="650" style="display:block;margin: 0 auto"></iframe> -->
<canvas id="the-canvas" style="width:100%;border:solid 1px #CCCCCC;"></canvas>
<iframe frameborder="1" width="100%" height="650" style="display:block;margin: 0 auto"></iframe>
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
var invoice = {{ $invoice->toJson() }}; window.invoice = {{ $invoice->toJson() }};
@if (file_exists($invoice->client->account->getLogoPath())) @if (file_exists($invoice->client->account->getLogoPath()))
invoice.image = "{{ HTML::image_data($invoice->client->account->getLogoPath()) }}"; invoice.image = "{{ HTML::image_data($invoice->client->account->getLogoPath()) }}";
invoice.imageWidth = {{ $invoice->client->account->getLogoWidth() }}; invoice.imageWidth = {{ $invoice->client->account->getLogoWidth() }};
@ -20,9 +31,32 @@
@endif @endif
var doc = generatePDF(invoice); var doc = generatePDF(invoice);
var string = doc.output('datauristring'); var string = doc.output('datauristring');
$('iframe').attr('src', string); //$('iframe').attr('src', string);
//console.log(string);
var pdfAsArray = convertDataURIToBinary(string);
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('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
page.render({canvasContext: context, viewport: viewport});
});
});
}); });
function onDownloadClick() {
var doc = generatePDF(invoice);
doc.save('Invoice-' + invoice.invoice_number + '.pdf');
}
</script> </script>
@stop @stop

View File

@ -233,6 +233,10 @@
this.lookup(); this.lookup();
} }
} }
this.$element.trigger('change');
this.$target.trigger('change');
this.$source.trigger('change');
} }
, clearElement: function () { , clearElement: function () {

View File

@ -187,7 +187,7 @@ var log = (function() {
// disabled, which is important to devs but not end users. // disabled, which is important to devs but not end users.
function info(msg) { function info(msg) {
if (verbosity >= INFOS) { if (verbosity >= INFOS) {
log('Info: ' + msg); //log('Info: ' + msg);
PDFJS.LogManager.notify('info', msg); PDFJS.LogManager.notify('info', msg);
} }
} }
@ -195,7 +195,7 @@ function info(msg) {
// Non-fatal warnings that should trigger the fallback UI. // Non-fatal warnings that should trigger the fallback UI.
function warn(msg) { function warn(msg) {
if (verbosity >= WARNINGS) { if (verbosity >= WARNINGS) {
log('Warning: ' + msg); //log('Warning: ' + msg);
PDFJS.LogManager.notify('warn', msg); PDFJS.LogManager.notify('warn', msg);
} }
} }
@ -34845,8 +34845,8 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
// Pre compile the pdf page and fetch the fonts/images. // Pre compile the pdf page and fetch the fonts/images.
page.getOperatorList(handler).then(function(operatorList) { page.getOperatorList(handler).then(function(operatorList) {
log('page=%d - getOperatorList: time=%dms, len=%d', pageNum, //log('page=%d - getOperatorList: time=%dms, len=%d', pageNum,
Date.now() - start, operatorList.fnArray.length); // Date.now() - start, operatorList.fnArray.length);
}, function(e) { }, function(e) {

View File

@ -438,4 +438,19 @@ function setComboboxValue($combobox, id, name) {
} else { } else {
$combobox.find('.combobox-container').removeClass('combobox-selected'); $combobox.find('.combobox-container').removeClass('combobox-selected');
} }
}
var BASE64_MARKER = ';base64,';
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
}
return array;
} }