コード例 #1
0
    $dateR = mysqli_query($dbc, $dateQ);
    $date = mysqli_fetch_array($dateR, MYSQLI_NUM);
    $where = "timestamp > '{$date['0']}'";
    $query = "SELECT ID, DATE_FORMAT(billdate, '%M %D'), amount, description, firstname\n        FROM bills INNER JOIN payers\n            ON (bills.payerid = payers.payerid)\n        WHERE {$where}";
    $header = " {$date['1']} to " . date('F jS');
}
$payersQ = "SELECT firstname FROM payers WHERE active=1";
$payersR = mysqli_query($dbc, $payersQ);
while ($row = mysqli_fetch_array($payersR)) {
    $payer[$row[0]] = 0.0;
}
$billQ = "SELECT ifnull(sum(amount),0) AS total, firstname\n    FROM bills INNER JOIN payers\n        ON (bills.payerid = payers.payerid)\n    WHERE {$where}\n    GROUP BY firstname\n    ORDER BY firstname ASC";
$billR = mysqli_query($dbc, $billQ);
$pdf = new fpdf('P', 'mm', 'Letter');
$pdf->setFont('Times', 'B', 20);
$pdf->addPage();
$pdf->setY(20);
$pdf->cell(0, 12, 'Bills from ' . $header, 0, 1, 'C');
$pdf->setY(40);
$total = 0.0;
while ($row = mysqli_fetch_array($billR, MYSQLI_NUM)) {
    $payer[$row[1]] = $row[0];
    $total += $row[0];
}
$num = mysqli_num_rows($payersR);
$avg = $total / $num;
$pdf->setFont('Times', 'B', 16);
// 216 mm total, 203 writable
$pdf->setX(7.5);
$pdf->cell(75, 10, 'Name', 1, 0, 'C');
$pdf->cell(42, 10, 'Amount Paid', 1, 0, 'C');
コード例 #2
0
ファイル: test_composer.php プロジェクト: Ophois/webforce3
<?php
include_once 'vendor/setasign/fpdf/fpdf.php';

$pdf = new fpdf(); // nouveau document PDF
$pdf->addPage(); //ajout d'une page blanche
$pdf->setFont('Arial', '', 12); //police arial 12
$pdf->Cell(190,10,'Hello World!',0,1,'C');
$pdf->setTextColor(255,0,0); //couleur rouge
$pdf->Cell(190,10,'Copyright WF3',0,1,'C');
$pdf->Output(); // envoi au navigateur
?>