invoiceninja/app/Ninja/Presenters/ProposalPresenter.php

61 lines
1.5 KiB
PHP
Raw Normal View History

2018-02-08 13:41:22 +02:00
<?php
namespace App\Ninja\Presenters;
use Utils;
2018-02-11 11:14:47 +02:00
use DropdownButton;
2018-02-08 13:41:22 +02:00
/**
* Class ProposalPresenter.
*/
class ProposalPresenter extends EntityPresenter
{
2018-02-11 11:14:47 +02:00
public function moreActions()
{
$proposal = $this->entity;
$invitation = $proposal->invitations->first();
$actions = [];
2018-03-26 22:31:45 +03:00
$actions[] = ['url' => $invitation->getLink('proposal'), 'label' => trans("texts.view_in_portal")];
2018-02-11 11:14:47 +02:00
$actions[] = DropdownButton::DIVIDER;
if (! $proposal->trashed()) {
$actions[] = ['url' => 'javascript:onArchiveClick()', 'label' => trans("texts.archive_proposal")];
}
if (! $proposal->is_deleted) {
$actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans("texts.delete_proposal")];
}
return $actions;
}
2018-02-08 13:41:22 +02:00
2018-02-11 16:00:03 +02:00
public function htmlDocument()
{
$proposal = $this->entity;
2018-02-11 20:03:48 +02:00
$html = "<html>
<head>
<style>
@page {
margin: 0px;
}
{$proposal->css}
</style>
</head>
<body>
{$proposal->html}
</body>
</html>";
return $html;
2018-02-11 16:00:03 +02:00
}
public function filename()
{
$proposal = $this->entity;
return sprintf('%s_%s.pdf', trans('texts.proposal'), $proposal->invoice->invoice_number);
}
2018-02-08 13:41:22 +02:00
}