Proposals

This commit is contained in:
Hillel Coren 2018-02-11 20:03:48 +02:00
parent cb9c418333
commit 4229b8ad57
5 changed files with 25 additions and 10 deletions

View File

@ -142,6 +142,8 @@ class ProposalController extends BaseController
$mpdf = new mPDF(); $mpdf = new mPDF();
$mpdf->WriteHTML($proposal->present()->htmlDocument); $mpdf->WriteHTML($proposal->present()->htmlDocument);
$mpdf->Output();
$mpdf->Output($proposal->present()->filename, 'D'); $mpdf->Output($proposal->present()->filename, 'D');
} }
} }

View File

@ -34,7 +34,21 @@ class ProposalPresenter extends EntityPresenter
{ {
$proposal = $this->entity; $proposal = $this->entity;
return "<html><head><style>{$proposal->css}</style><head><body>{$proposal->html}</body></html>"; $html = "<html>
<head>
<style>
@page {
margin: 0px;
}
{$proposal->css}
</style>
</head>
<body>
{$proposal->html}
</body>
</html>";
return $html;
} }
public function filename() public function filename()

View File

@ -26,10 +26,7 @@
} }
$(function() { $(function() {
var html = {!! json_encode($proposal->html) !!}; var content = {!! json_encode($proposal->present()->htmlDocument) !!};
var css = {!! json_encode($proposal->css) !!};
var content = '<html><head><style>' + css + '</style></head><body>' + html + '</body></html>';
var iFrame = document.getElementById('proposalIframe').contentWindow.document; var iFrame = document.getElementById('proposalIframe').contentWindow.document;
iFrame.write(content); iFrame.write(content);

View File

@ -525,7 +525,7 @@
@endif @endif
@if ( $invoice->id && ! $invoice->is_recurring) @if ( $invoice->id && ! $invoice->is_recurring)
{!! Button::primary(trans('texts.download_pdf')) {!! Button::primary(trans('texts.download'))
->withAttributes(['onclick' => 'onDownloadClick()', 'id' => 'downloadPdfButton']) ->withAttributes(['onclick' => 'onDownloadClick()', 'id' => 'downloadPdfButton'])
->appendIcon(Icon::create('download-alt')) !!} ->appendIcon(Icon::create('download-alt')) !!}
@endif @endif

View File

@ -57,7 +57,7 @@
->appendIcon(Icon::create('remove-circle')) ->appendIcon(Icon::create('remove-circle'))
->asLinkTo(HTMLUtils::previousUrl('/proposals')) !!} ->asLinkTo(HTMLUtils::previousUrl('/proposals')) !!}
{!! Button::primary(trans('texts.download_pdf')) {!! Button::primary(trans('texts.download'))
->withAttributes(['onclick' => 'onDownloadClick()']) ->withAttributes(['onclick' => 'onDownloadClick()'])
->appendIcon(Icon::create('download-alt')) !!} ->appendIcon(Icon::create('download-alt')) !!}
@ -90,9 +90,11 @@
return true; return true;
} }
function onDownloadClick() { @if ($proposal)
location.href = "{{ url("/proposals/{$proposal->public_id}/download") }}"; function onDownloadClick() {
} location.href = "{{ url("/proposals/{$proposal->public_id}/download") }}";
}
@endif
function loadTemplate() { function loadTemplate() {
var templateId = $('select#proposal_template_id').val(); var templateId = $('select#proposal_template_id').val();