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->WriteHTML($proposal->present()->htmlDocument);
$mpdf->Output();
$mpdf->Output($proposal->present()->filename, 'D');
}
}

View File

@ -34,7 +34,21 @@ class ProposalPresenter extends EntityPresenter
{
$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()

View File

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

View File

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

View File

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