| 1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
require_once('../../config.php');
|
|
|
4 |
require_once($CFG->dirroot.'/course/lib.php');
|
|
|
5 |
require_once($CFG->dirroot . '/blocks/cesa_notes/lib.php');
|
|
|
6 |
require_once('./lib/fpdf/fpdf.php');
|
|
|
7 |
|
|
|
8 |
class PDF extends FPDF
|
|
|
9 |
{
|
|
|
10 |
// Cabecera
|
|
|
11 |
function Header()
|
|
|
12 |
{
|
|
|
13 |
|
|
|
14 |
$this->Image('./pix/header.png',10,8,20);
|
|
|
15 |
$this->SetFont('Arial','B',15);
|
|
|
16 |
$this->Cell(80);
|
|
|
17 |
$this->Cell(30,15,get_string('cesa_notes', 'block_cesa_notes'),0,0,'C');
|
|
|
18 |
|
|
|
19 |
$this->Ln(50);
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
// Pie de página
|
|
|
23 |
function Footer()
|
|
|
24 |
{
|
|
|
25 |
// Posición: a 1,5 cm del final
|
|
|
26 |
$this->SetY(-15);
|
|
|
27 |
$this->Image('./pix/footer.png',10,null,190);
|
|
|
28 |
// Arial italic 8
|
|
|
29 |
$this->SetFont('Arial','I',8);
|
|
|
30 |
// Número de página
|
|
|
31 |
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
|
|
|
32 |
}
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
$manager = new block_cesa_notes_manager();
|
|
|
36 |
$notes = $manager->get_notes_to_print();
|
|
|
37 |
|
|
|
38 |
$pdf = new PDF();
|
|
|
39 |
$pdf->AliasNbPages();
|
|
|
40 |
$pdf->AddPage();
|
|
|
41 |
$pdf->SetFont('Times','',12);
|
|
|
42 |
foreach($notes as $note) {
|
|
|
43 |
|
|
|
44 |
$pdf->SetFont('Arial');
|
|
|
45 |
$pdf->SetFontSize(10);
|
|
|
46 |
$pdf->SetTextColor(255,2555,255);
|
|
|
47 |
$pdf->SetFillColor(58, 174, 219);
|
|
|
48 |
if ($note->courseid != 1) {
|
|
|
49 |
$pdf->Cell(0,6, utf8_decode($note->coursename . ' - ' . $note->modulename),'LTR',1,'L',1);
|
|
|
50 |
$pdf->Cell(0,6, $note->timecreated,'LRB',1,'L',1);
|
|
|
51 |
} else {
|
|
|
52 |
$pdf->Cell(0,6, $note->timecreated,1,1,'L',1);
|
|
|
53 |
}
|
|
|
54 |
$pdf->SetTextColor(38,38,38);
|
|
|
55 |
$pdf->SetFontSize(16);
|
|
|
56 |
$pdf->MultiCell(0, 10, utf8_decode($note->content), 1);
|
|
|
57 |
$pdf->Ln(10);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
$pdf->Output();
|
|
|
61 |
|