<?php

include("kurs/datenbankanbindung.php"); // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php

#require_once("class.fpdf_table.php");

define('FPDF_FONTPATH','font/');
require('as_utf_class.php');
require_once("table_def.inc");
$pdf= new utfFPDF();





$db = dbconnect();


$columns = 5; //five columns


$pos=$pdf->GetY()+10;


$pdf->SetY($pos);

	//we initialize the table class
	$pdf->Table_Init($columns, true, true);

	$table_subtype = $table_default_table_type;
	$pdf->Set_Table_Type($table_subtype);
	
	//TABLE HEADER SETTINGS
	$header_subtype = $table_default_header_type;
	
        $db = dbconnect();
        $query1 = "SELECT distinct doz_nr
                    FROM brt_thema a, stud b, doz c
                   WHERE a.uid = b.uid
                    AND a.eb_doz_nr = c.doz_nr
                    AND b.jahrgang = '08'
                    AND stg NOT LIKE '%S%'
                  ORDER BY concat( doz_name, ' ', doz_vorname) , nachname, vorname, ag";
        $result1 = $db->query ($query1)
           or die ("Cannot execute query1a");
           

 
        while ($row1 = $result1->fetch_array())
	{
	$pdf->AddPage();
	for($i=0; $i<$columns; $i++) $header_type[$i] = $table_default_header_type;

	$header_type[0]['WIDTH'] = 40;
	$header_type[0]['BG_COLOR'] = array(200,200,200);
	$header_type[0]['T_ALIGN'] = "L"; //C=CENTER, L=LEFT, R=RIGHT, J=JUSTIFY
	$header_type[0]['V_ALIGN'] = "M"; //T=TOP, M=MIDDLE, B=BOTTOM
	$header_type[0]['TEXT'] = "Erstprüfer";
	
	
	$header_type[1]['WIDTH'] = 40;
	$header_type[1]['BG_COLOR'] = array(200,200,200);
	$header_type[1]['T_ALIGN'] = "L"; //C=CENTER, L=LEFT, R=RIGHT, J=JUSTIFY
	$header_type[1]['V_ALIGN'] = "M"; //T=TOP, M=MIDDLE, B=BOTTOM
	$header_type[1]['TEXT'] = "Name";
	
	$header_type[2]['WIDTH'] = 10;
	$header_type[2]['BG_COLOR'] = array(200,200,200);
	$header_type[2]['T_ALIGN'] = "L"; //C=CENTER, L=LEFT, R=RIGHT, J=JUSTIFY
	$header_type[2]['V_ALIGN'] = "M"; //T=TOP, M=MIDDLE, B=BOTTOM
	$header_type[2]['TEXT'] = "AG";
	
	$header_type[3]['WIDTH'] = 50;
	$header_type[3]['BG_COLOR'] = array(200,200,200);
	$header_type[3]['T_ALIGN'] = "L"; //C=CENTER, L=LEFT, R=RIGHT, J=JUSTIFY
	$header_type[3]['V_ALIGN'] = "M"; //T=TOP, M=MIDDLE, B=BOTTOM
	$header_type[3]['TEXT'] = "Thema";
	
	$header_type[4]['WIDTH'] = 30;
	$header_type[4]['BG_COLOR'] = array(200,200,200);
	$header_type[4]['T_ALIGN'] = "L"; //C=CENTER, L=LEFT, R=RIGHT, J=JUSTIFY
	$header_type[4]['V_ALIGN'] = "M"; //T=TOP, M=MIDDLE, B=BOTTOM
	$header_type[4]['TEXT'] = "Zweitprüfer";
	
	#$header_type[1]['COLSPAN'] = "2";

	//set the header type
	$pdf->Set_Header_Type($header_type);
	
	$pdf->Draw_Header();
	
	//TABLE DATA SETTINGS
	$data_subtype = $table_default_data_type;
	
	$data_type = Array();//reset the array
	for ($i=0; $i<$columns; $i++) $data_type[$i] = $data_subtype;

	$pdf->Set_Data_Type($data_type);
	
#	$fsize = 10;
#	$colspan = 1;
#	$rr = 255;

        $db = dbconnect();
        $query = "SELECT concat( doz_vorname, ' ', doz_name ) Erstprüfer, Nachname, Vorname, concat( ag, '/', jahrgang ) AG, Thema, concat( zb_vorname, ' ', zb_nachname ) Zweitprüfer
                    FROM brt_thema a, stud b, doz c
                   WHERE a.uid = b.uid
                    AND a.eb_doz_nr = c.doz_nr
                    AND b.jahrgang = '08'
                    AND stg NOT LIKE '%S%'
                    AND doz_nr='$row1[doz_nr]'
                  ORDER BY concat( doz_name, ' ', doz_vorname) , nachname, vorname, ag";
        $result = $db->query ($query)
           or die ("Cannot execute query1");
           

 
        while ($row = $result->fetch_array())
	{


/* Schriftgröße
		$data[0]['T_SIZE'] = $fsize;
		$data[1]['T_SIZE'] = $fsize+3;
		$data[3]['T_SIZE'] = $fsize+4;
*/
/* Schriftfarbe und Zellenhintergrund
		$data[0]['T_COLOR'] = array(0,0,0); //Schriftfarbe
		$data[0]['BG_COLOR'] = array($rr,$rr,$rr);
		$data[3]['T_COLOR'] = array($rr,240,240);
		$data[3]['BG_COLOR'] = array($rr,100,135);
*/
			$data[0]['TEXT'] = "$row[Erstprüfer]";
			$data[0]['T_ALIGN'] = "L"; //C=CENTER, L=LEFT, R=RIGHT, J=JUSTIFY
			$data[0]['V_ALIGN'] = "M"; //T=TOP, M=MIDDLE, B=BOTTOM
		       #$data[0]['T_TYPE'] = "BI"; // B=BOLD, I=ITALIC
			
			$data[1]['TEXT'] = "$row[Vorname] $row[Nachname]";
			$data[1]['T_ALIGN'] = "L";
			$data[1]['V_ALIGN'] = "M";
			
			$data[2]['TEXT'] = "$row[AG]";
			$data[2]['T_ALIGN'] = "L";
			$data[2]['V_ALIGN'] = "M";
			
			$data[3]['TEXT'] = "$row[Thema]";
			$data[3]['T_ALIGN'] = "L";
			$data[3]['V_ALIGN'] = "M";
			
			$data[4]['TEXT'] = "$row[Zweitprüfer]";
			$data[4]['T_ALIGN'] = "L";
			$data[4]['V_ALIGN'] = "M";

		$pdf->Draw_Data($data,NULL,10); // -->letzter Parameter Höhe der Datenspalte. Neu prgrammiert in prints/class.fpdf_table.php am 15.04.2009
	}
	
}
	$pdf->Draw_Table_Border();


$pdf->Output();


?>