Subversion Repositories public

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 andreas 1
<?
2
require_once('version.inc');
3
require_once('dbaccess.inc');
4
require_once('language.inc');
5
require_once('header.inc');
6
require_once('helper.inc');
7
require_once('crypt.inc');
8
require_once('settings.inc');
9
 
10
$knopf = 0;
11
$func = $_REQUEST['func'];
12
 
13
# Auswertungsmenue
14
if (isset($_REQUEST['auswertung'])) { $knopf = 27; $headline = 31; }
15
 
16
$drm = array(true, false, false, false, false, true, false);
17
 
18
require_once('menu.inc');
19
require_once('knumber.inc');
20
require_once('tempplan.inc');
21
 
22
# This module contains the following functions:
23
#    Preselect
24
#    ZSum
25
#    Cell
26
#    ProjektMa
27
#    MitarbeiterPj
28
#    PrintList
29
 
30
# Folgende Funktion erlaubt die Auswahl einiger Voreinstellungen und
31
# Einschraenkungen fuer den Statusbericht.
32
#
33
function Preselect($repeat=0) {
34
	global $periode;
35
	global $phase;
36
	global $menu;
37
	global $unum;
38
	global $pmlight;
39
 
40
	$db = OpenDB();
41
	$pjclosed = $_REQUEST['pjclosed'];
42
	$nav = "mi_num='+wahl.mi_num.value+'&sort1='+wahl.sort[0].checked+'";
43
	$nav .= "&sort2='+wahl.sort[1].checked+'&pjclosed='+wahl.pjclosed.checked+'&menu=$menu&headline=31";
44
 
45
	if ($repeat == 1)
46
	   $plnum = $_REQUEST['pl_num'];
47
 
48
	if (!isset($pjclosed) || CheckTrue($pjclosed))
49
	   $pjclosed = true;
50
	else
51
	   $pjclosed = false;
52
 
53
	$prnum = 0;
54
	# Folgende Maske zeigt zwei ineinander verschachtelte Tabellen
55
	# um die einzelnen Wahlelemente optisch voneinader zu trennen.
56
?>
57
<form name="wahl" action="auswertung.php" method="post">
58
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
59
<input type="hidden" name="headline" value="31">
60
<input type="hidden" name="func" value="prlist">
61
 
62
<table class="sel">
63
<tr><th class="sel" colspan=2><? Output($db, 316, "Projektauswahl"); ?></th></tr>
64
<tr><td>
65
<?php
66
	# Auswahl eines freigegebenen oder fertigen Projekts.
67
	# Nicht in der light version!
68
	if (!$pmlight) {
69
	   Output($db, 317, "Abgeschlossene Projekte:");
70
	   echo "</td>\n";
71
	   echo "<td><input type=\"checkbox\" name=\"pjclosed\" value=\"1\" ";
72
 
73
	   if ($pjclosed)
74
	     echo "checked ";
75
 
76
	   echo "onChange=\"javascript:MoveTo('auswertung.php','func=repeatpj&$nav')\">&nbsp;";
77
	   Output($db, 318, "In Auswahlliste anzeigen");
78
	   echo "</td></tr><tr><td>\n";
79
	} else {
80
	   echo "<input type=\"hidden\" name=\"pjclosed\" value=\"1\">\n";
81
	}
82
 
83
	echo GetMessage($db, 319, "Projekte:") . "</td>\n";
84
	echo "<td>";
85
 
86
	$query = "select distinct on (pl_prnum) pl_num, pl_prnum, pl_lfd, pr_name, pl_status from plan, project ";
87
	$query .= "where pr_num = pl_prnum and pl_status in (0,2,4";
88
 
89
	if ($pjclosed)
90
	   $query .= ",6";
91
 
92
	$query .= ") ";
93
	$query .= "order by pl_prnum, pl_lfd desc";
94
 
95
	$result = QueryDB($db, $query);
96
 
97
	if (!$result) {
98
	   closeDB($db);
99
	   return;
100
	}
101
 
102
	echo "<select name=\"pl_num\" ";
103
	echo "onchange=\"javascript:MoveTo('auswertung.php', ";
104
	echo "'func=repeatpj&pl_num='+this.value+'&$nav')\">\n";
105
	$numrows = numrowsDB($result);
106
	$rows = 0;
107
 
108
	while ($rows < $numrows) {
109
	   $data = fetchDB($result, $rows);
110
	   $pl_num = $data[0];
111
	   $pl_prnum = $data[1];
112
	   $pl_lfd = $data[2];
113
	   $pr_name = $data[3];
114
	   $pl_status = $data[4];
115
 
116
	   if ($rows == 0) {
117
	      $a = GetMessage($db, 241, "Alle");
118
 
119
	      if (isset($plnum) && $plnum == 0)
120
	         echo "<option value=\"0\" selected>$a</option>\n";
121
	      else
122
	         echo "<option value=\"0\">$a</option>\n";
123
	   }
124
 
125
	   if ($pl_status == 1)
126
	      $vz = "*:";		// Kommt nie vor!!
127
	   else if ($pl_status == 6)
128
	      $vz = GetMessage($db, 320, "Abgeschl.:");	// Abgeschlossen
129
	   else if ($pl_status == 0)
130
	      $vz = GetMessage($db, 321, "Konto:");		// Konto
131
	   else
132
	      $vz = GetMessage($db, 1, "Projekt:");		// Projekt
133
 
134
	   if (isset($plnum) && $plnum == $pl_num) {
135
	      echo "<option value=\"$pl_num\" selected>$vz $pl_prnum $pr_name</option>\n";
136
	      $prnum = $pl_prnum;
137
	      $akt_status = $pl_status;
138
	   } else
139
	      echo "<option value=\"$pl_num\">$vz $pl_prnum $pr_name</option>\n";
140
	   $rows++;
141
	}
142
 
143
	echo "</select></td></tr>\n";
144
	# Mitarbeiterauswahl
145
	echo "<tr><th class=\"sel\" colspan=2>" . GetMessage($db, 322, "Mitarbeiterauswahl") . "</th></tr>\n";
146
	echo "<tr><td>" . GetMessage($db, 305, "Mitarbeiter:") . "</td>";
147
	echo "<td>\n";
148
 
149
 
150
	if ($repeat == 1 && isset($plnum) && $plnum > 0) {
151
//	   $query = "select distinct wd_minum, mi_nname, mi_vname from ";
152
//	   $query .= "wdone, mitarbeiter, task, plan where mi_num = wd_minum and ";
153
//	   $query .= "wd_prnum = $prnum ";
154
	   $query = "select distinct al_ressource, mi_nname, mi_vname from ";
155
	   $query .= "allocation, mitarbeiter, task, plan where ";
156
	   $query .= "mi_num = al_ressource and ta_num = al_task and ";
157
	   $query .= "pl_num = ta_plnum and pl_prnum = $prnum "; //and mi_plan = true ";
158
	   $query .= "order by mi_nname, mi_vname";
159
	} else {
160
	   $query = "select mi_num, mi_nname, mi_vname from mitarbeiter ";
161
	   $query .= "where mi_plan = true order by mi_nname, mi_vname";
162
	}
163
 
164
	$result = QueryDB($db, $query);
165
 
166
	if (!$result) {
167
	   closeDB($db);
168
	   return;
169
	}
170
 
171
	echo "<select name=\"mi_num\">\n";
172
	echo "<option value=\"0\">" . GetMessage($db, 241, "Alle") . "</option>\n";
173
	$minum = $_REQUEST['mi_num'];
174
	$numrows = numrowsDB($result);
175
	$rows = 0;
176
 
177
	while ($rows < $numrows) {
178
	   $data = fetchDB($result, $rows);
179
	   $mi_num = $data[0];
180
	   $mi_nname = $data[1];
181
	   $mi_vname = $data[2];
182
 
183
	   if (!isset($minum) || $minum <= 0)
184
	      $minum = $unum;
185
 
186
	   if ($mi_num == $minum)
187
	      echo "<option selected value=\"$mi_num\">$mi_nname $mi_vname</option>\n";
188
	   else
189
	      echo "<option value=\"$mi_num\">$mi_nname $mi_vname</option>\n";
190
	   $rows++;
191
	}
192
 
193
	echo "</select></td></tr>\n";
194
 
195
	# Zeitraum
196
	echo "<tr><th class=\"sel\" colspan=2>" . GetMessage($db, 323, "Anzuzeigender Zeitraum") . "</th></tr>\n";
197
	echo "<tr><td>" . GetMessage($db, 306, "Zeitraum:") . "</td>\n";
198
	echo "<td>";
199
	$query = "select ta_start from task";
200
 
201
	if ($repeat == 1 && isset($plnum) && $plnum > 0)
202
	   $query .= " where ta_plnum = $plnum ";
203
 
204
	$query .= " order by ta_start";
205
	$result = QueryDB($db, $query);
206
 
207
	if (!$result) {
208
	   closeDB($db);
209
	   return;
210
	}
211
 
212
	$data = fetchDB($result, 0);
213
	$fdate = $data[0];
214
 
215
	$query = "select ta_start + (ta_duration * 86400) as ds from task";
216
 
217
	if ($repeat == 1 && isset($plnum) && $plnum > 0)
218
	   $query .= " where ta_plnum = $plnum ";
219
 
220
	$query .= " order by ds desc";
221
	$result = QueryDB($db, $query);
222
 
223
	if (!$result) {
224
	   closeDB($db);
225
	   return;
226
	}
227
 
228
	$data = fetchDB($result, 0);
229
	$ldate = $data[0];
230
 
231
	if ($repeat == 1 && isset($plnum) && $plnum > 0) {
232
	   $dfirst = $fdate;
233
	   $dlast = $ldate;
234
	} else {
235
	   $dt = time();
236
	   $mon = gmdate ("n", $dt);
237
	   $year = gmdate("Y", $dt);
238
 
239
	   if ($mon < 6)
240
	      $mon = 1;
241
	   else
242
	      $mon = 6;
243
 
244
	   $dfirst = gmmktime(0, 0, 0, $mon, 1, $year);
245
 
246
	   if ($ldate < $dt) {
247
	      $mon = gmdate("n", $ldate);
248
	      $year = gmdate("Y", $ldate);
249
	      $dlast = gmmktime(0, 0, 0, $mon, 1, $year);
250
	   }
251
	   else {
252
	      if ($mon == 1)
253
		 $mon = 6;
254
	      else if ($mon == 6)
255
		 $mon = 12;
256
 
257
	      $zw = gmmktime(0, 0, 0, $mon, 1, $year);
258
 
259
	      if ($zw <= $ldate)
260
	         $dlast = $zw;
261
	      else {
262
	         $mon = gmdate("n", $ldate);
263
	         $dlast = gmmktime(0, 0, 0, $mon, 1, $year);
264
	      }
265
	   }
266
	}
267
 
268
	$cd = $fdate;
269
 
270
	if (!isset($akt_status) || $akt_status > 0) {
271
	   echo GetMessage($db, 307, "Von:") . "&nbsp;<select name=\"dfrom\"";
272
 
273
	   if ($repeat == 1 && isset($akt_status) && $akt_status == 0)
274
	      echo " disabled";
275
 
276
	   echo ">\n";
277
	   $amon = gmdate("n", $dfirst);
278
	   $ayear = gmdate("Y", $dfirst);
279
 
280
	   while ($cd <= $ldate) {
281
	      $mon = gmdate("n", $cd);
282
	      $year = gmdate("Y", $cd);
283
	      $zw = gmmktime(0, 0, 0, $mon, 1, $year);
284
 
285
	      if ($mon == $amon && $year == $ayear)
286
	         echo "<option value=\"$zw\" selected>$mon.$year</option>\n";
287
	      else
288
	         echo "<option value=\"$zw\">$mon.$year</option>\n";
289
 
290
	      $cd = IncDate($periode, $zw);
291
	   }
292
 
293
	   echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;";
294
	}
295
 
296
	$cd = $fdate;
297
 
298
	if (!isset($akt_status) || $akt_status > 0) {
299
	   echo GetMessage($db, 308, "Bis:") . "&nbsp;<select name=\"dto\">\n";
300
 
301
	   $lmon = gmdate("n", $dlast);
302
	   $lyear = gmdate("Y", $dlast);
303
 
304
	   while ($cd <= $ldate) {
305
	      $mon = gmdate("n", $cd);
306
	      $year = gmdate("Y", $cd);
307
	      $zw = gmmktime(0, 0, 0, $mon, 1, $year);
308
 
309
	      if ($mon == $lmon && $year == $lyear)
310
		 echo "<option value=\"$zw\" selected>$mon.$year</option>\n";
311
	      else
312
	         echo "<option value=\"$zw\">$mon.$year</option>\n";
313
 
314
	      $cd = IncDate($periode, $zw);
315
	   }
316
	}
317
 
318
	echo "</select></td></tr>\n";
319
	# Anzeigenauswahl
320
	echo "<tr><th class=\"sel\" colspan=2>" . GetMessage($db, 324, "Anzeigenauswahl") . "</th></tr>\n";
321
	echo "<tr><td valign=\"top\">" . GetMessage($db, 309, "Spaltenauswahl:") . "</td>\n";
322
	echo "<td><table border=0><tr>";
323
	echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"1\" name=\"fields_0\">" . GetMessage($db, 310, "Tasks anzeigen") . "</td>\n";
324
	echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"2\" name=\"fields_1\">" . GetMessage($db, 294, "Anmerkungen") . "</td></tr><tr>\n";
325
	echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"3\" name=\"fields_2\">" . GetMessage($db, 291, "Gruppe") . "</td>\n";
326
	echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"4\" name=\"fields_3\" ";
327
	echo "onClick=\"javascript:if (document.wahl.fields_4.checked == false ||";
328
	echo "document.wahl.fields_5.checked == false) { this.checked = false; }\">" . GetMessage($db, 312, "IST- Plandifferenz") . "</td></tr><tr>\n";
329
	echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"5\" name=\"fields_4\" checked ";
330
	echo "onClick=\"javascript:if (this.checked == false) { document.wahl.fields_3.checked = false; } ";
331
	echo "if (this.checked == false && document.wahl.fields_5.checked == false) { this.checked = true; }\">" . GetMessage($db, 311, "IST-Werte") . "</td>\n";
332
	echo "<td class=\"selnf\"><input type=\"checkbox\" value=\"6\" name=\"fields_5\" checked ";
333
	echo "onClick=\"javascript:if (this.checked == false) { document.wahl.fields_3.checked = false; } ";
334
	echo "if (this.checked == false && document.wahl.fields_4.checked == false) { this.checked = true; }\">" . GetMessage($db, 313, "Planwerte") . "</td></tr>\n";
335
 
336
	if ($phase)
337
	   echo "<tr><td class=\"selnf\" colspan=2><input type=\"checkbox\" value=\"7\" name=\"fields_6\" checked>" . GetMessage($db, 292, "Phase") . "</td></tr>\n";
338
 
339
	echo "</table>\n";
340
	echo "</td></tr>\n";
341
 
342
	echo "<tr><td valign=\"top\">" . GetMessage($db, 304, "Sortierreihenfolge:") . "</td>\n";
343
 
344
	if ($_REQUEST['sort1'] == "true")
345
	   $sort = 1;
346
	else if ($_REQUEST['sort2'] == "true")
347
	   $sort = 2;
348
	else
349
	   $sort = 2;
350
 
351
	echo "<td>";
352
	echo "<input type=\"radio\" name=\"sort\" ";
353
 
354
	if ($sort == 1)
355
	   echo "checked ";
356
 
357
	echo "value=\"1\">" . GetMessage($db, 314, "Projekte / Mitarbeiter") . "<br>\n";
358
	echo "<input type=\"radio\" name=\"sort\" ";
359
 
360
	if ($sort == 2)
361
	   echo "checked ";
362
 
363
	echo "value=\"2\">" . GetMessage($db, 315, "Mitarbeiter / Projekte") . "\n";
364
	echo "</td></tr>\n";
365
 
366
/*	echo "<tr><td>Plantiefe:</td>\n";
367
	echo "<td>";
368
	echo "<select name=\"level\" disabled>\n";
369
	echo "<option value=\"-1\">Alle</option>\n";
370
	echo "<option value=\"0\">0</option>\n";
371
	echo "<option value=\"1\">1</option>\n";
372
	echo "<option value=\"2\">2</option>\n";
373
	echo "<option value=\"3\">3</option>\n";
374
	echo "<option value=\"4\">4</option>\n";
375
	echo "<option value=\"5\">5</option>\n";
376
	echo "<option value=\"6\">6</option>\n";
377
	echo "<option value=\"7\">7</option>\n";
378
	echo "<option value=\"8\">8</option>\n";
379
	echo "<option value=\"9\">9</option>\n";
380
	echo "</select></td></tr>\n";
381
*/
382
	echo "<tr><td class=\"selmid\" colspan=2>";
383
	ButtonSubmit(GetMessage($db, 325, "Senden"), "wahl");
384
//	echo "<input type=\"submit\" name=\"submit\" value=\"Senden\"> <input type=\"reset\">\n";
385
	echo "</td></tr></table>\n";
386
	echo "</form>\n";
387
	closeDB($db);
388
}
389
 
390
# Zeilensumme ausgeben
391
#
392
function ZSum($sumi, $sump) {
393
	$fields_3 = $_REQUEST['fields_3'];
394
	$fields_4 = $_REQUEST['fields_4'];
395
	$fields_5 = $_REQUEST['fields_5'];
396
 
397
	if ($fields_4 > 0)
398
	   echo "<td class=\"seldkgray\" align=\"right\">" . FormatNum($sumi, 3) . "</td>";
399
 
400
	if ($fields_3 > 0)
401
	   echo "<td class=\"seldkgray\" align=\"right\">" . FormatNum($sump - $sumi, 3) . "</td>";
402
 
403
	if ($fields_5 > 0)
404
	   echo "<td class=\"seldkgray\" align=\"right\">" . FormatNum($sump, 3) . "</td>";
405
 
406
	echo "\n";
407
}
408
 
409
# Schreiben einer Zelle
410
#
411
function Cell($class, $ist, $plan, $blank=false, $per=0) {
412
	$fields_3 = $_REQUEST['fields_3'];
413
	$fields_4 = $_REQUEST['fields_4'];
414
	$fields_5 = $_REQUEST['fields_5'];
415
 
416
	if ($fields_4 > 0) {
417
	   echo "<td class=\"$class\" align=\"right\">";
418
 
419
	   if ($blank)
420
	      echo "&nbsp;";
421
	   else
422
	      echo FormatNum($ist, 3);
423
 
424
	   if ($per > 0)
425
	      echo "<br>" . gmdate("n/Y", $per);
426
 
427
	   echo "</td>";
428
	}
429
 
430
	if ($fields_3 > 0) {
431
	   echo "<td class=\"$class\" align=\"right\">";
432
 
433
	   if ($blank)
434
	      echo "&nbsp;";
435
	   else
436
	      echo FormatNum($plan - $ist, 3);
437
 
438
	   echo "</td>";
439
	}
440
 
441
	if ($fields_5 > 0) {
442
	   echo "<td class=\"$class\" align=\"right\">";
443
 
444
	   if ($blank)
445
	      echo "&nbsp;";
446
	   else
447
	      echo FormatNum($plan, 3);
448
 
449
	   echo "</td>";
450
	}
451
}
452
 
453
# Folgende Funktion erzeugt die Liste aller Projekte. Die Liste
454
# sortiert nach Projekten und Mitarbeitern (Projektsicht).
455
#
456
function ProjektMa($db, $pr_num, $mi_num=0) {
457
	global $periode;
458
	global $phase;
459
	$pl_num = $_REQUEST['pl_num'];
460
	$dfrom = $_REQUEST['dfrom'];
461
	$dto = $_REQUEST['dto'];
462
	$fields_0 = $_REQUEST['fields_0'];
463
	$fields_1 = $_REQUEST['fields_1'];
464
	$fields_2 = $_REQUEST['fields_2'];
465
	$fields_3 = $_REQUEST['fields_3'];
466
	$fields_4 = $_REQUEST['fields_4'];
467
	$fields_5 = $_REQUEST['fields_5'];
468
	$fields_6 = $_REQUEST['fields_6'];
469
	$sort = $_REQUEST['sort'];
470
	$level = $_REQUEST['level'];
471
 
472
	# Beim bis-Datum den Monatsletzten ermitteln
473
	$mon = gmdate("n", $dto);
474
	$year = gmdate("Y", $dto);
475
	$day = daysinmonth($mon, $year);
476
	$dto = gmmktime(23, 59, 59, $mon, $day, $year);
477
	# Den Projektnamen ermitteln
478
	$query = "select pr_num, pr_name, pr_status from project ";
479
 
480
	if ($pr_num > 0)
481
	   $query .= "where pr_num = $pr_num ";
482
 
483
	$query .= "order by pr_num";
484
	$respr = QueryDB($db, $query);
485
 
486
	if (!$respr)
487
	   return;
488
 
489
	$numpr = numrowsDB($respr);
490
	$pospr = 0;
491
 
492
	$pdiff = $fields_3;
493
	$pist = $fields_4;
494
	$pplan = $fields_5;
495
	$mult = 0;
496
 
497
	if ($pist > 0)
498
	   $mult++;
499
 
500
	if ($pplan > 0)
501
	   $mult++;
502
 
503
	if ($pplan > 0 && $pdiff > 0)
504
	   $mult++;
505
 
506
	$csp = 4;
507
 
508
	if ($fields_6 > 0)
509
	   $csp++;
510
 
511
	if ($fields_0 > 0)
512
	   $csp++;
513
 
514
	if ($fields_1 > 0)
515
	   $csp++;
516
 
517
	if ($fields_2 > 0)
518
	   $csp++;
519
 
520
	$pl_flag = false;
521
	$TempTable = false;
522
 
523
	while ($pospr < $numpr) {
524
	   $data = fetchDB($respr, $pospr);
525
	   $pr_num = $data[0];
526
	   $pr_name = $data[1];
527
	   $pr_status = $data[2];
528
 
529
	   # Wurde kein Projekt gewaehlt, dann muessen wir die Plannummer
530
	   # ermitteln. In diesem Fall zeigen wir immer den aktuelsten Plan
531
	   # an.
532
	   #
533
	   if ($pl_flag || !isset($pl_num) || $pl_num <= 0) {
534
	      $query = "select pl_num from plan where pl_prnum = $pr_num order by pl_num desc";
535
	      $result = QueryDB($db, $query);
536
 
537
	      if (!$result)
538
	         return;
539
 
540
	      if (numrowsDB($result) > 0) {
541
	         $data = fetchDB($result, 0);
542
	         $pl_num = $data[0];
543
	         $pl_flag = true;
544
	      } else {
545
	         $pl_num = 0;
546
	         $pl_flag = false;
547
	         $pospr++;
548
	         continue;
549
	      }
550
	   }
551
 
552
	   if ($TempTable && $pospr > 0)
553
	      TQueryDB($db, "drop table TempPlan");
554
 
555
	   $TempTable = true;
556
 
557
	   if (!CreateTempPlan($db, $pl_num, $pr_num, $dfrom, $dto, true)) {
558
	      $pospr++;
559
	      continue;
560
	   }
561
 
562
	   # Wieviele Perioden gibt es insgesamt?
563
	   $query = "select count(distinct tmp_periode) from TempPlan";
564
	   $result = QueryDB($db, $query);
565
 
566
	   if (!$result) {
567
	      closeDB($db);
568
	      return;
569
	   }
570
 
571
	   $data = fetchDB($result, 0);
572
	   $numper = $data[0];
573
	   $np = $numper * $mult;
574
	   $c = $csp + $np;
575
	   # Keine Datensaetze, dann keine Tabelle malen...
576
	   if ($numper == 0) {
577
	      $pospr++;
578
	      continue;
579
	   }
580
 
581
	   # Zeichnen des Tabellenkopfs
582
	   echo "<table class=\"sel\"><tr>";
583
	   echo "<td class=\"sel\" colspan=$c>Projekt: $pr_num $pr_name</td></tr>\n";
584
	   $c = $csp - 3;
585
	   echo "<tr><td class=\"sel\" colspan=$c>&nbsp;</td>\n";
586
 
587
	   # Ermitteln der einzelnen Perioden und Darstellung der Selben.
588
	   #
589
	   $query = "select distinct tmp_periode from TempPlan order by tmp_periode";
590
	   $result = QueryDB($db, $query);
591
 
592
	   # Wurde kein Projekt gewaehlt, dann muessen wir die Plannummer
593
	   # ermitteln. In diesem Fall zeigen wir immer den aktuelsten Plan
594
	   # an.
595
 
596
	   if (!$result) {
597
	      echo "</tr></table>";
598
	      return;
599
	   }
600
 
601
	   $numrows = numrowsDB($result);
602
	   $r = 0;
603
	   $x = 0;
604
 
605
	   while ($r < $numrows) {
606
	      $data = fetchDB($result, $r);
607
	      $tmp_periode = $data[0];
608
 
609
	      $mon = gmdate("n", $tmp_periode);
610
	      $year = gmdate("Y", $tmp_periode);
611
 
612
	      if ($r == 0) {
613
	         $fdate = $tmp_periode;
614
	         $adate = $fdate;
615
	      }
616
 
617
	      while ($adate < $tmp_periode) {
618
	         $p = gmdate("n/Y", $adate);
619
	         echo "<th colspan=$mult class=\"sel\">$p</th>\n";
620
	         $adate = IncDate($periode, $adate);
621
	         $sumperp[$x] = 0.0;
622
	         $sumperi[$x] = 0.0;
623
	         $totalis[$x] = 0.0;
624
	         $totalpl[$x] = 0.0;
625
	         $x++;
626
	      }
627
 
628
	      echo "<th colspan=$mult class=\"sel\">$mon/$year</th>\n";
629
	      $sumperp[$x] = 0.0;
630
	      $sumperi[$x] = 0.0;
631
	      $totalis[$x] = 0.0;
632
	      $totalpl[$x] = 0.0;
633
	      $adate = IncDate($periode, $adate);
634
	      $r++;
635
	      $x++;
636
	   }
637
 
638
	   $ldate = $tmp_periode;
639
	   echo "<th colspan=$mult class=\"sel\">Summen</th></tr>\n";
640
	   echo "<tr><th class=\"sel\">Mitarbeiter</th>";
641
 
642
	   if ($fields_2 > 0)
643
	      echo "<th class=\"sel\">Gruppe</th>";
644
 
645
	   if ($phase && $fields_6 > 0)
646
	      echo "<th class=\"sel\">Phase</th>";
647
 
648
	   if ($fields_0 > 0)
649
	      echo "<th class=\"sel\">Tasks</th>";
650
 
651
	   if ($fields_1 > 0)
652
	      echo "<th class=\"sel\">Anmerkungen</th>";
653
 
654
	   $r = 0;
655
 
656
	   while ($r <= $x) {
657
	      if ($pist > 0)
658
	         echo "<th class=\"sel\">IST</th>\n";
659
 
660
	      if ($pplan > 0 && $pdiff > 0)
661
	         echo "<th class=\"sel\">Diff.</th>\n";
662
 
663
	      if ($pplan > 0)
664
	         echo "<th class=\"sel\">Plan</th>\n";
665
 
666
	      $r++;
667
	   }
668
 
669
	   echo "</tr>\n";
670
 
671
	   $query = "select tmp_phase, tmp_periode, tmp_plan, tmp_ist,";
672
	   $query .= "tmp_taname, tmp_notiz, mi_nname, mi_vname, kp_phase, ";
673
	   $query .= "kl_land, tmp_miname, tmp_status, tmp_hash ";
674
	   $query .= "from TempPlan, mitarbeiter, key_phase, key_land where ";
675
	   $query .= "mi_num = tmp_miname and kp_num = tmp_phase and kl_num = mi_land ";
676
	   $query .= "order by mi_nname, mi_vname, tmp_phase, tmp_taname, tmp_periode";
677
	   $result = QueryDB($db, $query);
678
 
679
	   if (!$result)
680
	      return;
681
 
682
	   $numrows = numrowsDB($result);
683
	   $rows = 0;
684
	   $oldminame = 0;
685
	   $oldphase = 0;
686
	   $oldname = "";
687
	   $sumlpl = 0.0;
688
	   $sumlis = 0.0;
689
	   $per = 0;
690
	   $first = true;
691
	   $adate = $fdate;
692
	   $class = "selltgray";
693
 
694
	   while ($rows < $numrows) {
695
	      $data = fetchDB($result, $rows);
696
	      $tmp_phase = $data[0];
697
	      $tmp_periode = $data[1];
698
	      $tmp_plan = $data[2];
699
	      $tmp_ist = $data[3];
700
	      $tmp_taname = $data[4];
701
	      $tmp_notiz = $data[5];
702
	      $mi_nname = $data[6];
703
	      $mi_vname = $data[7];
704
	      $kp_phase = $data[8];
705
	      $kl_land = $data[9];
706
	      $tmp_miname = $data[10];
707
	      $tmp_status = $data[11];
708
	      $tmp_hash = $data[12];
709
 
710
	      # Summen und Zeilenanfang schreiben
711
	      #
712
	      if ($oldminame != $tmp_miname || $oldphase != $tmp_phase ||
713
		  $oldname != $tmp_taname) {
714
		 # Aktuelle Zeile vervollstaendigen (nur wenn eine Zeile
715
		 # bereits geschrieben wurde).
716
		 #
717
		 if (!$first) {
718
		    while ($adate <= $ldate) {
719
		       Cell($class, 0, 0, true);
720
 
721
		       if ($class == "selltgray")
722
		          $class = "selgray";
723
		       else
724
		          $class = "selltgray";
725
 
726
		       $adate = IncDate($periode, $adate);
727
		    }
728
 
729
		    ZSum($sumlis, $sumlpl);
730
		    echo "</tr>\n";
731
		 }
732
 
733
		 if (!$first && $oldminame != $tmp_miname) {
734
		    $cp = $csp - 3;
735
		    # Monatssummen nach einem Mitarbeiterwechsel
736
		    #
737
		    if ($fields_0 > 0 || $fields_6 > 0 && $fields_1 > 0 && $fields_2 > 0)
738
		       echo "<tr><td class=\"selnum\" colspan=$cp><b>Zwischensumme:</b></td>";
739
 
740
		    $adate = $fdate;
741
		    $per = 0;
742
		    $sumi = 0.0;
743
		    $sump = 0.0;
744
 
745
		    while ($adate <= $ldate) {
746
		       if ($fields_0 > 0 || $fields_6 > 0 && $fields_1 > 0 && $fields_2 > 0)
747
		          Cell("lsum", $sumperi[$per], $sumperp[$per]);
748
 
749
		       $adate = IncDate($periode, $adate);
750
		       $sumi += $sumperi[$per];
751
		       $sump += $sumperp[$per];
752
		       $sumperi[$per] = 0.0;
753
		       $sumperp[$per] = 0.0;
754
		       $per++;
755
		    }
756
 
757
		    if ($fields_0 > 0 || $fields_6 > 0 && $fields_1 > 0 && $fields_2 > 0) {
758
		       Zsum($sumi, $sump);
759
		       echo "\n";
760
		    }
761
		 }
762
 
763
		 # Beginn der Zeile: Schreiben der ersten fixen Zellen.
764
		 #
765
		 echo "<tr><td class=\"selltgray\">$mi_nname $mi_vname</td>\n";
766
 
767
		 if ($fields_2 > 0)
768
		    echo "<td class=\"selltgray\">$kl_land</td>\n";
769
 
770
		 if ($phase && $fields_6 > 0) {
771
		    echo "<td class=\"selltgray\">";
772
 
773
		    if ($tmp_status == 0)
774
		       echo "$tmp_phase: $kp_phase";
775
		    else
776
		       echo "&nbsp;";
777
 
778
		    echo "</td>\n";
779
		 }
780
 
781
		 if ($fields_0 > 0)
782
		    echo "<td class=\"selltgray\">$tmp_taname</td>\n";
783
 
784
		 if ($fields_1 > 0)
785
		    echo "<td class=\"selltgray\">$tmp_notiz</td>\n";
786
 
787
		 # Variablen initialisieren...
788
		 #
789
		 $sumlis = 0.0;
790
		 $sumlpl = 0.0;
791
		 $per = 0;
792
		 $adate = $fdate;
793
		 $oldminame = $tmp_miname;
794
		 $oldphase = $tmp_phase;
795
		 $oldname = $tmp_taname;
796
		 $first = false;
797
		 $class = "selltgray";
798
	      }
799
 
800
	      # Stimmt die aktuelle Position nicht mit der Periode ueberein,
801
	      # uebergehen wir die Zellen.
802
	      #
803
	      while ($adate < $tmp_periode) {
804
		 Cell($class, 0, 0, true);
805
 
806
		 if ($class == "selltgray")
807
		    $class = "selgray";
808
		 else
809
		    $class = "selltgray";
810
 
811
		 $adate = IncDate($periode, $adate);
812
		 $per++;
813
	      }
814
 
815
	      # Schreiben einer Zelle mit den aktuellen Werten.
816
	      Cell($class, $tmp_ist, $tmp_plan);
817
 
818
	      if ($class == "selltgray")
819
	         $class = "selgray";
820
	      else
821
	         $class = "selltgray";
822
 
823
	      $sumperp[$per] += $tmp_plan;
824
	      $sumperi[$per] += $tmp_ist;
825
	      $totalis[$per] += $tmp_ist;
826
	      $totalpl[$per] += $tmp_plan;
827
	      $sumlpl += $tmp_plan;
828
	      $sumlis += $tmp_ist;
829
	      $adate = IncDate($periode, $adate);
830
	      $per++;
831
	      $rows++;
832
	   }
833
 
834
	   # Beenden der letzten Datenzeile der aktuellen Tabelle.
835
	   #
836
	   while ($adate <= $ldate) {
837
	      Cell($class, 0, 0, true);
838
 
839
	      if ($class == "selltgray")
840
	         $class = "selgray";
841
	      else
842
	         $class = "selltgray";
843
 
844
	      $adate = IncDate($periode, $adate);
845
	   }
846
 
847
	   ZSum($sumlis, $sumlpl);
848
	   # Summenzeile am Ende der Tabelle fuer den letzten Mitarbeiter
849
	   # anzeigen.
850
	   #
851
	   $cp = 1;
852
 
853
	   if ($fields_0 > 0)
854
	      $cp++;
855
 
856
	   if ($fields_1 > 0)
857
	      $cp++;
858
 
859
	   if ($fields_2 > 0)
860
	      $cp++;
861
 
862
	   if ($fields_6 > 0)
863
	      $cp++;
864
 
865
	   if (($fields_0 > 0 || $fileds_1 > 0 || $fileds_2 > 0 || $fields_6 > 0) && $mi_num == 0) {
866
	      echo "<tr><td class=\"selnum\" colspan=$cp><b>Zwischensumme:</b></td>";
867
	      $adate = $fdate;
868
	      $per = 0;
869
	      $sumi = 0.0;
870
	      $sump = 0.0;
871
 
872
	      while ($adate <= $ldate) {
873
	         Cell("seldkgray", $sumperi[$per], $sumperp[$per]);
874
	         $adate = IncDate($periode, $adate);
875
	         $sumi += $sumperi[$per];
876
	         $sump += $sumperp[$per];
877
	         $sumperi[$per] = 0.0;
878
	         $sumperp[$per] = 0.0;
879
	         $per++;
880
	      }
881
 
882
	      ZSum($sumi, $sump);
883
	   }
884
 
885
	   # Monatssummen und Gesamtzeitraumsumme am Ende der Tabelle
886
	   # anzeigen.
887
	   #
888
	   echo "<tr><td class=\"selnum\" colspan=$cp><b>Monatssummen:</b></td>";
889
	   $adate = $fdate;
890
	   $per = 0;
891
	   $sumi = 0.0;
892
	   $sump = 0.0;
893
 
894
	   while ($adate <= $ldate) {
895
	      Cell("seldkgray", $totalis[$per], $totalpl[$per]);
896
	      $adate = IncDate($periode, $adate);
897
	      $sumi += $totalis[$per];
898
	      $sump += $totalpl[$per];
899
	      $per++;
900
	   }
901
 
902
	   Cell("two", $sumi, $sump);
903
	   echo "</tr>\n</table><br>\n";
904
	   $pospr++;
905
	}
906
}
907
 
908
# Folgende Funktion erzeugt die Liste fuer einen oder mehreren Mitarbeitern.
909
# Die Liste sortiert nach Mitarbeitern und Projekten.
910
#
911
function MitarbeiterPj($db, $mi_num, $prp_num=0) {
912
	global $periode;
913
	global $phase;
914
//	$pl_num = $_REQUEST['pl_num'];
915
	$dfrom = $_REQUEST['dfrom'];
916
	$dto = $_REQUEST['dto'];
917
	$fields_0 = $_REQUEST['fields_0'];
918
	$fields_1 = $_REQUEST['fields_1'];
919
	$fields_2 = $_REQUEST['fields_2'];
920
	$fields_3 = $_REQUEST['fields_3'];
921
	$fields_4 = $_REQUEST['fields_4'];
922
	$fields_5 = $_REQUEST['fields_5'];
923
	$fields_6 = $_REQUEST['fields_6'];
924
	$sort = $_REQUEST['sort'];
925
	$level = $_REQUEST['level'];
926
	$pjclosed = $_REQUEST['pjclosed'];
927
 
928
//	if (isset($pjclosed) && $pjclosed == "true")
929
	if (isset($pjclosed) && CheckTrue($pjclosed))
930
	   $pjc = ",6";
931
 
932
	# Beim bis-Datum den Monatsletzten ermitteln
933
	$mon = gmdate("n", $dto);
934
	$year = gmdate("Y", $dto);
935
	$day = daysinmonth($mon, $year);
936
	$dto = gmmktime(23, 59, 59, $mon, $day, $year);
937
	# Auslesen der Mitarbeiter. In einer Schleife werden die Daten
938
	# fuer jeden Mitarbeiter erstellt und pro Projekt angezeigt.
939
	#
940
	$query = "select mi_num, mi_nname, mi_vname, kl_land, ka_abt ";
941
	$query .= "from mitarbeiter, key_land, key_abt where ";
942
	$query .= "kl_num = mi_land and ka_num = mi_abt ";
943
 
944
	if ($mi_num > 0)
945
	   $query .= "and mi_num = $mi_num ";
946
 
947
	$query .= "order by mi_nname, mi_vname";
948
	$resmi = QueryDB($db, $query);
949
 
950
	if (!$resmi)
951
	   return;
952
 
953
	$nummi = numrowsDB($resmi);
954
	$posmi = 0;
955
 
956
	$pdiff = $fields_3;
957
	$pist = $fields_4;
958
	$pplan = $fields_5;
959
	$mult = 0;
960
 
961
	if ($pist > 0)
962
	   $mult++;
963
 
964
	if ($pplan > 0)
965
	   $mult++;
966
 
967
	if ($pplan > 0 && $pdiff > 0)
968
	   $mult++;
969
 
970
	$csp = 4;
971
 
972
	if ($fields_6 > 0)
973
	   $csp++;
974
 
975
	if ($fields_0 > 0)
976
	   $csp++;
977
 
978
	if ($fields_1 > 0)
979
	   $csp++;
980
 
981
	# Die Anzahl der Perioden ergibt sich aus der Auswahl. Die
982
	# Mitarbeitersicht besteht aus einer einzigen Tabelle in der
983
	# alle Daten angezeigt werden und mit Zwischensummen versehen
984
	# werden.
985
	# In der folgenden Schleife wird die Anzahl der Perioden
986
	# ermittelt.
987
	#
988
	$adate = $dfrom;
989
	$numper = 0;
990
 
991
	while ($adate <= $dto) {
992
	   $adate = IncDate($periode, $adate);
993
	   $numper++;
994
	}
995
 
996
	$np = $numper * $mult;
997
	$TempTable = false;
998
	echo "<table class=\"sel\">";
999
 
1000
	while ($posmi < $nummi) {
1001
	   $data = fetchDB($resmi, $posmi);
1002
	   $mi_num = $data[0];
1003
	   $mi_nname = $data[1];
1004
	   $mi_vname = $data[2];
1005
	   $kl_land = $data[3];
1006
	   $ka_abt = $data[4];
1007
 
1008
	   # Pruefen ob der Mitarbeiter in irgend einem Projekt im gewaehlten
1009
	   # Zeitraum geplant ist.
1010
	   if ($prp_num > 0) {
1011
	      $query = "select count(*) from allocation, task, plan where ";
1012
	      $query .= "ta_num = al_task and pl_num = ta_plnum and ";
1013
	      $query .= "pl_prnum = $prp_num and pl_status in (0,2,3,4,5 $pjc) and ";
1014
	   } else {
1015
	      $query = "select count(*) from allocation, task, plan where ";
1016
	      $query .= "ta_num = al_task and pl_num = ta_plnum and ";
1017
	      $query .= "pl_status in (0,2,3,4,5 $pjc) and ";
1018
	   }
1019
 
1020
	   $query .= "al_ressource = $mi_num and al_pstart between $dfrom and $dto";
1021
	   $result = QueryDB($db, $query);
1022
 
1023
	   if (!$result)
1024
	      return;
1025
 
1026
	   $data = fetchDB($result, 0);
1027
	   $anzp = $data[0];
1028
 
1029
	   # Pruefen ob es auch keine IST-Buchungen fuer den fraglichen
1030
	   # Zeitraum gegeben hat.
1031
	   $query = "select count(*) from wdone, plan where ";
1032
	   $query .= "pl_prnum = wd_prnum and pl_status in (0,2,3,4,5 $pjc) and ";
1033
	   $query .= "wd_datum between $dfrom and $dto and ";
1034
	   $query .= "wd_minum = $mi_num ";
1035
 
1036
	   if ($prp_num > 0)
1037
	      $query .= "and wd_prnum = $prp_num";
1038
 
1039
	   if (!($result = QueryDB($db, $query)))
1040
	      return;
1041
 
1042
	   $data = fetchDB($result, 0);
1043
	   $anzi = $data[0];
1044
 
1045
	   if ($anzp < 1 && $anzi < 1) {
1046
	      $posmi++;
1047
	      continue;
1048
	   }
1049
 
1050
	   # Zeichnen des Tabellenkopfs
1051
	   # Bei jedem Mitarbeiterwechsel wird ein neuer Tabellenkopf
1052
	   # gezeichnet.
1053
	   #
1054
	   $c = $csp + $np;
1055
	   echo "<tr><td class=\"sel\" colspan=$c>";
1056
	   echo "<table border=0 cellpadding=0><tr><td>Name:</td><td>$mi_nname $mi_vname</td></tr>\n";
1057
	   echo "<tr><td>Gruppe:</td><td>$kl_land</td></tr>\n";
1058
 
1059
	   if (!$pmlight)
1060
	      echo "<tr><td>Abteilung:</td><td>$ka_abt</td></tr>\n";
1061
 
1062
	   echo "</table></td></tr>\n";
1063
	   $c = $csp - 3;
1064
	   echo "<tr><td class=\"sel\" colspan=$c>&nbsp;</td>\n";
1065
	   $r = 0;
1066
	   $adate = $dfrom;
1067
 
1068
	   while ($r < $numper) {
1069
	      $p = gmdate("n/Y", $adate);
1070
	      echo "<th colspan=$mult class=\"sel\">$p</th>\n";
1071
	      $adate = IncDate($periode, $adate);
1072
	      $r++;
1073
	   }
1074
 
1075
	   echo "<th colspan=$mult class=\"sel\">Summen</th></tr>\n";
1076
	   echo "<tr><th class=\"sel\">Projekt</th>";
1077
 
1078
	   if ($phase && $fields_6 > 0)
1079
	      echo "<th class=\"sel\">Phase</th>";
1080
 
1081
	   if ($fields_0 > 0)
1082
	      echo "<th class=\"sel\">Tasks</th>";
1083
 
1084
	   if ($fields_1 > 0)
1085
	      echo "<th class=\"sel\">Anmerkungen</th>";
1086
 
1087
	   $r = 0;
1088
 
1089
	   while ($r <= $numper) {
1090
	      if ($pist > 0)
1091
	         echo "<td class=\"selinfo_l\" align=\"center\"><b>IST</b></td>\n";
1092
 
1093
	      if ($pplan > 0 && $pdiff > 0)
1094
	         echo "<td class=\"selinfo\" align=\"center\"><b>Diff.</b></td>\n";
1095
 
1096
	      if ($pplan > 0)
1097
	         echo "<td class=\"selinfo_r\" align=\"center\"><b>Plan</b></td>\n";
1098
 
1099
	      $r++;
1100
	   }
1101
 
1102
	   echo "</tr>\n";
1103
 
1104
	   # Projekte waehlen, in denen der Mitarbeiter geplant ist.
1105
	   #
1106
	   # Wurde kein bestimmter Mitarbeiter gewählt, werden immer alle
1107
	   # Mitarbeiter angezeigt. Es werden grundsätzlich alle Projekte
1108
	   # angezeigt in denen der Mitarbeiter geplant ist oder wo er
1109
	   # IST-Werte hat (das eine bedingt das andere!).
1110
	   #
1111
	   $query = "select distinct on (pr_num) pr_num, pr_name, pl_num, pl_status from ";
1112
	   $query .= "project left join plan on pl_prnum = pr_num ";
1113
	   $query .= "where pl_status in (0,2,3,4,5 $pjc) ";
1114
 
1115
	   if ($prp_num > 0)
1116
	      $query .= "and pr_num = $prp_num ";
1117
 
1118
	   $query .= "order by pr_num asc, pl_lfd desc";
1119
	   $respr = QueryDB($db, $query);
1120
 
1121
	   if (!$respr)
1122
	      return;
1123
 
1124
	   $numpr = numrowsDB($respr);
1125
	   $pospr = 0;
1126
	   $old_prnum = 0;
1127
	   $pr_flag = false;	// Zwischensumme schreiben
1128
 
1129
	   while ($pospr < $numpr) {
1130
	      $data = fetchDB($respr, $pospr);
1131
	      $pr_num = $data[0];
1132
	      $pr_name = $data[1];
1133
	      $pl_num = $data[2];
1134
	      $pl_status = $data[3];
1135
 
1136
	      # Pruefen ob fuer den fraglichen Zeitraum Plantage oder
1137
	      # IST-Daten vorhanden sind.
1138
	      $query = "select count(*) from allocation, task, plan where ";
1139
	      $query .= "ta_num = al_task and pl_num = ta_plnum and ";
1140
	      $query .= "pl_prnum = $pr_num and al_ressource = $mi_num and ";
1141
	      $query .= "al_pstart between $dfrom and $dto and pl_status in (0,2,3,4,5 $pjc)";
1142
 
1143
	      if (!($resco = QueryDB($db, $query)))
1144
	         return;
1145
 
1146
	      $data = fetchDB($resco, 0);
1147
	      $anzp = $data[0];
1148
 
1149
	      $query = "select count(*) from wdone where ";
1150
	      $query .= "wd_minum = $mi_num and wd_prnum = $pr_num and ";
1151
	      $query .= "wd_datum between $dfrom and $dto";
1152
 
1153
	      if (!($resco = QueryDB($db, $query)))
1154
	         return;
1155
 
1156
	      $data = fetchDB($resco, 0);
1157
	      $anzi = $data[0];
1158
 
1159
	      # Keine Plan- und IST-Daten? Wenn keine Daten, dann das
1160
	      # Projekt ueberspringen.
1161
	      if ($anzp == 0 && $anzi == 0) {
1162
	         $pospr++;
1163
	         continue;
1164
	      }
1165
 
1166
	      # Falls die temporaere Tabelle existiert, loeschen wir sie.
1167
	      if ($TempTable)
1168
		 TQueryDB($db, "drop table TempPlan");
1169
 
1170
	      $TempTable = true;
1171
	      # Plan erstellen --> tempplan.inc
1172
	      if (!CreateTempPlan($db, $pl_num, $pr_num, $dfrom, $dto, true, $mi_num, true)) {
1173
		 $pospr++;
1174
		 continue;
1175
	      }
1176
 
1177
	      # Wurden in der temporaeren Tabelle ueberhaupt Datensaetze
1178
	      # abgelegt?
1179
	      $query = "select count(*) from TempPlan";
1180
 
1181
	      if (!($resanz = QueryDB($db, $query)))
1182
	         return;
1183
 
1184
	      $data = fetchDB($resanz, 0);
1185
 
1186
	      if ($data[0] <= 0) {
1187
	         $pospr++;
1188
	         continue;
1189
	      }
1190
 
1191
	      $c = $csp + $np;
1192
	      $pr_flag = true;
1193
 
1194
	      # Tabelleninhalt schreiben:
1195
	      # Die Inhalte werden der zuvor temporaer erzeugten Tabelle
1196
	      # entnommen.
1197
	      #
1198
	      if ($fields_0 <= 0) {
1199
	         $query = "select sum(tmp_plan), sum(tmp_ist), tmp_periode ";
1200
 
1201
	         if ($fields_6 > 0)
1202
	            $query .= ", tmp_phase ";
1203
 
1204
	         $query .= "from TempPlan group by ";
1205
 
1206
	         if ($fields_6 > 0)
1207
	            $query .= "tmp_phase, ";
1208
 
1209
		 $query .= "tmp_periode order by ";
1210
 
1211
		 if ($fields_6 > 0)
1212
		    $query .= "tmp_phase, ";
1213
 
1214
		 $query .= "tmp_periode";
1215
	      } else {
1216
	         $query = "select tmp_phase, tmp_periode, tmp_plan, tmp_ist,";
1217
	         $query .= "tmp_taname, tmp_notiz, kp_phase, tmp_hash ";
1218
	         $query .= "from TempPlan, key_phase where ";
1219
	         $query .= "kp_num = tmp_phase ";
1220
	         $query .= "order by ";
1221
 
1222
	         if ($phase)
1223
	            $query .= "tmp_phase, ";
1224
 
1225
	         if ($fields_0 > 0 )
1226
	            $query .= "tmp_taname, ";
1227
 
1228
	         $query .= "tmp_periode";
1229
	      }
1230
 
1231
	      if (!($result = QueryDB($db, $query)))
1232
		 return;
1233
 
1234
	      $numrows = numrowsDB($result);
1235
	      $rows = 0;
1236
	      $oldphase = -1;
1237
	      $oldname = "";
1238
	      $sumlpl = 0.0;
1239
	      $sumlis = 0.0;
1240
	      $per = 0;
1241
	      $first = true;
1242
	      $adate = $dfrom;
1243
	      $class = "selltgray";
1244
 
1245
	      while ($rows < $numrows) {
1246
		 $data = fetchDB($result, $rows);
1247
 
1248
		 if ($fields_0 > 0) {
1249
		    $tmp_phase = $data[0];
1250
		    $tmp_periode = $data[1];
1251
		    $tmp_plan = $data[2];
1252
		    $tmp_ist = $data[3];
1253
		    $tmp_taname = $data[4];
1254
		    $tmp_notiz = $data[5];
1255
		    $kp_phase = $data[6];
1256
		    $tmp_hash = $data[7];
1257
		 } else {
1258
		    $tmp_plan = $data[0];
1259
		    $tmp_ist = $data[1];
1260
		    $tmp_periode = $data[2];
1261
 
1262
		    if ($fields_6 > 0) {
1263
		       $tmp_phase = $data[3];
1264
 
1265
		       $query = "select kp_phase from key_phase where kp_num = $tmp_phase";
1266
 
1267
		       if (!($reskp = QueryDB($db, $query)))
1268
		          return;
1269
 
1270
		       if (numrowsDB($reskp) > 0) {
1271
		          $d = fetchDB($reskp, 0);
1272
			  $kp_phase = $d[0];
1273
		       } else
1274
		          $kp_phase = "";
1275
		    } else
1276
		       $tmp_phase = 0;
1277
 
1278
		    $tmp_taname = "";
1279
		    $tmp_notiz = "";
1280
		    $tmp_hash = "";
1281
		 }
1282
 
1283
		 # Summen und Zeilenanfang schreiben
1284
		 #
1285
		 if ($oldphase != $tmp_phase || $oldname != $tmp_taname) {
1286
		    # Aktuelle Zeile vervollstaendigen (nur wenn eine Zeile
1287
		    # bereits geschrieben wurde).
1288
		    #
1289
		    if (!$first) {
1290
		       while ($adate <= $dto) {
1291
			  Cell($class, 0, 0, true);
1292
 
1293
			  if ($class == "selltgray")
1294
			     $class = "selgray";
1295
			  else
1296
			     $class = "selltgray";
1297
 
1298
			  $adate = IncDate($periode, $adate);
1299
		       }
1300
 
1301
		       ZSum($sumlis, $sumlpl);
1302
		       echo "</tr>\n";
1303
		    }
1304
 
1305
		    $cp = $csp - 3;
1306
		    # Beginn der Zeile: Schreiben der ersten fixen Zellen.
1307
		    #
1308
		    echo "<tr><td class=\"sel\">$pr_num $pr_name</td>\n";
1309
 
1310
		    if ($phase && $fields_6 > 0)
1311
		       echo "<td class=\"sel\">$tmp_phase: $kp_phase</td>\n";
1312
 
1313
		    if ($fields_0 > 0)
1314
		       echo "<td class=\"sel\">$tmp_taname</td>\n";
1315
 
1316
		    if ($fields_1 > 0)
1317
		       echo "<td class=\"sel\">$tmp_notiz</td>\n";
1318
 
1319
		    # Variablen initialisieren...
1320
		    #
1321
		    $sumlis = 0.0;
1322
		    $sumlpl = 0.0;
1323
		    $per = 0;
1324
		    $adate = $dfrom;
1325
		    $oldphase = $tmp_phase;
1326
		    $oldname = $tmp_taname;
1327
		    $first = false;
1328
		    $class = "selltgray";
1329
		 }
1330
 
1331
		 # Stimmt die aktuelle Position nicht mit der Periode ueberein,
1332
		 # uebergehen wir die Zellen.
1333
		 #
1334
		 while ($adate < $tmp_periode) {
1335
		    Cell($class, 0, 0, true);
1336
 
1337
		    if ($class == "selltgray")
1338
		       $class = "selgray";
1339
		    else
1340
		       $class = "selltgray";
1341
 
1342
		    $adate = IncDate($periode, $adate);
1343
		    $per++;
1344
	         }
1345
 
1346
	         # Schreiben einer Zelle mit den aktuellen Werten.
1347
	         Cell($class, $tmp_ist, $tmp_plan, false);
1348
 
1349
	         if ($class == "selltgray")
1350
	            $class = "selgray";
1351
	         else
1352
	            $class = "selltgray";
1353
 
1354
	         $sumperp[$per] += $tmp_plan;
1355
	         $sumperi[$per] += $tmp_ist;
1356
	         $totalis[$per] += $tmp_ist;
1357
	         $totalpl[$per] += $tmp_plan;
1358
	         $mitoti[$per] += $tmp_ist;
1359
	         $mitotp[$per] += $tmp_plan;
1360
	         $sumlpl += $tmp_plan;
1361
	         $sumlis += $tmp_ist;
1362
	         $adate = IncDate($periode, $adate);
1363
	         $per++;
1364
	         $rows++;
1365
	      }
1366
 
1367
	      # Beenden der der letzten Datenzeile der aktuellen Tabelle.
1368
	      #
1369
	      while ($adate <= $dto) {
1370
	         Cell($class, 0, 0, true);
1371
 
1372
	         if ($class == "selltgray")
1373
	            $class = "selgray";
1374
	         else
1375
	            $class = "selltgray";
1376
 
1377
	         $adate = IncDate($periode, $adate);
1378
	      }
1379
 
1380
	      ZSum($sumlis, $sumlpl);
1381
	      echo "</tr>\n";
1382
	      $cp = $csp - 3;
1383
 
1384
	      if ($prp_num == 0 && $numpr > 1 && ($fields_0 || $fields_6)) {
1385
	         echo "<tr><td class=\"selnum\" colspan=$cp><b>Projektsumme:</b></td>";
1386
	         $adate = $dfrom;
1387
	         $per = 0;
1388
	         $sumi = 0.0;
1389
	         $sump = 0.0;
1390
 
1391
	         while ($adate <= $dto) {
1392
		    Cell("lsum", $sumperi[$per], $sumperp[$per]);
1393
		    $adate = IncDate($periode, $adate);
1394
		    $sumi += $sumperi[$per];
1395
		    $sump += $sumperp[$per];
1396
		    $sumperi[$per] = 0.0;
1397
		    $sumperp[$per] = 0.0;
1398
		    $per++;
1399
	         }
1400
 
1401
	         Zsum($sumi, $sump);
1402
	         echo "</tr>\n";
1403
	      }
1404
 
1405
	      $pospr++;
1406
	   }
1407
 
1408
	   $cp = $csp - 3;
1409
	   echo "<tr><td class=\"selnum\" colspan=$cp><b>Gesamtsumme Mitarbeiter:</b></td>";
1410
	   $adate = $dfrom;
1411
	   $per = 0;
1412
	   $sumi = 0.0;
1413
	   $sump = 0.0;
1414
 
1415
	   while ($adate <= $dto) {
1416
	      Cell("seldkgray", $mitoti[$per], $mitotp[$per]);
1417
	      $adate = IncDate($periode, $adate);
1418
	      $sumi += $mitoti[$per];
1419
	      $sump += $mitotp[$per];
1420
	      $mitoti[$per] = 0.0;
1421
	      $mitotp[$per] = 0.0;
1422
	      $per++;
1423
	   }
1424
 
1425
	   Zsum($sumi, $sump);
1426
	   echo "</tr>\n";
1427
	   $posmi++;
1428
	}
1429
 
1430
	# Monatssummen und Gesamtzeitraumsumme am Ende der Tabelle
1431
	# anzeigen.
1432
	#
1433
	if ($mi_num == 0) {
1434
	   echo "<tr><td class=\"selnum\" colspan=$cp><b>Monatssummen:</b></td>";
1435
	   $adate = $dfrom;
1436
	   $per = 0;
1437
	   $sumi = 0.0;
1438
	   $sump = 0.0;
1439
 
1440
	   while ($adate <= $dto) {
1441
	      Cell("sum", $totalis[$per], $totalpl[$per]);
1442
	      $adate = IncDate($periode, $adate);
1443
	      $sumi += $totalis[$per];
1444
	      $sump += $totalpl[$per];
1445
	      $per++;
1446
	   }
1447
 
1448
	   Cell("two", $sumi, $sump);
1449
	   echo "</tr>\n";
1450
	}
1451
 
1452
	echo "</table><br>\n";
1453
}
1454
 
1455
# Folgende Funktion wertet die vom Anwender getroffenen Einstellungen aus
1456
# und ruft die entsprechenden Funktionen auf um die Listen darzustellen.
1457
#
1458
function PrintList() {
1459
	global $phase;
1460
	global $pmlight;
1461
	$pl_num = $_REQUEST['pl_num'];
1462
	$mi_num = $_REQUEST['mi_num'];
1463
	$dfrom = $_REQUEST['dfrom'];
1464
	$dto = $_REQUEST['dto'];
1465
	$fields_0 = $_REQUEST['fields_0'];
1466
	$fields_1 = $_REQUEST['fields_1'];
1467
	$fields_2 = $_REQUEST['fields_2'];
1468
	$fields_3 = $_REQUEST['fields_3'];
1469
	$fields_4 = $_REQUEST['fields_4'];
1470
	$fields_5 = $_REQUEST['fields_5'];
1471
	$fields_6 = $_REQUEST['fields_6'];
1472
	$sort = $_REQUEST['sort'];
1473
	$level = $_REQUEST['level'];
1474
	$pjclosed = $_REQUEST['pjclosed'];
1475
 
1476
	if (isset($pjclosed) && CheckTrue($pjclosed))
1477
	   $pjc = ",6";
1478
 
1479
	# Als erstes pruefen wir, ob die wichtigen Parameter auch korrekt
1480
	# gesetzt wurden.
1481
	if ($dfrom > $dto) {
1482
	   Error("Das Beginndatum darf nicht h&ouml;her sein als das Endedatum!");
1483
	   return;
1484
	}
1485
 
1486
	$db = OpenDB();
1487
	# In einem ersten Schritt zeichnen wir eine Box in der die gewaehlten
1488
	# Parameter angezeigt werden:
1489
	#
1490
	echo "<table class=\"input\">\n";
1491
	echo "<tr><td><table border=0 cellpadding=0 cellspacing=0>\n";
1492
 
1493
	if ($pl_num == 0) {
1494
	   echo "<tr><td>Projekt:</td><td>";
1495
	   echo "Alle";
1496
	} else {
1497
	   $query = "select pl_prnum, pr_name, pr_status from plan, project ";
1498
	   $query .= "where pr_num = pl_prnum and pl_num = $pl_num";
1499
	   $result = QueryDB($db, $query);
1500
 
1501
	   if (!$result) {
1502
	      closeDB($db);
1503
	      return;
1504
	   }
1505
 
1506
	   $data = fetchDB($result, 0);
1507
	   $pr_num = $data[0];
1508
	   $pr_name = $data[1];
1509
	   $pr_status = $data[2];
1510
 
1511
	   if ($pr_status == 0)
1512
	      echo "<tr><td>Projekt:</td><td>";
1513
	   else
1514
	      echo "<tr><td>Konto:</td><td>";
1515
 
1516
	   echo "$pr_num $pr_name";
1517
	}
1518
 
1519
	echo "</td></tr>\n";
1520
	echo "<tr><td>Mitarbeiter:</td><td>";
1521
 
1522
	if ($mi_num == 0) {
1523
	   echo "Alle";
1524
	} else {
1525
	   $query = "select mi_nname, mi_vname from mitarbeiter where mi_num = $mi_num";
1526
	   $result = QueryDB($db, $query);
1527
 
1528
	   if (!$result) {
1529
	      closeDB($db);
1530
	      return;
1531
	   }
1532
 
1533
	   $data = fetchDB($result, 0);
1534
	   $mi_nname = $data[0];
1535
	   $mi_vname = $data[1];
1536
	   echo "$mi_nname $mi_vname";
1537
	}
1538
 
1539
	echo "</td></tr>\n";
1540
	echo "<tr><td>Zeitraum:</td><td class=\"selnf\">";
1541
	echo "Von: " . gmdate("n.Y", $dfrom) . " ";
1542
	echo "Bis: " . gmdate("n.Y", $dto);
1543
	echo "</td></tr>\n";
1544
 
1545
	echo "<tr><td valign=\"top\">Spaltenauswahl:</td>\n";
1546
	echo "<td class=\"selnf\">";
1547
 
1548
	if ($fields_2 > 0)
1549
	   echo "Gruppe<br>\n";
1550
 
1551
	if ($fields_6 > 0)
1552
	   echo "Phasen<br>\n";
1553
 
1554
	if ($fields_0 > 0)
1555
	   echo "Tasks anzeigen<br>\n";
1556
 
1557
	if ($fields_1 > 0)
1558
	   echo "Anmerkungen<br>\n";
1559
 
1560
	if ($fields_4 > 0)
1561
	   echo "IST-Werte<br>\n";
1562
 
1563
	if ($fields_3 > 0)
1564
	   echo "IST- / Plandifferenz<br>\n";
1565
 
1566
	if ($fields_5 > 0)
1567
	   echo "Planwerte<br>\n";
1568
 
1569
	echo "</td></tr>\n";
1570
 
1571
	echo "<tr><td>Sortierreihenfolge:</td><td>\n";
1572
 
1573
	if ($sort == 1)
1574
	   echo "Projekte / Mitarbeiter";
1575
	else
1576
	   echo "Mitarbeiter / Projekte";
1577
 
1578
	echo "</td></tr>\n";
1579
 
1580
/*	echo "<tr><td>Plantiefe:</td><td>\n";
1581
 
1582
	if ($level == -1)
1583
	   echo "Alle";
1584
	else
1585
	   echo "Bis zu Level $level";
1586
 
1587
	echo "</td></tr>\n"; */
1588
	echo "</table></td></tr></table><br>\n";
1589
 
1590
	if ($sort == 1)
1591
	   ProjektMa($db, $pr_num, $mi_num);
1592
	else
1593
	   MitarbeiterPj($db, $mi_num, $pr_num);
1594
 
1595
	closeDB($db);
1596
}
1597
 
1598
# Auswertung des Menues:
1599
#
1600
if ($knopf == 27)		// Ressourcenauslastung
1601
   Preselect();
1602
 
1603
if ($func == "repeatpj")
1604
   Preselect(1);
1605
 
1606
# Auswertung der Funktionen
1607
if ($func == "prlist") {
1608
   $pl_num = $_REQUEST['pl_num'];
1609
   $mi_num = $_REQUEST['mi_num'];
1610
   $dfrom = $_REQUEST['dfrom'];
1611
   $dto = $_REQUEST['dto'];
1612
   $fields_0 = $_REQUEST['fields_0'];
1613
   $fields_1 = $_REQUEST['fields_1'];
1614
   $fields_2 = $_REQUEST['fields_2'];
1615
   $fields_3 = $_REQUEST['fields_3'];
1616
   $fields_4 = $_REQUEST['fields_4'];
1617
   $fields_5 = $_REQUEST['fields_5'];
1618
   $fields_6 = $_REQUEST['fields_6'];
1619
   $sort = $_REQUEST['sort'];
1620
   $level = $_REQUEST['level'];
1621
   $pjclosed = $_REQUEST['pjclosed'];
1622
 
1623
   echo "<table class=\"indent\"><tr><td>";
1624
 
1625
   if (!$pmlight) {
1626
      ButtonPrint(GetMessage(-1, 383, "Drucken"), "auswertung.php",
1627
      "pl_num=$pl_num&dfrom=$dfrom&dto=$dto&fields_0=$fields_0" .
1628
      "&fields_1=$fields_1&fields_2=$fields_2&fields_3=$fields_3" .
1629
      "&fields_4=$fields_4&fields_5=$fields_5&fields_6=$fields_6" .
1630
      "&mi_num=$mi_num&sort=$sort&level=$level&header=2&pjclosed=$pjclosed&" .
1631
      "func=pauswertung"); //', 'Auswertung', 1000, 650)");
1632
      echo "</td><td>";
1633
      $bt_text = GetMessage(-1, 384, "PDF-Ausgabe");
1634
   } else
1635
      $bt_text = GetMessage(-1, 383, "Drucken");
1636
 
1637
   ButtonPrint($bt_text, "auswertpdf.php",
1638
   "pl_num=$pl_num&dfrom=$dfrom&dto=$dto&fields_0=$fields_0" .
1639
   "&fields_1=$fields_1&fields_2=$fields_2&fields_3=$fields_3" .
1640
   "&fields_4=$fields_4&fields_5=$fields_5&fields_6=$fields_6" .
1641
   "&mi_num=$mi_num&sort=$sort&level=$level&header=2&&pjclosed=$pjclosed&" .
1642
   "func=pauswertung", true);
1643
   echo "</td></tr></table>";
1644
   PrintList();
1645
}
1646
 
1647
if ($func == "pauswertung") {
1648
   PrintList();
1649
}
1650
 
1651
require('footer.inc');
1652
?>