| 523 | geraldo | 1 | <?php
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | namespace LeadersLinked\Library;
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 | use Fpdf\Fpdf;
 | 
        
           |  |  | 6 | use Amenadiel\JpGraph\Graph;
 | 
        
           |  |  | 7 | use Amenadiel\JpGraph\Plot;
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 | class SelfEvaluationPDF extends FPDF {
 | 
        
           |  |  | 10 |   | 
        
           |  |  | 11 |     /**
 | 
        
           |  |  | 12 |      * Header PDF
 | 
        
           |  |  | 13 |      */
 | 
        
           |  |  | 14 |     function Header() {
 | 
        
           |  |  | 15 |         $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/header_background.png', 10, 8, 190);
 | 
        
           |  |  | 16 |         $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/header_logo.png', 130, 20, 60);
 | 
        
           |  |  | 17 |     }
 | 
        
           |  |  | 18 |     /**
 | 
        
           |  |  | 19 |      * Header custom PDF
 | 
        
           |  |  | 20 |      * @param type $headerFormName
 | 
        
           |  |  | 21 |      * @param type $headerUsername
 | 
        
           |  |  | 22 |      */
 | 
        
           |  |  | 23 |     function customHeader($headerFormName, $headerUsername) {
 | 
        
           |  |  | 24 |         $s = utf8_decode(' Página: ' . $this->PageNo());
 | 
        
           |  |  | 25 |         $this->SetFont('Arial', '', 10);
 | 
        
           |  |  | 26 |         $this->SetY(40);
 | 
        
           |  |  | 27 |         $this->Cell(190, 10, $s, 0, 0, 'R');
 | 
        
           |  |  | 28 |   | 
        
           |  |  | 29 |         // Arial bold 15
 | 
        
           |  |  | 30 |         $this->SetFont('Arial', 'B', 15);
 | 
        
           |  |  | 31 |         $this->SetY(50);
 | 
        
           |  |  | 32 |         $this->Cell(180, 10, $headerFormName, 0, 0, 'C');
 | 
        
           |  |  | 33 |         $this->setY($this->getY() + 8);
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 |         $this->SetFont('Arial', '', 10);
 | 
        
           |  |  | 37 |         $this->Cell(180, 10, $headerUsername, 0, 0, 'C');
 | 
        
           |  |  | 38 |         $this->setY($this->getY() + 10);
 | 
        
           |  |  | 39 |     }
 | 
        
           |  |  | 40 |     /**
 | 
        
           |  |  | 41 |      * Footer PDF
 | 
        
           |  |  | 42 |      */
 | 
        
           |  |  | 43 |     function Footer() {
 | 
        
           |  |  | 44 |         $this->SetY(-30);
 | 
        
           |  |  | 45 |         $this->Image($_SERVER['DOCUMENT_ROOT'] . '/pdf/footer_background.jpg', 10, $this->getY(), 190);
 | 
        
           |  |  | 46 |     }
 | 
        
           |  |  | 47 |     /**
 | 
        
           |  |  | 48 |      * Create chart PDF
 | 
        
           |  |  | 49 |      * @param type $labels
 | 
        
           |  |  | 50 |      * @param type $values
 | 
        
           |  |  | 51 |      * @param type $title
 | 
        
           |  |  | 52 |      * @param type $filename
 | 
        
           |  |  | 53 |      */
 | 
        
           |  |  | 54 |     function PieChart($labels, $values, $title, $filename) {
 | 
        
           |  |  | 55 |         // We need some data
 | 
        
           |  |  | 56 |         $datay = $values;
 | 
        
           |  |  | 57 |         $datax = $labels;
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 |         // Setup the graph.
 | 
        
           |  |  | 60 |         $graph = new Graph\PieGraph(400, 240);
 | 
        
           |  |  | 61 |         $graph->clearTheme();
 | 
        
           |  |  | 62 |         $graph->img->SetMargin(60, 20, 35, 75);
 | 
        
           |  |  | 63 |         $graph->SetScale("textlin");
 | 
        
           |  |  | 64 |         $graph->SetShadow();
 | 
        
           |  |  | 65 |   | 
        
           |  |  | 66 |         // Set up the title for the graph
 | 
        
           |  |  | 67 |         $graph->title->Set($title);
 | 
        
           |  |  | 68 |         $graph->title->SetMargin(8);
 | 
        
           |  |  | 69 |         $graph->title->SetColor("darkred");
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |         // Show 0 label on Y-axis (default is not to show)
 | 
        
           |  |  | 72 |         $graph->yscale->ticks->SupressZeroLabel(false);
 | 
        
           |  |  | 73 |   | 
        
           |  |  | 74 |         // Setup X-axis labels
 | 
        
           |  |  | 75 |         $graph->xaxis->SetTickLabels($datax);
 | 
        
           |  |  | 76 |         $graph->xaxis->SetLabelAngle(50);
 | 
        
           |  |  | 77 |   | 
        
           |  |  | 78 |         // Create the bar pot
 | 
        
           |  |  | 79 |         $bplot = new Plot\PiePlot($datay);
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 |         // Setup color for gradient fill style
 | 
        
           |  |  | 82 |         // Set color for the frame of each bar
 | 
        
           |  |  | 83 |         $bplot->SetColor("white");
 | 
        
           |  |  | 84 |         $graph->Add($bplot);
 | 
        
           |  |  | 85 |   | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 |         $graph->Stroke($filename);
 | 
        
           |  |  | 88 |     }
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 | }
 |