This commit is contained in:
aynsix
2022-01-26 16:27:03 +03:00
parent f9aaec1e49
commit 308c2dd896
3 changed files with 41 additions and 11 deletions

View File

@@ -33,6 +33,8 @@ class PDFRecords extends PDF
$this->pdfTitle = $pdfTitle; $this->pdfTitle = $pdfTitle;
$this->pdfDescription = $pdfDescription; $this->pdfDescription = $pdfDescription;
$this->pdf->setPrintOwnerUser($app->getAuthenticatedUser());
$records = $printer->get_elements(); $records = $printer->get_elements();
$list = []; $list = [];
@@ -507,7 +509,7 @@ class PDFRecords extends PDF
$this->pdf->Cell(95, $h, $RIGHT_TEXT, "TBR", 1, "R", 1); $this->pdf->Cell(95, $h, $RIGHT_TEXT, "TBR", 1, "R", 1);
$this->pdf->SetY($y); $this->pdf->SetY($y);
$this->pdf->write(7, "record " . $rec->getNumber(), '', false, 'C'); $this->pdf->write(7, $rec->getNumber(), '', false, 'C');
$this->pdf->SetY($y2); $this->pdf->SetY($y2);
if($basket) { if($basket) {

View File

@@ -11,10 +11,15 @@
namespace Alchemy\Phrasea\Out\Tool; namespace Alchemy\Phrasea\Out\Tool;
use Alchemy\Phrasea\Model\Entities\User;
class PhraseaPDF extends \TCPDF class PhraseaPDF extends \TCPDF
{ {
const FONT = 'freesans'; const FONT = 'freesans';
/** @var User */
private $printOwnerUser;
public function Header() public function Header()
{ {
@@ -22,6 +27,13 @@ class PhraseaPDF extends \TCPDF
public function Footer() public function Footer()
{ {
$owner = ' Phraseanet';
$unNeededTextLength = '';
if (!empty($this->printOwnerUser)) {
$owner = sprintf('Printed with Phraseanet by <a href="mailto:%s">%s</a> on %s', $this->printOwnerUser->getEmail(), $this->printOwnerUser->getDisplayName(), (new \DateTime())->format("Y/m/d"));
$unNeededTextLength = sprintf('<a href="%s"></a>', $this->printOwnerUser->getEmail());
}
$this->SetLeftMargin(0); $this->SetLeftMargin(0);
$mr = $this->SetRightMargin(0); $mr = $this->SetRightMargin(0);
@@ -30,18 +42,33 @@ class PhraseaPDF extends \TCPDF
$this->SetFont(self::FONT, 'I', 8); $this->SetFont(self::FONT, 'I', 8);
$this->Cell(0, 10, 'Page ' . $this->PageNo(), 0, 0, 'C'); $this->Cell(0, 10, 'Page ' . $this->PageNo(), 0, 0, 'C');
$this->SetFont(self::FONT, '', 8); if (empty($this->printOwnerUser)) {
$w = $this->GetStringWidth('Printed by'); $this->SetFont(self::FONT, '', 8);
$w = $this->GetStringWidth('Printed by');
$this->SetFont(self::FONT, 'B', 8); $this->SetFont(self::FONT, 'B', 8);
$w += $this->GetStringWidth(' Phraseanet'); $w += $this->GetStringWidth($owner);
$this->SetXY(-$w - $mr - 5, -15); $this->SetXY(-$w - $mr - 5, -15);
$this->SetFont(self::FONT, '', 8); $this->SetFont(self::FONT, '', 8);
$this->Write(8, 'Printed by'); $this->Write(8, 'Printed by');
$this->SetFont(self::FONT, 'B', 8); $this->SetFont(self::FONT, 'B', 8);
$this->Write(8, ' Phraseanet'); $this->Write(8, ' Phraseanet');
} else {
$this->SetFont(self::FONT, '', 8);
$w = $this->GetStringWidth($owner) - $this->GetStringWidth($unNeededTextLength);
$this->SetXY(-$w - $mr -5, -15);
$this->SetFont(self::FONT, '', 8);
$this->writeHTMLCell($w,8, '', '', $owner);
}
}
public function setPrintOwnerUser($user)
{
$this->printOwnerUser = $user;
} }
} }

View File

@@ -4,7 +4,7 @@
<div style="padding:10px;"> <div style="padding:10px;">
<div style="margin: 20px 5px;"> <div style="margin: 20px 5px;">
<h4 style="margin-left: 0px;">{{ 'print:: pdf title' | trans }}</h4> <h4 style="margin-left: 0px;">{{ 'print:: pdf title' | trans }}</h4>
<input type="text" value="" name="print-pdf-title" class="print-pdf-title" style="margin-left: 0px"/> <input type="text" value="" name="print-pdf-title" class="print-pdf-title" style="margin-left: 0px;width: 530px;padding-left: 0px;padding-right: 0px;margin-right: 0px;"/>
</div> </div>
<div style="margin: 20px 5px;"> <div style="margin: 20px 5px;">
<h4 style="margin-left: 0px;">{{ 'print:: pdf description' | trans }}</h4> <h4 style="margin-left: 0px;">{{ 'print:: pdf description' | trans }}</h4>
@@ -27,6 +27,7 @@
{% endif %} {% endif %}
{% if printer.get_count_actionable() > 0 %} {% if printer.get_count_actionable() > 0 %}
<h3>{{ 'print:: choose model' | trans }}</h3>
{% if printer.get_count_preview() > 0 %} {% if printer.get_count_preview() > 0 %}
<h4>{{ 'phraseanet:: preview' | trans }}</h4> <h4>{{ 'phraseanet:: preview' | trans }}</h4>
<div style="margin: 10px 0 20px 0; padding: 0 10px;"> <div style="margin: 10px 0 20px 0; padding: 0 10px;">