Codice PHP:
<?php
include("connessione.php");
$password=$_GET['codice_meccanografico'];
$data = $_GET['data'];
$query=mysqli_query($conn, "SELECT * FROM scuola WHERE codice_meccanografico = '$password'");
$row=mysqli_fetch_array($query);
$name=$row['nome'];
global $column_headers;
require './pdf/classes/fpdf181/fpdf.php';
class Documento extends FPDF {
function Header() {
global $column_headers, $pagetitle;
$this->Image('img/logo.png',10,6,30);
$pagetitle = utf8_decode($pagetitle);
$this->setX(10);
$this->setY(25);
$this->SetFont('Arial','B',10);
$this->setX(10);
$this->setY(30);
$this->SetFont('Arial','B',10);
$this->setXY(5,2);
$this->Cell(200,12,$this->title,0,0,'C');
$this->SetFont('Arial','',8);
$this->setXY(5,2);
$this->Cell(200,12,$this->title1,0,0,'C');
$this->setXY(5,2);
$this->Cell(200,12,$this->title2,0,0,'C');
$this->setXY(10,3);
$this->setXY(100, 15);
$this->SetFont('Arial','B',15);
$this->Cell(0,0,$pagetitle);
$this->SetFont('Arial','B',10);
$this->Line(5,30,280,30);
$this->setY(34);
foreach ($column_headers as $pos => $testo) {
$this->setX($pos);
$this->Cell(0,0,$testo);
}
$this->Line(5,40,280,40);
$this->setXY(11, 46);
}
function Footer() {
$this->setXY(11, -10);
$username = $name;
$f = date("d/m/Y")." - ".date("H:i")." Utente - $username";
$this->Cell(0,0,$f);
}
function setColumnHeaders($ch) {
global $column_headers;
$column_headers = $ch;
}
}
// Tabella famiglie articoli - PDF
$query4 = mysqli_query($conn, "SELECT * FROM supplenze JOIN scuola ON supplenze.id_scuola = scuola.id_scuola WHERE scuola.codice_meccanografico = '$password' AND pubblico='1' AND data='$data'");
while($cicle=mysqli_fetch_array($query4)){
$sql="SELECT * FROM supplenze,docenti WHERE doc_ass=id AND doc_ass=$cicle[doc_ass]";
$query2 = mysqli_query($conn, $sql);
$row1 = mysqli_fetch_array($query2, MYSQLI_ASSOC);
$sql1="SELECT * FROM classi,docenti WHERE classi.id=$cicle[classe] AND docenti.id=$cicle[doc_sos]";
$query3 = mysqli_query($conn, $sql1);
$row2 = mysqli_fetch_array($query3, MYSQLI_ASSOC);
$doc_ass = $row1['docente'];
$data = $cicle['data'];
$ora = $cicle['ora'];
$classe = $row2['classe'];
$materia = $cicle['materia'];
$doc_sos = $row2['docente'];
$pagetitle = "Tabella Supplenze Giornaliere";
$nomefile = "supplenze giornaliere.pdf";
$column_headers = array(
10 => 'Docente assente',
100 => 'Data',
130 => 'Ora',
150 => 'Classe',
170 => 'Materia',
200 => 'Docente sostituto',
);
$pdf = new Documento();
$pdf->AliasNbPages();
$pdf->AddPage('L');
$pdf->SetFont('Arial','',10);
$pdf->setColumnHeaders($column_headers);
$pdf->setFillColor(240,30,20);
$pdf->setXY(10, $pdf->getY());
$pdf->setXY(10, $pdf->getY());
$pdf->Cell(30,5,$doc_ass,0,0,'L');
$pdf->setX(100);
$pdf->Cell(10,5,$cicle['data'],0,0,'L');
$pdf->setX(130);
$pdf->Cell(10,5,$cicle['ora'],0,0,'L');
$pdf->setX(150);
$pdf->Cell(10,5,$classe,0,0,'L');
$pdf->setX(170);
$pdf->Cell(10,5,$cicle['materia'],0,0,'L');
$pdf->setX(200);
$pdf->Cell(10,5,$doc_sos,0,0,'L');
$pdf->setXY(11, $pdf->getY()+6);
$pdf->Output('supplenze giornaliere.pdf','I');
}
?>