Rev 16768 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpnamespace LeadersLinked\Library;use Fpdf\Fpdf;use Amenadiel\JpGraph\Graph\PieGraph;use Amenadiel\JpGraph\Plot\PiePlot;use Amenadiel\JpGraph\Graph\Graph;use Amenadiel\JpGraph\Plot\LinePlot;use Amenadiel\JpGraph\Plot\BarPlot;use Amenadiel\JpGraph\Themes\UniversalTheme;use Amenadiel\JpGraph\Themes\PastelTheme;use Amenadiel\JpGraph\Themes\SoftyTheme;use Laminas\Mvc\I18n\Translator;class SurveyReport extends FPDF {/**** @var string*/public $header;/**** @var string*/public $footer;/**** @var string*/public $campaignName;/**** @var string*/public $printDate;/**** @var string*/public $formName;/**** @var string*/public $formText;/**** @var Translator*/public $translator;/*** Header PDF*/function Header() {if(empty($this->printDate)) {$this->printDate = date('d/m/Y H:i a');}if ($this->header != '') {$this->Image($this->header, 10, 8, 190);$this->SetY(55);}$s = Functions::utf8_decode($this->printDate . ' ' . $this->translator->translate('LABEL_PAGE') . ' : ' . $this->PageNo());$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);$this->SetFont('Arial', 'B', 10);$this->Cell(180, 8, Functions::utf8_decode($this->campaignName), 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);}}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);}}/*** Footer PDF*/function Footer() {if ($this->footer != '') {$this->SetY(-40);$this->Image($this->footer, 10, $this->getY(), 190);}}/*** Create chart PDF* @param string[] $labels* @param float[] $values* @param string $title* @param string $filename*/function pieChart($labels, $values, $title, $filename) {// Setup the graph.$graph = new PieGraph(600, 240);$graph->SetTheme(new SoftyTheme());//$graph->clearTheme();//$graph->SetShadow();// Create the bar pot$bplot = new PiePlot($values);$bplot->SetLegends($labels);$bplot->SetCenter(0.2);// Setup color for gradient fill style// Set color for the frame of each bar$bplot->SetColor("white");$bplot->SetLabelType(PIE_VALUE_PER);$graph->Add($bplot);$graph->Stroke($filename);}function barChart($labels, $values, $title, $filename){$graph = new Graph(700, count($values) * 100, 'auto');$graph->SetScale('textint');$graph->clearTheme();$graph->SetShadow();$graph->Set90AndMargin(130, 30, 60, 30);$graph->yscale->ticks->SupressZeroLabel(false);// Setup X-axis labels$graph->xaxis->SetTickLabels($labels);$graph->xaxis->SetLabelAngle(40);$bplot = new BarPlot($values);$bplot->SetFillColor('orange');$bplot->SetShadow();$bplot->SetCenter(0.2);$bplot->SetWidth(0.6);$bplot->value->Show();$graph->Add($bplot);$graph->Stroke($filename);}/**function borderTable($title, $content) {// Header Table$this->SetFillColor(204, 204, 204);$this->SetDrawColor(0, 0, 0);$this->SetLineWidth(0);$this->SetFont('Arial', 'B', 9);$this->Cell(190, 6, Functions::utf8_decode($title), 1, 0, 'L', true);$this->Ln();// Body Table$this->SetFillColor(225, 255, 255);$this->SetTextColor(0);foreach ($content as $rs) {if (isset($rs['title'])) {$this->SetFont('Arial', 'B', 9);$this->Cell(50, 10, Functions::utf8_decode($rs['title']), 1, 0, 'L', false);$this->MultiCell(140, 10, Functions::utf8_decode($rs['content']), 1, 'L', false);$this->Ln();} else {$this->SetFont('Arial', '', 9);$this->MultiCell(190, 6, Functions::utf8_decode($rs['content']), 1, 'L', false);}}$this->Ln(5);}*/}