1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Proposals

This commit is contained in:
Hillel Coren 2018-02-11 16:00:03 +02:00
parent db6cc52faa
commit a136c3c325
4 changed files with 31 additions and 1 deletions

View File

@ -81,6 +81,19 @@ class ClientPortalController extends BaseController
return view('invited.proposal', $data); return view('invited.proposal', $data);
} }
public function downloadProposal($invitationKey)
{
if (! $invitation = $this->propoosalRepo->findInvitationByKey($invitationKey)) {
return $this->returnError(trans('texts.proposal_not_found'));
}
$proposal = $invitation->proposal;
$mpdf = new \mPDF();
$mpdf->WriteHTML($proposal->present()->htmlDocument);
$mpdf->Output($proposal->present()->filename, 'D');
}
public function viewInvoice($invitationKey) public function viewInvoice($invitationKey)
{ {
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) { if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {

View File

@ -15,6 +15,7 @@ use Auth;
use Input; use Input;
use Session; use Session;
use View; use View;
use mPDF;
class ProposalController extends BaseController class ProposalController extends BaseController
{ {
@ -139,6 +140,8 @@ class ProposalController extends BaseController
{ {
$proposal = $request->entity(); $proposal = $request->entity();
$mpdf = new mPDF();
$mpdf->WriteHTML($proposal->present()->htmlDocument);
$mpdf->Output($proposal->present()->filename, 'D');
} }
} }

View File

@ -30,4 +30,17 @@ class ProposalPresenter extends EntityPresenter
return $actions; return $actions;
} }
public function htmlDocument()
{
$proposal = $this->entity;
return "<html><head><style>{$proposal->css}</style><head><body>{$proposal->html}</body></html>";
}
public function filename()
{
$proposal = $this->entity;
return sprintf('%s_%s.pdf', trans('texts.proposal'), $proposal->invoice->invoice_number);
}
} }

View File

@ -16,6 +16,7 @@ Route::post('/get_started', 'AccountController@getStarted');
// Client visible pages // Client visible pages
Route::group(['middleware' => ['lookup:contact', 'auth:client']], function () { Route::group(['middleware' => ['lookup:contact', 'auth:client']], function () {
Route::get('view/{invitation_key}', 'ClientPortalController@viewInvoice'); Route::get('view/{invitation_key}', 'ClientPortalController@viewInvoice');
Route::get('proposal/{proposal_invitation_key}/download', 'ClientPortalController@downloadProposal');
Route::get('proposal/{proposal_invitation_key}', 'ClientPortalController@viewProposal'); Route::get('proposal/{proposal_invitation_key}', 'ClientPortalController@viewProposal');
Route::get('download/{invitation_key}', 'ClientPortalController@download'); Route::get('download/{invitation_key}', 'ClientPortalController@download');
Route::put('sign/{invitation_key}', 'ClientPortalController@sign'); Route::put('sign/{invitation_key}', 'ClientPortalController@sign');