Subversion Repositories public

Rev

Blame | Last modification | View Log | RSS feed

<?
require_once('version.inc');
require_once('dbaccess.inc');
require_once('language.inc');
require_once('header.inc');
require_once('helper.inc');
require_once('crypt.inc');
require_once('settings.inc');

$knopf = 0;
$func = $_REQUEST['func'];

# Auswertungsmenue
if (isset($_REQUEST['auswertung'])) { $knopf = 27; $headline = 31; }

$drm = array(true, false, false, false, false, true, false);

require_once('menu.inc');
require_once('knumber.inc');
require_once('tempplan.inc');

# This module contains the following functions:
#    Preselect
#    ZSum
#    Cell
#    ProjektMa
#    MitarbeiterPj
#    PrintList

# Folgende Funktion erlaubt die Auswahl einiger Voreinstellungen und
# Einschraenkungen fuer den Statusbericht.
#
function Preselect($repeat=0) {
        global $periode;
        global $phase;
        global $menu;
        global $unum;
        global $pmlight;

        $db = OpenDB();
        $pjclosed = $_REQUEST['pjclosed'];
        $nav = "mi_num='+wahl.mi_num.value+'&sort1='+wahl.sort[0].checked+'";
        $nav .= "&sort2='+wahl.sort[1].checked+'&pjclosed='+wahl.pjclosed.checked+'&menu=$menu&headline=31";

        if ($repeat == 1)
           $plnum = $_REQUEST['pl_num'];

        if (!isset($pjclosed) || CheckTrue($pjclosed))
           $pjclosed = true;
        else
           $pjclosed = false;

        $prnum = 0;
        # Folgende Maske zeigt zwei ineinander verschachtelte Tabellen
        # um die einzelnen Wahlelemente optisch voneinader zu trennen.
?>
<form name="wahl" action="auswertung.php" method="post">
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
<input type="hidden" name="headline" value="31">
<input type="hidden" name="func" value="prlist">

<table class="sel">
<tr><th class="sel" colspan=2><? Output($db, 316, "Projektauswahl"); ?></th></tr>
<tr><td>
<?php
        # Auswahl eines freigegebenen oder fertigen Projekts.
        # Nicht in der light version!
        if (!$pmlight) {
           Output($db, 317, "Abgeschlossene Projekte:");
           echo "</td>\n";
           echo "<td><input type=\"checkbox\" name=\"pjclosed\" value=\"1\" ";

           if ($pjclosed)
             echo "checked ";

           echo "onChange=\"javascript:MoveTo('auswertung.php','func=repeatpj&$nav')\">&nbsp;";
           Output($db, 318, "In Auswahlliste anzeigen");
           echo "</td></tr><tr><td>\n";
        } else {
           echo "<input type=\"hidden\" name=\"pjclosed\" value=\"1\">\n";
        }

        echo GetMessage($db, 319, "Projekte:") . "</td>\n";
        echo "<td>";

        $query = "select distinct on (pl_prnum) pl_num, pl_prnum, pl_lfd, pr_name, pl_status from plan, project ";
        $query .= "where pr_num = pl_prnum and pl_status in (0,2,4";

        if ($pjclosed)
           $query .= ",6";

        $query .= ") ";
        $query .= "order by pl_prnum, pl_lfd desc";

        $result = QueryDB($db, $query);

        if (!$result) {
           closeDB($db);
           return;
        }

        echo "<select name=\"pl_num\" ";
        echo "onchange=\"javascript:MoveTo('auswertung.php', ";
        echo "'func=repeatpj&pl_num='+this.value+'&$nav')\">\n";
        $numrows = numrowsDB($result);
        $rows = 0;

        while ($rows < $numrows) {
           $data = fetchDB($result, $rows);
           $pl_num = $data[0];
           $pl_prnum = $data[1];
           $pl_lfd = $data[2];
           $pr_name = $data[3];
           $pl_status = $data[4];

           if ($rows == 0) {
              $a = GetMessage($db, 241, "Alle");

              if (isset($plnum) && $plnum == 0)
                 echo "<option value=\"0\" selected>$a</option>\n";
              else
                 echo "<option value=\"0\">$a</option>\n";
           }

           if ($pl_status == 1)
              $vz = "*:";               // Kommt nie vor!!
           else if ($pl_status == 6)
              $vz = GetMessage($db, 320, "Abgeschl.:"); // Abgeschlossen
           else if ($pl_status == 0)
              $vz = GetMessage($db, 321, "Konto:");             // Konto
           else
              $vz = GetMessage($db, 1, "Projekt:");             // Projekt

           if (isset($plnum) && $plnum == $pl_num) {
              echo "<option value=\"$pl_num\" selected>$vz $pl_prnum $pr_name</option>\n";
              $prnum = $pl_prnum;
              $akt_status = $pl_status;
           } else
              echo "<option value=\"$pl_num\">$vz $pl_prnum $pr_name</option>\n";
           $rows++;
        }

        echo "</select></td></tr>\n";
        # Mitarbeiterauswahl
        echo "<tr><th class=\"sel\" colspan=2>" . GetMessage($db, 322, "Mitarbeiterauswahl") . "</th></tr>\n";
        echo "<tr><td>" . GetMessage($db, 305, "Mitarbeiter:") . "</td>";
        echo "<td>\n";


        if ($repeat == 1 && isset($plnum) && $plnum > 0) {
//         $query = "select distinct wd_minum, mi_nname, mi_vname from ";
//         $query .= "wdone, mitarbeiter, task, plan where mi_num = wd_minum and ";
//         $query .= "wd_prnum = $prnum ";
           $query = "select distinct al_ressource, mi_nname, mi_vname from ";
           $query .= "allocation, mitarbeiter, task, plan where ";
           $query .= "mi_num = al_ressource and ta_num = al_task and ";
           $query .= "pl_num = ta_plnum and pl_prnum = $prnum "; //and mi_plan = true ";
           $query .= "order by mi_nname, mi_vname";
        } else {
           $query = "select mi_num, mi_nname, mi_vname from mitarbeiter ";
           $query .= "where mi_plan = true order by mi_nname, mi_vname";
        }

        $result = QueryDB($db, $query);

        if (!$result) {
           closeDB($db);
           return;
        }

        echo "<select name=\"mi_num\">\n";
        echo "<option value=\"0\">" . GetMessage($db, 241, "Alle") . "</option>\n";
        $minum = $_REQUEST['mi_num'];
        $numrows = numrowsDB($result);
        $rows = 0;

        while ($rows < $numrows) {
           $data = fetchDB($result, $rows);
           $mi_num = $data[0];
           $mi_nname = $data[1];
           $mi_vname = $data[2];

           if (!isset($minum) || $minum <= 0)
              $minum = $unum;

           if ($mi_num == $minum)
              echo "<option selected value=\"$mi_num\">$mi_nname $mi_vname</option>\n";
           else
              echo "<option value=\"$mi_num\">$mi_nname $mi_vname</option>\n";
           $rows++;
        }

        echo "</select></td></tr>\n";

        # Zeitraum
        echo "<tr><th class=\"sel\" colspan=2>" . GetMessage($db, 323, "Anzuzeigender Zeitraum") . "</th></tr>\n";
        echo "<tr><td>" . GetMessage($db, 306, "Zeitraum:") . "</td>\n";
        echo "<td>";
        $query = "select ta_start from task";

        if ($repeat == 1 && isset($plnum) && $plnum > 0)
           $query .= " where ta_plnum = $plnum ";

        $query .= " order by ta_start";
        $result = QueryDB($db, $query);

        if (!$result) {
           closeDB($db);
           return;
        }

        $data = fetchDB($result, 0);
        $fdate = $data[0];

        $query = "select ta_start + (ta_duration * 86400) as ds from task";

        if ($repeat == 1 && isset($plnum) && $plnum > 0)
           $query .= " where ta_plnum = $plnum ";

        $query .= " order by ds desc";
        $result = QueryDB($db, $query);

        if (!$result) {
           closeDB($db);
           return;
        }

        $data = fetchDB($result, 0);
        $ldate = $data[0];

        if ($repeat == 1 && isset($plnum) && $plnum > 0) {
           $dfirst = $fdate;
           $dlast = $ldate;
        } else {
           $dt = time();
           $mon = gmdate ("n", $dt);
           $year = gmdate("Y", $dt);

           if ($mon < 6)
              $mon = 1;
           else
              $mon = 6;

           $dfirst = gmmktime(0, 0, 0, $mon, 1, $year);

           if ($ldate < $dt) {
              $mon = gmdate("n", $ldate);
              $year = gmdate("Y", $ldate);
              $dlast = gmmktime(0, 0, 0, $mon, 1, $year);
           }
           else {
              if ($mon == 1)
                 $mon = 6;
              else if ($mon == 6)
                 $mon = 12;

              $zw = gmmktime(0, 0, 0, $mon, 1, $year);

              if ($zw <= $ldate)
                 $dlast = $zw;
              else {
                 $mon = gmdate("n", $ldate);
                 $dlast = gmmktime(0, 0, 0, $mon, 1, $year);
              }
           }
        }

        $cd = $fdate;

        if (!isset($akt_status) || $akt_status > 0) {
           echo GetMessage($db, 307, "Von:") . "&nbsp;<select name=\"dfrom\"";

           if ($repeat == 1 && isset($akt_status) && $akt_status == 0)
              echo " disabled";

           echo ">\n";
           $amon = gmdate("n", $dfirst);
           $ayear = gmdate("Y", $dfirst);

           while ($cd <= $ldate) {
              $mon = gmdate("n", $cd);
              $year = gmdate("Y", $cd);
              $zw = gmmktime(0, 0, 0, $mon, 1, $year);

              if ($mon == $amon && $year == $ayear)
                 echo "<option value=\"$zw\" selected>$mon.$year</option>\n";
              else
                 echo "<option value=\"$zw\">$mon.$year</option>\n";

              $cd = IncDate($periode, $zw);
           }

           echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;";
        }

        $cd = $fdate;

        if (!isset($akt_status) || $akt_status > 0) {
           echo GetMessage($db, 308, "Bis:") . "&nbsp;<select name=\"dto\">\n";

           $lmon = gmdate("n", $dlast);
           $lyear = gmdate("Y", $dlast);

           while ($cd <= $ldate) {
              $mon = gmdate("n", $cd);
              $year = gmdate("Y", $cd);
              $zw = gmmktime(0, 0, 0, $mon, 1, $year);

              if ($mon == $lmon && $year == $lyear)
                 echo "<option value=\"$zw\" selected>$mon.$year</option>\n";
              else
                 echo "<option value=\"$zw\">$mon.$year</option>\n";

              $cd = IncDate($periode, $zw);
           }
        }

        echo "</select></td></tr>\n";
        # Anzeigenauswahl
        echo "<tr><th class=\"sel\" colspan=2>" . GetMessage($db, 324, "Anzeigenauswahl") . "</th></tr>\n";
        echo "<tr><td valign=\"top\">" . GetMessage($db, 309, "Spaltenauswahl:") . "</td>\n";
        echo "<td><table border=0><tr>";
        echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"1\" name=\"fields_0\">" . GetMessage($db, 310, "Tasks anzeigen") . "</td>\n";
        echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"2\" name=\"fields_1\">" . GetMessage($db, 294, "Anmerkungen") . "</td></tr><tr>\n";
        echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"3\" name=\"fields_2\">" . GetMessage($db, 291, "Gruppe") . "</td>\n";
        echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"4\" name=\"fields_3\" ";
        echo "onClick=\"javascript:if (document.wahl.fields_4.checked == false ||";
        echo "document.wahl.fields_5.checked == false) { this.checked = false; }\">" . GetMessage($db, 312, "IST- Plandifferenz") . "</td></tr><tr>\n";
        echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"5\" name=\"fields_4\" checked ";
        echo "onClick=\"javascript:if (this.checked == false) { document.wahl.fields_3.checked = false; } ";
        echo "if (this.checked == false && document.wahl.fields_5.checked == false) { this.checked = true; }\">" . GetMessage($db, 311, "IST-Werte") . "</td>\n";
        echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"6\" name=\"fields_5\" checked ";
        echo "onClick=\"javascript:if (this.checked == false) { document.wahl.fields_3.checked = false; } ";
        echo "if (this.checked == false && document.wahl.fields_4.checked == false) { this.checked = true; }\">" . GetMessage($db, 313, "Planwerte") . "</td></tr>\n";

        if ($phase)
           echo "<tr><td class=\"selnf\" colspan=2><input type=\"checkbox\" value=\"7\" name=\"fields_6\" checked>" . GetMessage($db, 292, "Phase") . "</td></tr>\n";

        echo "</table>\n";
        echo "</td></tr>\n";

        echo "<tr><td valign=\"top\">" . GetMessage($db, 304, "Sortierreihenfolge:") . "</td>\n";

        if ($_REQUEST['sort1'] == "true")
           $sort = 1;
        else if ($_REQUEST['sort2'] == "true")
           $sort = 2;
        else
           $sort = 2;

        echo "<td>";
        echo "<input type=\"radio\" name=\"sort\" ";

        if ($sort == 1)
           echo "checked ";

        echo "value=\"1\">" . GetMessage($db, 314, "Projekte / Mitarbeiter") . "<br>\n";
        echo "<input type=\"radio\" name=\"sort\" ";

        if ($sort == 2)
           echo "checked ";

        echo "value=\"2\">" . GetMessage($db, 315, "Mitarbeiter / Projekte") . "\n";
        echo "</td></tr>\n";

/*      echo "<tr><td>Plantiefe:</td>\n";
        echo "<td>";
        echo "<select name=\"level\" disabled>\n";
        echo "<option value=\"-1\">Alle</option>\n";
        echo "<option value=\"0\">0</option>\n";
        echo "<option value=\"1\">1</option>\n";
        echo "<option value=\"2\">2</option>\n";
        echo "<option value=\"3\">3</option>\n";
        echo "<option value=\"4\">4</option>\n";
        echo "<option value=\"5\">5</option>\n";
        echo "<option value=\"6\">6</option>\n";
        echo "<option value=\"7\">7</option>\n";
        echo "<option value=\"8\">8</option>\n";
        echo "<option value=\"9\">9</option>\n";
        echo "</select></td></tr>\n";
*/
        echo "<tr><td class=\"selmid\" colspan=2>";
        ButtonSubmit(GetMessage($db, 325, "Senden"), "wahl");
//      echo "<input type=\"submit\" name=\"submit\" value=\"Senden\"> <input type=\"reset\">\n";
        echo "</td></tr></table>\n";
        echo "</form>\n";
        closeDB($db);
}

# Zeilensumme ausgeben
#
function ZSum($sumi, $sump) {
        $fields_3 = $_REQUEST['fields_3'];
        $fields_4 = $_REQUEST['fields_4'];
        $fields_5 = $_REQUEST['fields_5'];

        if ($fields_4 > 0)
           echo "<td class=\"seldkgray\" align=\"right\">" . FormatNum($sumi, 3) . "</td>";

        if ($fields_3 > 0)
           echo "<td class=\"seldkgray\" align=\"right\">" . FormatNum($sump - $sumi, 3) . "</td>";

        if ($fields_5 > 0)
           echo "<td class=\"seldkgray\" align=\"right\">" . FormatNum($sump, 3) . "</td>";

        echo "\n";
}

# Schreiben einer Zelle
#
function Cell($class, $ist, $plan, $blank=false, $per=0) {
        $fields_3 = $_REQUEST['fields_3'];
        $fields_4 = $_REQUEST['fields_4'];
        $fields_5 = $_REQUEST['fields_5'];

        if ($fields_4 > 0) {
           echo "<td class=\"$class\" align=\"right\">";

           if ($blank)
              echo "&nbsp;";
           else
              echo FormatNum($ist, 3);

           if ($per > 0)
              echo "<br>" . gmdate("n/Y", $per);

           echo "</td>";
        }

        if ($fields_3 > 0) {
           echo "<td class=\"$class\" align=\"right\">";

           if ($blank)
              echo "&nbsp;";
           else
              echo FormatNum($plan - $ist, 3);

           echo "</td>";
        }

        if ($fields_5 > 0) {
           echo "<td class=\"$class\" align=\"right\">";

           if ($blank)
              echo "&nbsp;";
           else
              echo FormatNum($plan, 3);

           echo "</td>";
        }
}

# Folgende Funktion erzeugt die Liste aller Projekte. Die Liste
# sortiert nach Projekten und Mitarbeitern (Projektsicht).
#
function ProjektMa($db, $pr_num, $mi_num=0) {
        global $periode;
        global $phase;
        $pl_num = $_REQUEST['pl_num'];
        $dfrom = $_REQUEST['dfrom'];
        $dto = $_REQUEST['dto'];
        $fields_0 = $_REQUEST['fields_0'];
        $fields_1 = $_REQUEST['fields_1'];
        $fields_2 = $_REQUEST['fields_2'];
        $fields_3 = $_REQUEST['fields_3'];
        $fields_4 = $_REQUEST['fields_4'];
        $fields_5 = $_REQUEST['fields_5'];
        $fields_6 = $_REQUEST['fields_6'];
        $sort = $_REQUEST['sort'];
        $level = $_REQUEST['level'];

        # Beim bis-Datum den Monatsletzten ermitteln
        $mon = gmdate("n", $dto);
        $year = gmdate("Y", $dto);
        $day = daysinmonth($mon, $year);
        $dto = gmmktime(23, 59, 59, $mon, $day, $year);
        # Den Projektnamen ermitteln
        $query = "select pr_num, pr_name, pr_status from project ";

        if ($pr_num > 0)
           $query .= "where pr_num = $pr_num ";

        $query .= "order by pr_num";
        $respr = QueryDB($db, $query);

        if (!$respr)
           return;

        $numpr = numrowsDB($respr);
        $pospr = 0;

        $pdiff = $fields_3;
        $pist = $fields_4;
        $pplan = $fields_5;
        $mult = 0;

        if ($pist > 0)
           $mult++;

        if ($pplan > 0)
           $mult++;

        if ($pplan > 0 && $pdiff > 0)
           $mult++;

        $csp = 4;

        if ($fields_6 > 0)
           $csp++;

        if ($fields_0 > 0)
           $csp++;

        if ($fields_1 > 0)
           $csp++;

        if ($fields_2 > 0)
           $csp++;

        $pl_flag = false;
        $TempTable = false;

        while ($pospr < $numpr) {
           $data = fetchDB($respr, $pospr);
           $pr_num = $data[0];
           $pr_name = $data[1];
           $pr_status = $data[2];

           # Wurde kein Projekt gewaehlt, dann muessen wir die Plannummer
           # ermitteln. In diesem Fall zeigen wir immer den aktuelsten Plan
           # an.
           #
           if ($pl_flag || !isset($pl_num) || $pl_num <= 0) {
              $query = "select pl_num from plan where pl_prnum = $pr_num order by pl_num desc";
              $result = QueryDB($db, $query);

              if (!$result)
                 return;

              if (numrowsDB($result) > 0) {
                 $data = fetchDB($result, 0);
                 $pl_num = $data[0];
                 $pl_flag = true;
              } else {
                 $pl_num = 0;
                 $pl_flag = false;
                 $pospr++;
                 continue;
              }
           }

           if ($TempTable && $pospr > 0)
              TQueryDB($db, "drop table TempPlan");

           $TempTable = true;

           if (!CreateTempPlan($db, $pl_num, $pr_num, $dfrom, $dto, true)) {
              $pospr++;
              continue;
           }

           # Wieviele Perioden gibt es insgesamt?
           $query = "select count(distinct tmp_periode) from TempPlan";
           $result = QueryDB($db, $query);

           if (!$result) {
              closeDB($db);
              return;
           }

           $data = fetchDB($result, 0);
           $numper = $data[0];
           $np = $numper * $mult;
           $c = $csp + $np;
           # Keine Datensaetze, dann keine Tabelle malen...
           if ($numper == 0) {
              $pospr++;
              continue;
           }

           # Zeichnen des Tabellenkopfs
           echo "<table class=\"sel\"><tr>";
           echo "<td class=\"sel\" colspan=$c>Projekt: $pr_num $pr_name</td></tr>\n";
           $c = $csp - 3;
           echo "<tr><td class=\"sel\" colspan=$c>&nbsp;</td>\n";

           # Ermitteln der einzelnen Perioden und Darstellung der Selben.
           #
           $query = "select distinct tmp_periode from TempPlan order by tmp_periode";
           $result = QueryDB($db, $query);

           # Wurde kein Projekt gewaehlt, dann muessen wir die Plannummer
           # ermitteln. In diesem Fall zeigen wir immer den aktuelsten Plan
           # an.

           if (!$result) {
              echo "</tr></table>";
              return;
           }

           $numrows = numrowsDB($result);
           $r = 0;
           $x = 0;

           while ($r < $numrows) {
              $data = fetchDB($result, $r);
              $tmp_periode = $data[0];

              $mon = gmdate("n", $tmp_periode);
              $year = gmdate("Y", $tmp_periode);

              if ($r == 0) {
                 $fdate = $tmp_periode;
                 $adate = $fdate;
              }

              while ($adate < $tmp_periode) {
                 $p = gmdate("n/Y", $adate);
                 echo "<th colspan=$mult class=\"sel\">$p</th>\n";
                 $adate = IncDate($periode, $adate);
                 $sumperp[$x] = 0.0;
                 $sumperi[$x] = 0.0;
                 $totalis[$x] = 0.0;
                 $totalpl[$x] = 0.0;
                 $x++;
              }

              echo "<th colspan=$mult class=\"sel\">$mon/$year</th>\n";
              $sumperp[$x] = 0.0;
              $sumperi[$x] = 0.0;
              $totalis[$x] = 0.0;
              $totalpl[$x] = 0.0;
              $adate = IncDate($periode, $adate);
              $r++;
              $x++;
           }

           $ldate = $tmp_periode;
           echo "<th colspan=$mult class=\"sel\">Summen</th></tr>\n";
           echo "<tr><th class=\"sel\">Mitarbeiter</th>";

           if ($fields_2 > 0)
              echo "<th class=\"sel\">Gruppe</th>";

           if ($phase && $fields_6 > 0)
              echo "<th class=\"sel\">Phase</th>";

           if ($fields_0 > 0)
              echo "<th class=\"sel\">Tasks</th>";

           if ($fields_1 > 0)
              echo "<th class=\"sel\">Anmerkungen</th>";

           $r = 0;

           while ($r <= $x) {
              if ($pist > 0)
                 echo "<th class=\"sel\">IST</th>\n";

              if ($pplan > 0 && $pdiff > 0)
                 echo "<th class=\"sel\">Diff.</th>\n";

              if ($pplan > 0)
                 echo "<th class=\"sel\">Plan</th>\n";

              $r++;
           }

           echo "</tr>\n";

           $query = "select tmp_phase, tmp_periode, tmp_plan, tmp_ist,";
           $query .= "tmp_taname, tmp_notiz, mi_nname, mi_vname, kp_phase, ";
           $query .= "kl_land, tmp_miname, tmp_status, tmp_hash ";
           $query .= "from TempPlan, mitarbeiter, key_phase, key_land where ";
           $query .= "mi_num = tmp_miname and kp_num = tmp_phase and kl_num = mi_land ";
           $query .= "order by mi_nname, mi_vname, tmp_phase, tmp_taname, tmp_periode";
           $result = QueryDB($db, $query);

           if (!$result)
              return;

           $numrows = numrowsDB($result);
           $rows = 0;
           $oldminame = 0;
           $oldphase = 0;
           $oldname = "";
           $sumlpl = 0.0;
           $sumlis = 0.0;
           $per = 0;
           $first = true;
           $adate = $fdate;
           $class = "selltgray";

           while ($rows < $numrows) {
              $data = fetchDB($result, $rows);
              $tmp_phase = $data[0];
              $tmp_periode = $data[1];
              $tmp_plan = $data[2];
              $tmp_ist = $data[3];
              $tmp_taname = $data[4];
              $tmp_notiz = $data[5];
              $mi_nname = $data[6];
              $mi_vname = $data[7];
              $kp_phase = $data[8];
              $kl_land = $data[9];
              $tmp_miname = $data[10];
              $tmp_status = $data[11];
              $tmp_hash = $data[12];

              # Summen und Zeilenanfang schreiben
              #
              if ($oldminame != $tmp_miname || $oldphase != $tmp_phase ||
                  $oldname != $tmp_taname) {
                 # Aktuelle Zeile vervollstaendigen (nur wenn eine Zeile
                 # bereits geschrieben wurde).
                 #
                 if (!$first) {
                    while ($adate <= $ldate) {
                       Cell($class, 0, 0, true);

                       if ($class == "selltgray")
                          $class = "selgray";
                       else
                          $class = "selltgray";

                       $adate = IncDate($periode, $adate);
                    }

                    ZSum($sumlis, $sumlpl);
                    echo "</tr>\n";
                 }

                 if (!$first && $oldminame != $tmp_miname) {
                    $cp = $csp - 3;
                    # Monatssummen nach einem Mitarbeiterwechsel
                    #
                    if ($fields_0 > 0 || $fields_6 > 0 && $fields_1 > 0 && $fields_2 > 0)
                       echo "<tr><td class=\"selnum\" colspan=$cp><b>Zwischensumme:</b></td>";

                    $adate = $fdate;
                    $per = 0;
                    $sumi = 0.0;
                    $sump = 0.0;

                    while ($adate <= $ldate) {
                       if ($fields_0 > 0 || $fields_6 > 0 && $fields_1 > 0 && $fields_2 > 0)
                          Cell("lsum", $sumperi[$per], $sumperp[$per]);

                       $adate = IncDate($periode, $adate);
                       $sumi += $sumperi[$per];
                       $sump += $sumperp[$per];
                       $sumperi[$per] = 0.0;
                       $sumperp[$per] = 0.0;
                       $per++;
                    }

                    if ($fields_0 > 0 || $fields_6 > 0 && $fields_1 > 0 && $fields_2 > 0) {
                       Zsum($sumi, $sump);
                       echo "\n";
                    }
                 }

                 # Beginn der Zeile: Schreiben der ersten fixen Zellen.
                 #
                 echo "<tr><td class=\"selltgray\">$mi_nname $mi_vname</td>\n";

                 if ($fields_2 > 0)
                    echo "<td class=\"selltgray\">$kl_land</td>\n";

                 if ($phase && $fields_6 > 0) {
                    echo "<td class=\"selltgray\">";

                    if ($tmp_status == 0)
                       echo "$tmp_phase: $kp_phase";
                    else
                       echo "&nbsp;";

                    echo "</td>\n";
                 }

                 if ($fields_0 > 0)
                    echo "<td class=\"selltgray\">$tmp_taname</td>\n";

                 if ($fields_1 > 0)
                    echo "<td class=\"selltgray\">$tmp_notiz</td>\n";

                 # Variablen initialisieren...
                 #
                 $sumlis = 0.0;
                 $sumlpl = 0.0;
                 $per = 0;
                 $adate = $fdate;
                 $oldminame = $tmp_miname;
                 $oldphase = $tmp_phase;
                 $oldname = $tmp_taname;
                 $first = false;
                 $class = "selltgray";
              }

              # Stimmt die aktuelle Position nicht mit der Periode ueberein,
              # uebergehen wir die Zellen.
              #
              while ($adate < $tmp_periode) {
                 Cell($class, 0, 0, true);

                 if ($class == "selltgray")
                    $class = "selgray";
                 else
                    $class = "selltgray";

                 $adate = IncDate($periode, $adate);
                 $per++;
              }

              # Schreiben einer Zelle mit den aktuellen Werten.
              Cell($class, $tmp_ist, $tmp_plan);

              if ($class == "selltgray")
                 $class = "selgray";
              else
                 $class = "selltgray";

              $sumperp[$per] += $tmp_plan;
              $sumperi[$per] += $tmp_ist;
              $totalis[$per] += $tmp_ist;
              $totalpl[$per] += $tmp_plan;
              $sumlpl += $tmp_plan;
              $sumlis += $tmp_ist;
              $adate = IncDate($periode, $adate);
              $per++;
              $rows++;
           }

           # Beenden der letzten Datenzeile der aktuellen Tabelle.
           #
           while ($adate <= $ldate) {
              Cell($class, 0, 0, true);

              if ($class == "selltgray")
                 $class = "selgray";
              else
                 $class = "selltgray";

              $adate = IncDate($periode, $adate);
           }

           ZSum($sumlis, $sumlpl);
           # Summenzeile am Ende der Tabelle fuer den letzten Mitarbeiter
           # anzeigen.
           #
           $cp = 1;

           if ($fields_0 > 0)
              $cp++;

           if ($fields_1 > 0)
              $cp++;

           if ($fields_2 > 0)
              $cp++;

           if ($fields_6 > 0)
              $cp++;

           if (($fields_0 > 0 || $fileds_1 > 0 || $fileds_2 > 0 || $fields_6 > 0) && $mi_num == 0) {
              echo "<tr><td class=\"selnum\" colspan=$cp><b>Zwischensumme:</b></td>";
              $adate = $fdate;
              $per = 0;
              $sumi = 0.0;
              $sump = 0.0;

              while ($adate <= $ldate) {
                 Cell("seldkgray", $sumperi[$per], $sumperp[$per]);
                 $adate = IncDate($periode, $adate);
                 $sumi += $sumperi[$per];
                 $sump += $sumperp[$per];
                 $sumperi[$per] = 0.0;
                 $sumperp[$per] = 0.0;
                 $per++;
              }

              ZSum($sumi, $sump);
           }

           # Monatssummen und Gesamtzeitraumsumme am Ende der Tabelle
           # anzeigen.
           #
           echo "<tr><td class=\"selnum\" colspan=$cp><b>Monatssummen:</b></td>";
           $adate = $fdate;
           $per = 0;
           $sumi = 0.0;
           $sump = 0.0;

           while ($adate <= $ldate) {
              Cell("seldkgray", $totalis[$per], $totalpl[$per]);
              $adate = IncDate($periode, $adate);
              $sumi += $totalis[$per];
              $sump += $totalpl[$per];
              $per++;
           }

           Cell("two", $sumi, $sump);
           echo "</tr>\n</table><br>\n";
           $pospr++;
        }
}

# Folgende Funktion erzeugt die Liste fuer einen oder mehreren Mitarbeitern.
# Die Liste sortiert nach Mitarbeitern und Projekten.
#
function MitarbeiterPj($db, $mi_num, $prp_num=0) {
        global $periode;
        global $phase;
//      $pl_num = $_REQUEST['pl_num'];
        $dfrom = $_REQUEST['dfrom'];
        $dto = $_REQUEST['dto'];
        $fields_0 = $_REQUEST['fields_0'];
        $fields_1 = $_REQUEST['fields_1'];
        $fields_2 = $_REQUEST['fields_2'];
        $fields_3 = $_REQUEST['fields_3'];
        $fields_4 = $_REQUEST['fields_4'];
        $fields_5 = $_REQUEST['fields_5'];
        $fields_6 = $_REQUEST['fields_6'];
        $sort = $_REQUEST['sort'];
        $level = $_REQUEST['level'];
        $pjclosed = $_REQUEST['pjclosed'];

//      if (isset($pjclosed) && $pjclosed == "true")
        if (isset($pjclosed) && CheckTrue($pjclosed))
           $pjc = ",6";

        # Beim bis-Datum den Monatsletzten ermitteln
        $mon = gmdate("n", $dto);
        $year = gmdate("Y", $dto);
        $day = daysinmonth($mon, $year);
        $dto = gmmktime(23, 59, 59, $mon, $day, $year);
        # Auslesen der Mitarbeiter. In einer Schleife werden die Daten
        # fuer jeden Mitarbeiter erstellt und pro Projekt angezeigt.
        #
        $query = "select mi_num, mi_nname, mi_vname, kl_land, ka_abt ";
        $query .= "from mitarbeiter, key_land, key_abt where ";
        $query .= "kl_num = mi_land and ka_num = mi_abt ";

        if ($mi_num > 0)
           $query .= "and mi_num = $mi_num ";

        $query .= "order by mi_nname, mi_vname";
        $resmi = QueryDB($db, $query);

        if (!$resmi)
           return;

        $nummi = numrowsDB($resmi);
        $posmi = 0;

        $pdiff = $fields_3;
        $pist = $fields_4;
        $pplan = $fields_5;
        $mult = 0;

        if ($pist > 0)
           $mult++;

        if ($pplan > 0)
           $mult++;

        if ($pplan > 0 && $pdiff > 0)
           $mult++;

        $csp = 4;

        if ($fields_6 > 0)
           $csp++;

        if ($fields_0 > 0)
           $csp++;

        if ($fields_1 > 0)
           $csp++;

        # Die Anzahl der Perioden ergibt sich aus der Auswahl. Die
        # Mitarbeitersicht besteht aus einer einzigen Tabelle in der
        # alle Daten angezeigt werden und mit Zwischensummen versehen
        # werden.
        # In der folgenden Schleife wird die Anzahl der Perioden
        # ermittelt.
        #
        $adate = $dfrom;
        $numper = 0;

        while ($adate <= $dto) {
           $adate = IncDate($periode, $adate);
           $numper++;
        }

        $np = $numper * $mult;
        $TempTable = false;
        echo "<table class=\"sel\">";

        while ($posmi < $nummi) {
           $data = fetchDB($resmi, $posmi);
           $mi_num = $data[0];
           $mi_nname = $data[1];
           $mi_vname = $data[2];
           $kl_land = $data[3];
           $ka_abt = $data[4];

           # Pruefen ob der Mitarbeiter in irgend einem Projekt im gewaehlten
           # Zeitraum geplant ist.
           if ($prp_num > 0) {
              $query = "select count(*) from allocation, task, plan where ";
              $query .= "ta_num = al_task and pl_num = ta_plnum and ";
              $query .= "pl_prnum = $prp_num and pl_status in (0,2,3,4,5 $pjc) and ";
           } else {
              $query = "select count(*) from allocation, task, plan where ";
              $query .= "ta_num = al_task and pl_num = ta_plnum and ";
              $query .= "pl_status in (0,2,3,4,5 $pjc) and ";
           }

           $query .= "al_ressource = $mi_num and al_pstart between $dfrom and $dto";
           $result = QueryDB($db, $query);

           if (!$result)
              return;

           $data = fetchDB($result, 0);
           $anzp = $data[0];

           # Pruefen ob es auch keine IST-Buchungen fuer den fraglichen
           # Zeitraum gegeben hat.
           $query = "select count(*) from wdone, plan where ";
           $query .= "pl_prnum = wd_prnum and pl_status in (0,2,3,4,5 $pjc) and ";
           $query .= "wd_datum between $dfrom and $dto and ";
           $query .= "wd_minum = $mi_num ";

           if ($prp_num > 0)
              $query .= "and wd_prnum = $prp_num";

           if (!($result = QueryDB($db, $query)))
              return;

           $data = fetchDB($result, 0);
           $anzi = $data[0];

           if ($anzp < 1 && $anzi < 1) {
              $posmi++;
              continue;
           }

           # Zeichnen des Tabellenkopfs
           # Bei jedem Mitarbeiterwechsel wird ein neuer Tabellenkopf
           # gezeichnet.
           #
           $c = $csp + $np;
           echo "<tr><td class=\"sel\" colspan=$c>";
           echo "<table border=0 cellpadding=0><tr><td>Name:</td><td>$mi_nname $mi_vname</td></tr>\n";
           echo "<tr><td>Gruppe:</td><td>$kl_land</td></tr>\n";

           if (!$pmlight)
              echo "<tr><td>Abteilung:</td><td>$ka_abt</td></tr>\n";

           echo "</table></td></tr>\n";
           $c = $csp - 3;
           echo "<tr><td class=\"sel\" colspan=$c>&nbsp;</td>\n";
           $r = 0;
           $adate = $dfrom;

           while ($r < $numper) {
              $p = gmdate("n/Y", $adate);
              echo "<th colspan=$mult class=\"sel\">$p</th>\n";
              $adate = IncDate($periode, $adate);
              $r++;
           }

           echo "<th colspan=$mult class=\"sel\">Summen</th></tr>\n";
           echo "<tr><th class=\"sel\">Projekt</th>";

           if ($phase && $fields_6 > 0)
              echo "<th class=\"sel\">Phase</th>";

           if ($fields_0 > 0)
              echo "<th class=\"sel\">Tasks</th>";

           if ($fields_1 > 0)
              echo "<th class=\"sel\">Anmerkungen</th>";

           $r = 0;

           while ($r <= $numper) {
              if ($pist > 0)
                 echo "<td class=\"selinfo_l\" align=\"center\"><b>IST</b></td>\n";

              if ($pplan > 0 && $pdiff > 0)
                 echo "<td class=\"selinfo\" align=\"center\"><b>Diff.</b></td>\n";

              if ($pplan > 0)
                 echo "<td class=\"selinfo_r\" align=\"center\"><b>Plan</b></td>\n";

              $r++;
           }

           echo "</tr>\n";

           # Projekte waehlen, in denen der Mitarbeiter geplant ist.
           #
           # Wurde kein bestimmter Mitarbeiter gewählt, werden immer alle
           # Mitarbeiter angezeigt. Es werden grundsätzlich alle Projekte
           # angezeigt in denen der Mitarbeiter geplant ist oder wo er
           # IST-Werte hat (das eine bedingt das andere!).
           #
           $query = "select distinct on (pr_num) pr_num, pr_name, pl_num, pl_status from ";
           $query .= "project left join plan on pl_prnum = pr_num ";
           $query .= "where pl_status in (0,2,3,4,5 $pjc) ";

           if ($prp_num > 0)
              $query .= "and pr_num = $prp_num ";

           $query .= "order by pr_num asc, pl_lfd desc";
           $respr = QueryDB($db, $query);

           if (!$respr)
              return;

           $numpr = numrowsDB($respr);
           $pospr = 0;
           $old_prnum = 0;
           $pr_flag = false;    // Zwischensumme schreiben

           while ($pospr < $numpr) {
              $data = fetchDB($respr, $pospr);
              $pr_num = $data[0];
              $pr_name = $data[1];
              $pl_num = $data[2];
              $pl_status = $data[3];

              # Pruefen ob fuer den fraglichen Zeitraum Plantage oder
              # IST-Daten vorhanden sind.
              $query = "select count(*) from allocation, task, plan where ";
              $query .= "ta_num = al_task and pl_num = ta_plnum and ";
              $query .= "pl_prnum = $pr_num and al_ressource = $mi_num and ";
              $query .= "al_pstart between $dfrom and $dto and pl_status in (0,2,3,4,5 $pjc)";

              if (!($resco = QueryDB($db, $query)))
                 return;

              $data = fetchDB($resco, 0);
              $anzp = $data[0];

              $query = "select count(*) from wdone where ";
              $query .= "wd_minum = $mi_num and wd_prnum = $pr_num and ";
              $query .= "wd_datum between $dfrom and $dto";

              if (!($resco = QueryDB($db, $query)))
                 return;

              $data = fetchDB($resco, 0);
              $anzi = $data[0];

              # Keine Plan- und IST-Daten? Wenn keine Daten, dann das
              # Projekt ueberspringen.
              if ($anzp == 0 && $anzi == 0) {
                 $pospr++;
                 continue;
              }

              # Falls die temporaere Tabelle existiert, loeschen wir sie.
              if ($TempTable)
                 TQueryDB($db, "drop table TempPlan");

              $TempTable = true;
              # Plan erstellen --> tempplan.inc
              if (!CreateTempPlan($db, $pl_num, $pr_num, $dfrom, $dto, true, $mi_num, true)) {
                 $pospr++;
                 continue;
              }

              # Wurden in der temporaeren Tabelle ueberhaupt Datensaetze
              # abgelegt?
              $query = "select count(*) from TempPlan";

              if (!($resanz = QueryDB($db, $query)))
                 return;

              $data = fetchDB($resanz, 0);

              if ($data[0] <= 0) {
                 $pospr++;
                 continue;
              }

              $c = $csp + $np;
              $pr_flag = true;

              # Tabelleninhalt schreiben:
              # Die Inhalte werden der zuvor temporaer erzeugten Tabelle
              # entnommen.
              #
              if ($fields_0 <= 0) {
                 $query = "select sum(tmp_plan), sum(tmp_ist), tmp_periode ";

                 if ($fields_6 > 0)
                    $query .= ", tmp_phase ";

                 $query .= "from TempPlan group by ";

                 if ($fields_6 > 0)
                    $query .= "tmp_phase, ";

                 $query .= "tmp_periode order by ";

                 if ($fields_6 > 0)
                    $query .= "tmp_phase, ";

                 $query .= "tmp_periode";
              } else {
                 $query = "select tmp_phase, tmp_periode, tmp_plan, tmp_ist,";
                 $query .= "tmp_taname, tmp_notiz, kp_phase, tmp_hash ";
                 $query .= "from TempPlan, key_phase where ";
                 $query .= "kp_num = tmp_phase ";
                 $query .= "order by ";

                 if ($phase)
                    $query .= "tmp_phase, ";

                 if ($fields_0 > 0 )
                    $query .= "tmp_taname, ";

                 $query .= "tmp_periode";
              }

              if (!($result = QueryDB($db, $query)))
                 return;

              $numrows = numrowsDB($result);
              $rows = 0;
              $oldphase = -1;
              $oldname = "";
              $sumlpl = 0.0;
              $sumlis = 0.0;
              $per = 0;
              $first = true;
              $adate = $dfrom;
              $class = "selltgray";

              while ($rows < $numrows) {
                 $data = fetchDB($result, $rows);

                 if ($fields_0 > 0) {
                    $tmp_phase = $data[0];
                    $tmp_periode = $data[1];
                    $tmp_plan = $data[2];
                    $tmp_ist = $data[3];
                    $tmp_taname = $data[4];
                    $tmp_notiz = $data[5];
                    $kp_phase = $data[6];
                    $tmp_hash = $data[7];
                 } else {
                    $tmp_plan = $data[0];
                    $tmp_ist = $data[1];
                    $tmp_periode = $data[2];

                    if ($fields_6 > 0) {
                       $tmp_phase = $data[3];

                       $query = "select kp_phase from key_phase where kp_num = $tmp_phase";

                       if (!($reskp = QueryDB($db, $query)))
                          return;

                       if (numrowsDB($reskp) > 0) {
                          $d = fetchDB($reskp, 0);
                          $kp_phase = $d[0];
                       } else
                          $kp_phase = "";
                    } else
                       $tmp_phase = 0;

                    $tmp_taname = "";
                    $tmp_notiz = "";
                    $tmp_hash = "";
                 }

                 # Summen und Zeilenanfang schreiben
                 #
                 if ($oldphase != $tmp_phase || $oldname != $tmp_taname) {
                    # Aktuelle Zeile vervollstaendigen (nur wenn eine Zeile
                    # bereits geschrieben wurde).
                    #
                    if (!$first) {
                       while ($adate <= $dto) {
                          Cell($class, 0, 0, true);

                          if ($class == "selltgray")
                             $class = "selgray";
                          else
                             $class = "selltgray";

                          $adate = IncDate($periode, $adate);
                       }

                       ZSum($sumlis, $sumlpl);
                       echo "</tr>\n";
                    }

                    $cp = $csp - 3;
                    # Beginn der Zeile: Schreiben der ersten fixen Zellen.
                    #
                    echo "<tr><td class=\"sel\">$pr_num $pr_name</td>\n";

                    if ($phase && $fields_6 > 0)
                       echo "<td class=\"sel\">$tmp_phase: $kp_phase</td>\n";

                    if ($fields_0 > 0)
                       echo "<td class=\"sel\">$tmp_taname</td>\n";

                    if ($fields_1 > 0)
                       echo "<td class=\"sel\">$tmp_notiz</td>\n";

                    # Variablen initialisieren...
                    #
                    $sumlis = 0.0;
                    $sumlpl = 0.0;
                    $per = 0;
                    $adate = $dfrom;
                    $oldphase = $tmp_phase;
                    $oldname = $tmp_taname;
                    $first = false;
                    $class = "selltgray";
                 }

                 # Stimmt die aktuelle Position nicht mit der Periode ueberein,
                 # uebergehen wir die Zellen.
                 #
                 while ($adate < $tmp_periode) {
                    Cell($class, 0, 0, true);

                    if ($class == "selltgray")
                       $class = "selgray";
                    else
                       $class = "selltgray";

                    $adate = IncDate($periode, $adate);
                    $per++;
                 }

                 # Schreiben einer Zelle mit den aktuellen Werten.
                 Cell($class, $tmp_ist, $tmp_plan, false);

                 if ($class == "selltgray")
                    $class = "selgray";
                 else
                    $class = "selltgray";

                 $sumperp[$per] += $tmp_plan;
                 $sumperi[$per] += $tmp_ist;
                 $totalis[$per] += $tmp_ist;
                 $totalpl[$per] += $tmp_plan;
                 $mitoti[$per] += $tmp_ist;
                 $mitotp[$per] += $tmp_plan;
                 $sumlpl += $tmp_plan;
                 $sumlis += $tmp_ist;
                 $adate = IncDate($periode, $adate);
                 $per++;
                 $rows++;
              }

              # Beenden der der letzten Datenzeile der aktuellen Tabelle.
              #
              while ($adate <= $dto) {
                 Cell($class, 0, 0, true);

                 if ($class == "selltgray")
                    $class = "selgray";
                 else
                    $class = "selltgray";

                 $adate = IncDate($periode, $adate);
              }

              ZSum($sumlis, $sumlpl);
              echo "</tr>\n";
              $cp = $csp - 3;

              if ($prp_num == 0 && $numpr > 1 && ($fields_0 || $fields_6)) {
                 echo "<tr><td class=\"selnum\" colspan=$cp><b>Projektsumme:</b></td>";
                 $adate = $dfrom;
                 $per = 0;
                 $sumi = 0.0;
                 $sump = 0.0;

                 while ($adate <= $dto) {
                    Cell("lsum", $sumperi[$per], $sumperp[$per]);
                    $adate = IncDate($periode, $adate);
                    $sumi += $sumperi[$per];
                    $sump += $sumperp[$per];
                    $sumperi[$per] = 0.0;
                    $sumperp[$per] = 0.0;
                    $per++;
                 }

                 Zsum($sumi, $sump);
                 echo "</tr>\n";
              }

              $pospr++;
           }

           $cp = $csp - 3;
           echo "<tr><td class=\"selnum\" colspan=$cp><b>Gesamtsumme Mitarbeiter:</b></td>";
           $adate = $dfrom;
           $per = 0;
           $sumi = 0.0;
           $sump = 0.0;

           while ($adate <= $dto) {
              Cell("seldkgray", $mitoti[$per], $mitotp[$per]);
              $adate = IncDate($periode, $adate);
              $sumi += $mitoti[$per];
              $sump += $mitotp[$per];
              $mitoti[$per] = 0.0;
              $mitotp[$per] = 0.0;
              $per++;
           }

           Zsum($sumi, $sump);
           echo "</tr>\n";
           $posmi++;
        }

        # Monatssummen und Gesamtzeitraumsumme am Ende der Tabelle
        # anzeigen.
        #
        if ($mi_num == 0) {
           echo "<tr><td class=\"selnum\" colspan=$cp><b>Monatssummen:</b></td>";
           $adate = $dfrom;
           $per = 0;
           $sumi = 0.0;
           $sump = 0.0;

           while ($adate <= $dto) {
              Cell("sum", $totalis[$per], $totalpl[$per]);
              $adate = IncDate($periode, $adate);
              $sumi += $totalis[$per];
              $sump += $totalpl[$per];
              $per++;
           }

           Cell("two", $sumi, $sump);
           echo "</tr>\n";
        }

        echo "</table><br>\n";
}

# Folgende Funktion wertet die vom Anwender getroffenen Einstellungen aus
# und ruft die entsprechenden Funktionen auf um die Listen darzustellen.
#
function PrintList() {
        global $phase;
        global $pmlight;
        $pl_num = $_REQUEST['pl_num'];
        $mi_num = $_REQUEST['mi_num'];
        $dfrom = $_REQUEST['dfrom'];
        $dto = $_REQUEST['dto'];
        $fields_0 = $_REQUEST['fields_0'];
        $fields_1 = $_REQUEST['fields_1'];
        $fields_2 = $_REQUEST['fields_2'];
        $fields_3 = $_REQUEST['fields_3'];
        $fields_4 = $_REQUEST['fields_4'];
        $fields_5 = $_REQUEST['fields_5'];
        $fields_6 = $_REQUEST['fields_6'];
        $sort = $_REQUEST['sort'];
        $level = $_REQUEST['level'];
        $pjclosed = $_REQUEST['pjclosed'];

        if (isset($pjclosed) && CheckTrue($pjclosed))
           $pjc = ",6";

        # Als erstes pruefen wir, ob die wichtigen Parameter auch korrekt
        # gesetzt wurden.
        if ($dfrom > $dto) {
           Error("Das Beginndatum darf nicht h&ouml;her sein als das Endedatum!");
           return;
        }

        $db = OpenDB();
        # In einem ersten Schritt zeichnen wir eine Box in der die gewaehlten
        # Parameter angezeigt werden:
        #
        echo "<table class=\"input\">\n";
        echo "<tr><td><table border=0 cellpadding=0 cellspacing=0>\n";

        if ($pl_num == 0) {
           echo "<tr><td>Projekt:</td><td>";
           echo "Alle";
        } else {
           $query = "select pl_prnum, pr_name, pr_status from plan, project ";
           $query .= "where pr_num = pl_prnum and pl_num = $pl_num";
           $result = QueryDB($db, $query);

           if (!$result) {
              closeDB($db);
              return;
           }

           $data = fetchDB($result, 0);
           $pr_num = $data[0];
           $pr_name = $data[1];
           $pr_status = $data[2];

           if ($pr_status == 0)
              echo "<tr><td>Projekt:</td><td>";
           else
              echo "<tr><td>Konto:</td><td>";

           echo "$pr_num $pr_name";
        }

        echo "</td></tr>\n";
        echo "<tr><td>Mitarbeiter:</td><td>";

        if ($mi_num == 0) {
           echo "Alle";
        } else {
           $query = "select mi_nname, mi_vname from mitarbeiter where mi_num = $mi_num";
           $result = QueryDB($db, $query);

           if (!$result) {
              closeDB($db);
              return;
           }

           $data = fetchDB($result, 0);
           $mi_nname = $data[0];
           $mi_vname = $data[1];
           echo "$mi_nname $mi_vname";
        }

        echo "</td></tr>\n";
        echo "<tr><td>Zeitraum:</td><td class=\"selnf\">";
        echo "Von: " . gmdate("n.Y", $dfrom) . " ";
        echo "Bis: " . gmdate("n.Y", $dto);
        echo "</td></tr>\n";

        echo "<tr><td valign=\"top\">Spaltenauswahl:</td>\n";
        echo "<td class=\"selnf\">";

        if ($fields_2 > 0)
           echo "Gruppe<br>\n";

        if ($fields_6 > 0)
           echo "Phasen<br>\n";

        if ($fields_0 > 0)
           echo "Tasks anzeigen<br>\n";

        if ($fields_1 > 0)
           echo "Anmerkungen<br>\n";

        if ($fields_4 > 0)
           echo "IST-Werte<br>\n";

        if ($fields_3 > 0)
           echo "IST- / Plandifferenz<br>\n";

        if ($fields_5 > 0)
           echo "Planwerte<br>\n";

        echo "</td></tr>\n";

        echo "<tr><td>Sortierreihenfolge:</td><td>\n";

        if ($sort == 1)
           echo "Projekte / Mitarbeiter";
        else
           echo "Mitarbeiter / Projekte";

        echo "</td></tr>\n";

/*      echo "<tr><td>Plantiefe:</td><td>\n";

        if ($level == -1)
           echo "Alle";
        else
           echo "Bis zu Level $level";

        echo "</td></tr>\n"; */
        echo "</table></td></tr></table><br>\n";

        if ($sort == 1)
           ProjektMa($db, $pr_num, $mi_num);
        else
           MitarbeiterPj($db, $mi_num, $pr_num);

        closeDB($db);
}

# Auswertung des Menues:
#
if ($knopf == 27)               // Ressourcenauslastung
   Preselect();

if ($func == "repeatpj")
   Preselect(1);

# Auswertung der Funktionen
if ($func == "prlist") {
   $pl_num = $_REQUEST['pl_num'];
   $mi_num = $_REQUEST['mi_num'];
   $dfrom = $_REQUEST['dfrom'];
   $dto = $_REQUEST['dto'];
   $fields_0 = $_REQUEST['fields_0'];
   $fields_1 = $_REQUEST['fields_1'];
   $fields_2 = $_REQUEST['fields_2'];
   $fields_3 = $_REQUEST['fields_3'];
   $fields_4 = $_REQUEST['fields_4'];
   $fields_5 = $_REQUEST['fields_5'];
   $fields_6 = $_REQUEST['fields_6'];
   $sort = $_REQUEST['sort'];
   $level = $_REQUEST['level'];
   $pjclosed = $_REQUEST['pjclosed'];

   echo "<table class=\"indent\"><tr><td>";

   if (!$pmlight) {
      ButtonPrint(GetMessage(-1, 383, "Drucken"), "auswertung.php",
      "pl_num=$pl_num&dfrom=$dfrom&dto=$dto&fields_0=$fields_0" .
      "&fields_1=$fields_1&fields_2=$fields_2&fields_3=$fields_3" .
      "&fields_4=$fields_4&fields_5=$fields_5&fields_6=$fields_6" .
      "&mi_num=$mi_num&sort=$sort&level=$level&header=2&pjclosed=$pjclosed&" .
      "func=pauswertung"); //', 'Auswertung', 1000, 650)");
      echo "</td><td>";
      $bt_text = GetMessage(-1, 384, "PDF-Ausgabe");
   } else
      $bt_text = GetMessage(-1, 383, "Drucken");

   ButtonPrint($bt_text, "auswertpdf.php",
   "pl_num=$pl_num&dfrom=$dfrom&dto=$dto&fields_0=$fields_0" .
   "&fields_1=$fields_1&fields_2=$fields_2&fields_3=$fields_3" .
   "&fields_4=$fields_4&fields_5=$fields_5&fields_6=$fields_6" .
   "&mi_num=$mi_num&sort=$sort&level=$level&header=2&&pjclosed=$pjclosed&" .
   "func=pauswertung", true);
   echo "</td></tr></table>";
   PrintList();
}

if ($func == "pauswertung") {
   PrintList();
}

require('footer.inc');
?>