<?php
include("kurs/datenbankanbindung.php"); // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
$user_admin=$_COOKIE["user_admin"];
$hs=$_COOKIE["ck_hs"];


$db = dbconnect();

// In der View stan_zuw_so sind nur Datensätze drin, die nicht bereits gedruckt wurden. Abgleich mit 'stan_printqueue_antrag'
$queryb = $db->query ("SELECT count(*) Anz
                          FROM stan_zuw_so
                         WHERE hs='$hs'");
$row_cur_uid_anz = $queryb->fetch_array();



if($row_cur_uid_anz[Anz] > 0){

define('FPDF_FONTPATH','font/');
require('prints/as_utf_class.php');
require_once("prints/table_def.inc");

$pdf= new utfFPDF();


if($hs == 'K' or $hs == 'k'){
  $pagecount = $pdf->setSourceFile("anschreiben_kehl/blanko_kehl.pdf");
}else{
  $pagecount = $pdf->setSourceFile("anschreiben/blanko_ludwigsburg.pdf");
}
#$pagecount = $pdf->setSourceFile("anschreiben/zuweisung_AG_Standort.pdf");

$tplidx = $pdf->ImportPage(1);



$db = dbconnect();

$querya = "SELECT distinct uid, vorname, nachname
            FROM stan_zuw_so
           WHERE hs='$hs'
           ORDER BY uid";
$resulta = $db->query ($querya)
   or die ("Cannot execute query1");


while ($row_cur_uid = $resulta->fetch_array())
{


    $pdf->addPage();
    $pdf->useTemplate($tplidx,0,0,0);
    $pdf->SetAutoPageBreak(true, 10);
    if($hs == 'K' or $hs == 'k'){
      require("anschreiben_kehl/zuweisung_ag_standort_alt.php");
    }else{
      require("anschreiben/zuweisung_ag_standort_alt.php");
    }
    
  }

    
#}

#exit;	
$pdf->Output("zuweisung_standort.pdf","i");
$pdf->closeParsers();
}else{ //($row_cur_uid_anz[Anz] > 0

echo"
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Mailversand</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Keine aktuelle Zuweisungen</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br><p align=\"center\"><b>Es wurden alle Standortzuweisungen gedruckt!</b>
                    <p></p>
                    <p></p>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";

} //Endif($row_cur_uid_anz[Anz] > 0){
?>