<?php

include("kurs/datenbankanbindung.php"); // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
$uid1='schwaral';
$jahrgang='08';
$standort='1';
$_POST[termin] = '1';

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

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



$pdf->AddPage();

$db = dbconnect();


$columns = 4; //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;
	
	
	for($i=0; $i<$columns; $i++) $header_type[$i] = $table_default_header_type;

	$header_type[0]['WIDTH'] = 50;
	$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'] = "Name";
	
	
	$header_type[1]['WIDTH'] = 20;
	$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'] = "Hochschule";
	
	$header_type[2]['WIDTH'] = 50;
	$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'] = "Ausbildungsstelle";
	
	$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'] = "Unterschrift";
	
	#$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 vorname, nachname, hs, mail, mail2, dst_id
                    FROM stan_ag_standort_termine a, stan_ag_standort_wunsch b, stan_antrag c, stud d
                   WHERE a.fagsid =b.wagsid
                     AND b.saaid = c.saaid
                     AND c.uid = d.uid
                     AND a.datid='$_POST[termin]'
                     AND a.datum >=c.beginn
                     AND a.datum <=c.ende
                     AND b.prio=1
                   ORDER BY nachname, vorname
                   limit 0,4";
        $result = $db->query ($query)
           or die ("Cannot execute query1");
           

 
        while ($row = $result->fetch_array())
	{
		$data = Array();
		
                $res4 = $db->query("SELECT bez FROM stan_dienststellen WHERE dst_id='$row[dst_id]'");
                $row4 = $res4->fetch_array();
                if($row4[bez] != ''){
                  $dst_bez = $row4[bez];
                }else{
                  $res5 = $db->query("SELECT bez FROM stan_dienststellen_tmp WHERE dst_id='$row[dst_id]'");
                  $row5 = $res5->fetch_array();
                  $dst_bez = $row5[bez];
                }
		

                if($row[hs] == 'K' or $row[hs] == 'k'){
                  $hs = "Kehl";
                }else{
                  $hs = "Ludwigsburg";
                }

/* 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[vorname] $row[nachname]";
			$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'] = "$hs";
			$data[1]['T_ALIGN'] = "L";
			$data[1]['V_ALIGN'] = "M";
			
			$data[2]['TEXT'] = "$dst_bez";
			$data[2]['T_ALIGN'] = "L";
			$data[2]['V_ALIGN'] = "M";
			
			$data[3]['TEXT'] = "";
			$data[3]['T_ALIGN'] = "L";
			$data[3]['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();


?>