Rev 16768 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
namespace LeadersLinked\Library;
use Fpdf\Fpdf;
use Laminas\Mvc\I18n\Translator;
class UniqueSurveyReport extends FPDF
{
/**
*
* @var string
*/
public $header;
/**
*
* @var string
*/
public $footer;
/**
*
* @var string
*/
public $formName;
/**
*
* @var string
*/
public $formText;
/**
*
* @var string
*/
public $userName;
/**
*
* @var string
*/
public $formDate;
/**
*
* @var Translator
*/
public $translator;
/**
* Header PDF
*/
function Header()
{
if ($this->header != '') {
$this->Image($this->header, 10, 8, 190);
$this->SetY(55);
}
$s = $this->translator->translate('LABEL_DATE') . ' : ' . $this->formDate . ' '. $this->translator->translate('LABEL_PAGE') . ' : ' . $this->PageNo();
$s = Functions::utf8_decode( $s );
$this->SetFont('Arial', '', 10);
$this->SetY(12);
$this->Cell(190, 10, $s, 0, 0, 'R');
$this->SetFont('Arial', 'B', 10);
$this->SetY(20);
$this->SetX(45);
if($this->userName) {
$this->SetFont('Arial', 'B', 10);
$this->Cell(180, 8, Functions::utf8_decode($this->userName), 0, 0, 'L');
$this->setY($this->getY() + 6);
}
$this->SetFont('Arial', 'B', 10);
//$this->SetY(20);
$this->SetX(45);
$this->Cell(155, 8, $this->formName, 0, 0, 'L');
$this->SetY($this->getY() + 6);
$this->SetFont('Arial', '', 10);
// $this->SetY(30);
$this->SetX(45);
$lines = explode('|-|', wordwrap(Functions::utf8_decode($this->formText), 95, '|-|', true) );
foreach($lines as $line)
{
$this->SetX(45);
$this->Cell(155, 8, $line, 0, 0, 'L');
$this->SetY($this->getY() + 6);
}
if($this->GetY() < 50) {
$this->SetY(50);
}
}
/**
* Footer PDF
*/
function Footer() {
if ($this->footer != '') {
$this->SetY(-40);
$this->Image($this->footer, 10, $this->getY(), 190);
}
}
function addSection($name, $text)
{
$this->SetFont('Arial', 'B', 10);
$this->setX(10);
$this->Cell(190, 8, Functions::utf8_decode($name), 0, 0, 'C');
$this->setY($this->getY() + 6);
$s = Functions::utf8_decode($text);
$lines = explode('|-|', wordwrap( $s, 115, '|-|', true) );
foreach($lines as $line)
{
$this->setX(10);
$this->SetFont('Arial', '', 10);
$this->Cell(155, 8, $line, 0, 0, 'L');
$this->setY($this->getY() + 6);
}
}
function questionAndAnswer($text, $value)
{
if($this->GetY() > 250) {
$this->AddPage();
}
$s = Functions::utf8_decode($text);
$lines = explode('|-|', wordwrap( $s, 105, '|-|', true) );
$first = true;
foreach($lines as $line)
{
if($first) {
$this->SetFont('Arial', 'B', 10);
$this->setX(10);
$this->Cell(40, 8, $this->translator->translate('LABEL_QUESTION') . ' : ', 0, 0, 'L');
$first = false;
if($this->GetY() > 250) {
$this->AddPage();
}
}
$this->setX(32);
$this->SetFont('Arial', '', 10);
$this->Cell(168, 8, $line, 0, 0, 'L');
$this->setY($this->getY() + 6);
}
$lines = explode('|-|', wordwrap( strval($value), 105, '|-|', true) );
$first = true;
foreach($lines as $line)
{
if($first) {
$this->SetFont('Arial', 'B', 10);
$this->setX(10);
$this->Cell(40, 8, $this->translator->translate('LABEL_ANSWER') . ' : ', 0, 0, 'L');
$first = false;
}
if($this->GetY() > 250) {
$this->AddPage();
}
$this->setX(32);
$this->SetFont('Arial', '', 10);
$this->Cell(168, 8, $line, 0, 0, 'L');
$this->setY($this->getY() + 6);
}
}
function questionAndAnswers($text, $values)
{
if($this->GetY() > 250) {
$this->AddPage();
}
$s = Functions::utf8_decode($text);
$lines = explode('|-|', wordwrap( $s, 105, '|-|', true) );
$first = true;
foreach($lines as $line)
{
if($first) {
$this->SetFont('Arial', 'B', 10);
$this->setX(10);
$this->Cell(40, 8, $this->translator->translate('LABEL_QUESTION') . ' : ', 0, 0, 'L');
$first = false;
}
if($this->GetY() > 250) {
$this->AddPage();
}
$this->setX(32);
$this->SetFont('Arial', '', 10);
$this->Cell(168, 8, $line, 0, 0, 'L');
$this->setY($this->getY() + 6);
}
$first = true;
foreach($values as $value)
{
$lines = explode('|-|', wordwrap( strval($value), 105, '|-|', true) );
foreach($lines as $line)
{
if($first) {
$this->SetFont('Arial', 'B', 10);
$this->setX(10);
$this->Cell(40, 8, $this->translator->translate('LABEL_ANSWER') . ' : ', 0, 0, 'L');
$first = false;
}
$this->setX(32);
$this->SetFont('Arial', '', 10);
$this->Cell(168, 8, $line, 0, 0, 'L');
$this->setY($this->getY() + 6);
}
}
}
}