<?php
#cert_pdf.php for ya 18ap07
#text view for bidp 7ja15
#mysql_real_escape_string()

#echo '<p>';
#print_r($_SERVER);
#print_r($_POST);
#echo '<p>';

#@_OUTLINE_PART_1_
#constants
$key1="bidp";
#$key2='ya1';
#$data_base="$key1";
#$table1='ya.a2proj';
#$table2='ya.a1file';
#$table3='ya.a1adds';
$include="all.php"; #change to test.php for easyphp
$connect="pear_connect"; #change to bidp_connect for easyphp
$filesubdir="/php/$key1/";
$thisfile=$_SERVER[PHP_SELF];
if ($_SERVER[SERVER_ADDR]!=$_SERVER[SERVER_NAME])
	{$findserver=$_SERVER[SERVER_NAME]. ':' .$_SERVER[SERVER_PORT];}
else
	{$findserver=$_SERVER[SERVER_ADDR]. ':' .$_SERVER[SERVER_PORT];}
if ($_SERVER[HTTPS]=='on')
	{$thisserver = 'https://' .$findserver;}
else
	{$thisserver = 'http://' .$findserver;}
#echo '<p>here ' .$thisserver; #ok
#$homefile="http://192.168.20.12/";
$homefile='';
#$thisfile='siteboard.php';
$headwords=strtoupper($key1)." site notice board text: ";
#import from userin or posted data
if ($_POST['start']=='')
	{$start=1;}
else
	{$start=$_POST['start'];}
#echo '<p>start==' .$start; #ok 8ja15
$boardsize=$_POST['boardsize'];
#$today=date("Y-m-d");
#$update='Updated '. date('jS F Y', filemtime($thisfile));
#constants

include $include;
require 'DB.php';
include 'fpdf.php';
include 'allhere.php';


#define start tag
#if start=1 this is first cycle (enter basic references); if start=2 second (work in main form), if 3 third (save new project data), if 4 fourth (view/print pdf)
if ($_POST["start"]==2) #in second pass, check data entered in first pass
{
	if ($_POST["jobref"]>'') #existing reference
	{
		$jobref=$_POST["jobref"];
		echo '<p>jobref=' .$jobref;
		$start=2;
		$year=$_POST['year'];
		$mon=$_POST['month'];
		if (strlen($mon)<2)
			{$month= '0'. $mon;}
		else
			{$month=$mon;}
		$dy=$_POST['day'];
		if (strlen($dy)<2)
			{$day= '0'. $dy;}
		else
			{$day=$dy;}
	}
}

if ($_POST["start"]==5)
	{$start=5;}

if ($_POST["start"]==7 || $_GET['start']==7) #set up data for fourth pass (pdf)
{
#if ($_POST['output']=='ispdf')
#{
	$start=7; #display & print pdf
}
#import from userin or posted data


#$link=$connect ()
#		or die ("Cannot link to server");
#$link->setFetchMode(DB_FETCHMODE_ASSOC);


#------------------------------------------
#solicit reference, certificate date and certificate number
if ($start==1)
{
	$title = "<font color=\"red\">$headwords</font> create wording";
}
elseif ($start==2)
{
	$title = "<font color=\"red\">$headwords</font> enter details";
}
#set up headings
#------------------------------------------


#==========================================
#enter project reference #8ja15
if ($start==1)
{
	?>
	<head>
	<?php
	echo $styleya;
	?>
	</head>
	<?php
	print "<h3>$title</h3>";
	echo $thisdate;

	#selector list of files
	#$query = "SELECT job_nmbr, coden FROM $table1 WHERE coden>'' AND left(job_nmbr,2)!='(A' ORDER BY job_nmbr";
	#$result = mysql_query($query)
  #      or die("query failed - " . mysql_errno() . ": " . mysql_error());
	#first pass form to indicate project reference
	#$defaults=array('copytype'=>'isprj'); #default is unconditional
	print "<form action=\"$PHP_SELF\" method=\"post\">";
	print "<p>Please enter the project reference and name, select the board size, select the functions to list then select Submit.</p>";
	print ("<table>\n");
	print "<tr bgcolor=\"cccccc\"><th align=\"left\">Project reference</th><th></th><th></th></tr>";
	#if ($start==1)
	#{
		print "<tr><td>Enter project number and name: </td>";
		echo '<td><input name="thisproject" value="" size="60" maxlength="99">';
		#print "<td><select type=\"test\" name=\"jobref\"";
		#while ($row=mysql_fetch_array($result)) #list from a2proj
		#{
			#$match=trim($row['job_nmbr']);
			#$rowfile=$link->getRow("SELECT descript, situated, status FROM $table2 WHERE trim(jobnumber)='$match' LIMIT 1"); #all entries #AND lower(status)!='n'
			#if (strlen(trim($row['job_nmbr']))>4 && $rowfile['status']!='n')
			#{
				#print "<option value=\"$row[job_nmbr]\">$row[job_nmbr]  ". #trim($rowfile['descript']);
				#if ($rowfile['situated']>'') #if there is location data
				#{
					#$locate1=", ".trim($rowfile['situated']);
				#}
				#else $locate1='';
				#echo $rowfile['status']; #ok
				#print "$locate1</option>";
			#}
		#}
		#mysql_free_result($result);
		#print "</select>";
		print "</td></tr>";
		$defaults=array('boardsize'=>'standard');
		echo '<tr>';
		echo '<th align="right">Board size</th><td>';
		input_radiocheck('radio','boardsize',$defaults,'standard');
		print " Standard 1800x300 (default)<br>";
		input_radiocheck('radio','boardsize',$defaults,'compact');
		print " Compact 1200x250";
		echo '</td></tr>';
		echo '<tr><th align = "left">Employer</th><td>';
		print '<input type="checkbox" name="emp"  value="y" checked="checked"'.$ischecked.'>Default: click to exclude'; #bracket at employer collects array for get
		echo '</td></tr>';
		echo '<tr><th align = "left">Architect</th><td>';
		print '<input type="checkbox" name="arc"  value="y" checked="checked"'.$ischecked.'>Default: click to exclude'; #bracket at employer collects array for get
		echo '</td></tr>';
		echo '<tr><th align = "left">Quantity surveyor</th><td>';
		print '<input type="checkbox" name="qs"  value="y" '.$ischecked.'>Click to include'; #bracket at employer collects array for get
		echo '</td></tr>';
		echo '<tr><th align = "left">Structural engineer</th><td>';
		print '<input type="checkbox" name="se"  value="y">Click to include';
		echo '</td></tr>';
		echo '<tr><th align = "left">Electrical engineer</th><td>';
		print '<input type="checkbox" name="ee"  value="">Click to include';
		echo '<tr><th align = "left">Mechanical engineer</th><td>';
		print '<input type="checkbox" name="me"  value="">Click to include';
		echo '<tr><th align = "left">Civil engineer</th><td>';
		print '<input type="checkbox" name="ce"  value="y">Click to include';
		echo '</td></tr>';
		echo '<tr><th align = "left">Clerk of Works</th><td>';
		print '<input type="checkbox" name="cow"  value="">Click to include';
		echo '</td></tr>';
		echo '<tr><th align = "left">Contractor</th><td>';
		print '<input type="checkbox" name="con"  value="y" checked="checked"'.$ischecked.'>Default: click to exclude';
		echo '</td></tr>';
		echo '<tr><td><input type="hidden" name="start" value="2">'; #sets start level for next pass</td></tr>
	print ("</table>");
	echo '<hr>';
	print ("<input type=\"submit\" name=\"button\" value=\"Submit\">");
	print "</form>";

	echo '<hr>';
	print("<p><a href=$homefile><font color=\"#999966\"><b>Home</b></font></a>");
	#print("<p><a href=\"http://yabw.net\"><font color=\"#999966\"><b>YA web page</b></font></a>");
	print $madehere;
}
#end of first pass to select project
#===============================================


#===============================================
#second pass main data entry for this form
if ($start==2)
{
	?>
	<head>
	<?php
	echo $styleya;
	?></head>
	<?php
	#echo '<p>start=' .$start; #ok
	echo '<h3>' .$title. '</h3>';
	#print "<h3>$title for $jobref</h3>";
	echo '<p>' .$thisday;
#	print $jobref.' check'; prints ok
	#echo $tname .'here'; #ok when entry is in a2proj
	$thisproject=$_POST['thisproject'];
	#echo '<p>ref ' .$thisproject; #ok
	#$these=$link->getRow("SELECT * FROM $table1 WHERE job_nmbr='$reference'");
	#$thisproj=$link->getRow("SELECT descript, situated  from $table2 WHERE jobnumber='$reference'");
	echo '<form action="'. $PHP_SELF .'" method="post">';
	echo '<table>';
	#$empcode=$link->getOne("SELECT coden from $table1 WHERE job_nmbr='$jobref'");
	#if ($empcode>'')
	#{
		#$empdata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($empcode) ."'");
		#echo 'Employer: '.  .' of '. $empdata['adline1'] .', '. $empdata['adline2'];
	#}
	$clientname= $empdata['company'];
	$projectname= trim($thisproj['descript']) .' for '. $clientname;
	echo '<tr><th align="left">Project name </th><td><input type="text" name="boardname" value="'. $thisproject .'" size="50" maxlength="99">';
	echo '</td></tr>';
	if ($_POST['emp']=='y')
	{
		echo '<tr><th align="left">Employer</th><td>';
		echo '<input type="text" name="empname" value="" size="50" maxlength="99">';
		echo '</td><td>';
		#echo '<input type="text" name="empadd" value="" size="50" maxlength="99">';
		echo '</td></tr>';
	}
	if ($_POST['arc']=='y')
	{
		echo '<tr><th align="left">Architect</th><td>';
		echo '<input type="text" name="arcname" value="" size="50" maxlength="99">';
		echo '</td><td>';
		echo '<input type="text" name="arcadd" value="Box , Phone " size="50" maxlength="99">';
		echo '</td></tr>';
	}
	if ($_POST['qs']=='y')
	{
		#$qscode=$link->getOne("SELECT qs from $table1 WHERE job_nmbr='$jobref'");
		#$qsdata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($qscode) ."'");
		echo '<tr><th align="left">Quantity surveyor</th><td>';
		echo '<input type="text" name="qsname" value="" size="50" maxlength="99">';
		echo '</td><td>';
		echo '<input type="text" name="qsadd" value="Box , Phone " size="50" maxlength="99">';
		echo '</td></tr>';
	}
	if ($_POST['se']=='y')
	{
		#$secode=$link->getOne("SELECT se from $table1 WHERE job_nmbr='$jobref'");
		#$sedata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($secode) ."'");
		echo '<tr><th align="left">Structural engineer</th><td>';
		echo '<input type="text" name="sename" value="" size="50" maxlength="99">';
		echo '</td><td>';
		echo '<input type="text" name="seadd" value="Box , Phone " size="50" maxlength="99">';
		echo '</td></tr>';
	}
	if ($_POST['ee']=='y')
	{
		#$eecode=$link->getOne("SELECT ee from $table1 WHERE job_nmbr='$jobref'");
		#$eedata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($eecode) ."'");
		echo '<tr><th align="left">Electrical engineer</th><td>';
		echo '<input type="text" name="eename" value="" size="50" maxlength="99">';
		echo '</td><td>';
		echo '<input type="text" name="eeadd" value="Box , Phone " size="50" maxlength="99">';
		echo '</td></tr>';
	}
	if ($_POST['me']=='y')
	{
		#$mecode=$link->getOne("SELECT me from $table1 WHERE job_nmbr='$jobref'");
		#$medata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($mecode) ."'");
		echo '<tr><th align="left">Mechanical engineer</th><td>';
		echo '<input type="text" name="mename" value="" size="50" maxlength="99">';
		echo '</td><td>';
		echo '<input type="text" name="meadd" value="Box , Phone " size="50" maxlength="99">';
		echo '</td></tr>';
	}
	if ($_POST['ce']=='y')
	{
		#$cecode=$link->getOne("SELECT ce from $table1 WHERE job_nmbr='$jobref'");
		#$cedata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($cecode) ."'");
		echo '<tr><th align="left">Civil engineer</th><td>';
		echo '<input type="text" name="cename" value="" size="50" maxlength="99">';
		echo '</td><td>';
		echo '<input type="text" name="ceadd" value="Box , Phone " size="50" maxlength="99">';
		echo '</td></tr>';
	}
	if ($_POST['cow']=='y')
	{
		#$cowcode=$link->getOne("SELECT cow from $table1 WHERE job_nmbr='$jobref'");
		#$cowdata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($cowcode) ."'");
		echo '<tr><th align="left">Clerk of Works</th><td>';
		echo '<input type="text" name="cowname" value="" size="50" maxlength="99">';
		echo '</td><td>';
		echo '<input type="text" name="cowadd" value="Box , Phone " size="50" maxlength="99">';
		echo '</td></tr>';
	}
	echo '<tr><th align="left">';
	#$concode=$link->getOne("SELECT con from $table1 WHERE job_nmbr='$jobref'");
	if ($_POST['con']=='y')
	{
		#$condata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($concode) ."'");
		echo '<tr><th align="left">Contractor </th><td>';
		echo '<input type="text" name="conname" value="" size="50" maxlength="99"></td><td><input type="text" name="conadd" value="Box , Phone "  size="50" maxlength="99">';
		echo '</td></tr>';

	}
  echo '</td></tr>';
  print "<tr><td><input type=\"hidden\" name=\"start\" value=\"5\">";
  echo "<input type=\"hidden\" name=\"reference\" value=\"$jobref\">";
  echo "<input type=\"hidden\" name=\"boardsize\" value=\"$boardsize\">";
  echo '</td></tr>';
	echo '</table>';
	print "<input type=\"submit\" name=\"button\" value=\"Submit to PDF\">\n";
	echo '</form>';
	print "</td></tr>";

#	print $reference.' check'; #prints ok
	#print "<form action=\"$PHP_SELF\" method=\"post\">";
	#print ("<p>Please enter the details at the last row,\n");
	#print ("then select Submit.\n</p>\n");
	#print ("<table>\n");
	#if job ref exists, call array from table


	#echo '</td><td>';
	#put all data here for posting
	#print ("<input type=\"hidden\" name=\"start\" value=\"3\">\n");
	#print ("<input type=\"hidden\" name=\"reference\" value=\"$reference\">\n"); #carry ref forward
	#print ("</table>\n");
	#print ("<input type=\"submit\" name=\"button\" value=\"Submit\">\n");
	#print "</form>\n";

	print("<p><a href=$homefile><font color=\"#999966\"><b>Home</b></font></a><br />");

	#echo '<p>Call pdf function without writing new certificate: accept or edit certificate number and submit:</p>';
	#echo '<form action="http://192.168.20.12/php/ya2/cert_pdf.php/?start=4&reference='. $reference .'" method="post">';
	#echo '<input type="text" name="cert_no" value="'. $thiscert .'" size="2" maxlength="2"';
  #print "<input type=\"submit\" name=\"button\" value=\"Submit\">";
  #echo '</form>';

	echo '<hr>';
	print $madehere;
	print '<p>Created 18ap07';
}
#end part 2 main data entry for this form
#===============================================


#===============================================
#function write data to table for new certificate

#end write new project to table
#=============================================


#=============================================
#produce pdml pdf
if ($start==7)
{
#print_r($_POST); #ok
#	print $jobref.'
#nb pdml=no png graphics
	if ($_POST['reference']>'')
		{$reference=$_POST['reference'];}
	elseif ($_GET['reference']>'')
		{$reference=$_GET['reference'];}
	$boardname=$_POST['boardname'];
	$boardsize=$_POST['boardsize'];
	$arcname=$_POST['arcname'];
	$arcadd=$_POST['arcadd'];
	$arcdes='Architect';
	$qsname=$_POST['qsname'];
	$qsadd=$_POST['qsadd'];
	$qsdes='Quantity surveyor';
	$sename=$_POST['sename'];
	$seadd=$_POST['seadd'];
	$sedes='Structural engineer';
	$eename=$_POST['eename'];
	$eeadd=$_POST['eeadd'];
	$eedes='Electrical engineer';
	$mename=$_POST['mename'];
	$meadd=$_POST['meadd'];
	$medes='Mechanical engineer';
	$cename=$_POST['cename'];
	$ceadd=$_POST['ceadd'];
	$cedes='Civil engineer';
	$cowname=$_POST['cowname'];
	$cowadd=$_POST['cowadd'];
	$cowdes='Clerk of Works';
	$conname=$_POST['conname'];
	$conadd=$_POST['conadd'];
	$condes='Contractor';

	#echo $cert_no; #ok
	#$condata=$link->getRow("SELECT * FROM $table3 WHERE lower(coden)='". strtolower($concode) ."'");

	include 'pdml.php';

	?>
	<pdml>
	<body>
	<font face=arial size=11>
	<div top=55mm left=95mm height=60mm>
	</div>
	<?php
	echo '<cell left=12mm top=40mm width=100mm></cell><br height=120%>';

	#site board name
	echo '<font face=arial size=15>';
	echo '<div top=30mm left=40mm width=120mm height=25mm color="#ffc0e0" border=1mm>';
	echo '<line from 30,30 to 30,90>';
	echo $boardname;
	echo '</div><br>';
	#end site board name

	#arc name
	echo '<font face=arial size=11>';
	echo '<div top=57.5mm left=40mm width=120mm height=25mm color="#fff0e0" border=1mm>';
	#echo '<line from 30,30 to 30,50>';
	echo $arcname;
	echo '</div><br>';
	#end arc name

	#qs board
	echo '<cell top=85mm left=40mm width=120mm height=25mm border=1mm color="#fccfff"';
	#end qs board


	echo '<font face=arial size=11></b>';


	?>
	</body>
	</pdml>
	<?php
} #end start=7
#function print pdf to screen
#==============================================


#==============================================
#start=5 uses fpdf
if ($start==5)
{

	class PDF extends FPDF
	{ #start of fpdf extends
	  function display_list()
		{
			global $connect;
			if ($_POST['reference']>'')
				{$reference=$_POST['reference'];}
			$boardname=$_POST['boardname'];
			$boardsize=$_POST['boardsize'];
			$empname=$_POST['empname'];
			$arcname=$_POST['arcname'];
			$arcadd=$_POST['arcadd'];
			$arcdes='Architect';
			$qsname=$_POST['qsname'];
			$qsadd=$_POST['qsadd'];
			$qsdes='Quantity surveyor';
			$sename=$_POST['sename'];
			$seadd=$_POST['seadd'];
			$sedes='Structural engineer';
			$eename=$_POST['eename'];
			$eeadd=$_POST['eeadd'];
			$eedes='Electrical engineer';
			$mename=$_POST['mename'];
			$meadd=$_POST['meadd'];
			$medes='Mechanical engineer';
			$cename=$_POST['cename'];
			$ceadd=$_POST['ceadd'];
			$cedes='Civil engineer';
			$cowname=$_POST['cowname'];
			$cowadd=$_POST['cowadd'];
			$cowdes='Clerk of Works';
			$conname=$_POST['conname'];
			$conadd=$_POST['conadd'];
			$condes='Contractor';

			#$link=$connect ()
				#or die ("Cannot link to server");
			#$link->setFetchMode(DB_FETCHMODE_ASSOC);

			if ($boardsize=='standard')
			{
				$xx=20;
				$yy=47.5;
				$yspace=32.5;
				$yhigh=30;
				$end=30;
				$middle=120;
				$topcelly=22;
				$topcellx=33;
				$topwide=112;
				$texta=18; #description
				$firmcellplus=7;
				$fcellxplus=33;
				$fcellwide=110;
				$textb=16; #firm
				$acellwide=154;
				$dcellyplus=10;
				$dcellxplus=154;
				$dcellwide=22;
				$dcellhigh=6;
				$textc=11; #desgnation
			}
			elseif ($boardsize=='compact')
			{
				$xx=20;
				$yy=42.5;
				$yspace=27.5;
				$yhigh=25;
				$end=21;
				$middle=78;
				$topwide=70;
				$topcelly=20;
				$topcellx=25;
				$texta=13;
				$firmcellplus=4;
				$fcellxplus=25;
				$fcellwide=70;
				$textb=13;
				$acellwide=105;
				$dcellyplus=7;
				$dcellxplus=100;
				$dcellwide=18;
				$dcellhigh=5;
				$textc=8;
			}

			$this->SetTopMargin(0);
			$this->SetY(0);
			$this->Rect($xx, 15, $end, $yhigh); #top board
			$this->Rect($xx+$end, 15, $middle, $yhigh);
			$this->Rect($xx+$end+$middle, 15, $end, $yhigh);
			$this->SetXY($xx+$topcellx,$topcelly);
			$this->SetFont('Arial','',$texta);
			$this->Multicell($topwide,8,$boardname,0,'R'); #$boardname

			if  ($empname>'')
			{
				$this->SetXY($xx+$topcellx,$topcelly+8); #
				$this->SetFont('Arial','',$textb);
				$this->Multicell($topwide,8,$empname,0,'R');
			}

			if ($arcname>'')
			{
				$this->Rect($xx, $yy, $end, $yhigh); #arc board
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$arcname,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$arcadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,10,$arcdes,0,'C');
				$yy=$yy+$yspace;
			}

			if ($qsname>'')
			{
				$this->Rect($xx, $yy, $end, $yhigh);
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$qsname,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$qsadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,$dcellhigh,$qsdes,0,'C');
				$yy=$yy+$yspace;
			}

			if ($sename>'')
			{
				$this->Rect($xx, $yy, $end, $yhigh);
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$sename,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$seadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,$dcellhigh,$sedes,0,'C');
				$yy=$yy+$yspace;
			}

			if ($eename>'')
			{
				$this->Rect($xx, $yy, $end, $yhigh);
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$eename,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$eeadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,$dcellhigh,$eedes,0,'C');
				$yy=$yy+$yspace;
			}

			if ($mename>'') #mechanical engineer
			{
				$this->Rect($xx, $yy, $end, $yhigh);
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$mename,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$meadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,$dcellhigh,$medes,0,'C');
				$yy=$yy+$yspace;
			}

			if ($cename>'') #civil engineer
			{
				$this->Rect($xx, $yy, $end, $yhigh);
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$cename,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$ceadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,$dcellhigh,$cedes,0,'C');
				$yy=$yy+$yspace;
			}

			if ($cowname>'') #clerk of works
			{
				$this->Rect($xx, $yy, $end, $yhigh);
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$cowname,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$cowadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,$dcellhigh,$cowdes,0,'C');
				$yy=$yy+$yspace;
			}

			if ($conname>'')
			{
				$this->Rect($xx, $yy, $end, $yhigh); #contractor
				$this->Rect($xx+$end, $yy, $middle, $yhigh);
				$this->Rect($xx+$end+$middle, $yy, $end, $yhigh);
				$this->SetXY($xx+$fcellxplus,$yy+$firmcellplus);
				$this->SetFont('Arial','',$textb);
				$this->Multicell($fcellwide,10,$conname,0,'R');
				$this->SetFont('Arial','',$textc);
				$this->Ln(0);
				$this->Multicell($acellwide,5,$conadd,0,'R');
				$this->SetXY($xx+$dcellxplus,$yy+$dcellyplus);
				$this->Multicell($dcellwide,10,$condes,0,'C');
			}

			$this->Ln(10);
			$this->SetFont('Arial','',10);
			$this->Cell(10,15,"",0,0);
			$this->Cell(100,15,"BIDP site notice board, Scale 1:10; Board size $boardsize",0,1);
		}
	} #end of fpdf extends
	$pdf=new PDF('P','mm','A4'); #items starting with $pdf represent use of the class
	$pdf->AliasNbPages();
	$pdf->AddPage(); #creates the page dy
	$pdf->SetFont('Arial','',11);
	$pdf->display_list();
	#$pdf->Cell(40,10,'Hello World!');
	$pdf->Output();
}
#end start=5
#==============================================
#end
?>