Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/contracts/
Upload File :
Current File : /var/www/cesa.co.za/contracts/creategrid.php

<?php
include("../php/inc_db.php");
include("inc_config.php");
require_once('fpdf184/fpdf.php');
require_once('FPDI-2.3.6/src/autoload.php');

$pdf = new setasign\Fpdi\Fpdi('P','mm','A4'); 

$sql="SELECT ContractTypes.PDFTemplate FROM ContractTypes WHERE ContractTypeID=".intval($_GET["id"]);
$rec=mysql_query($sql);
if ($row=mysql_fetch_assoc($rec)) {
	$pagecount = $pdf->setSourceFile(CONTRACTS_DIR.$row["PDFTemplate"]); 
    $i=intval($_GET["page"]);
		$tplidx = $pdf->importPage($i, '/MediaBox'); 
		$pdf->AddPage(); 
		$pdf->SetMargins(255,255,255);
		$pdf->useTemplate($tplidx, 0, 0, 215); 
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('Arial','',8);
        for ($y=10; $y<=270; $y+=10) {
            $pdf->SetXY(10,$y);
            $pdf->Cell(0,0,$y);
            for ($x=20; $x<=210; $x+=10) {

                $pdf->SetXY($x,$y);
                $pdf->Cell(0,0,"+");
            }
        }
		$sql="SELECT ContractFields.* FROM ContractFields
		WHERE ContractFields.ContractTypeID=".intval($_GET["id"])."
		AND ContractFields.PageNum=".$i;
		$recD=mysql_query($sql);
		while ($rowD=mysql_fetch_assoc($recD)) {
			$pdf->SetFont('Arial','',$rowD["FontSize"]);
			$pdf->SetXY($rowD["PosX"],$rowD["PosY"]);
			$pdf->MultiCell($rowD["CellWidth"], 5,str_replace("\r\n","\n",$rowD["DataField"])); 
		}

		
	$pdf->Output(CONTRACTS_DIR.'grid_'.$_GET["id"].'.pdf', 'F'); 

	header("Content-type: application/pdf");
	readfile(CONTRACTS_DIR.'grid_'.$_GET["id"].'.pdf');
}
?>