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['planung'])) { $knopf = 25; $headline = 29; }
15
 
16
$drm = array(true, false, false, false, false, true, false);
17
 
18
require_once('menu.inc');
19
require_once('knumber.inc');
20
 
21
# Folgende Funktion erlaubt die Auswahl einer Periode fuer die der Statusbericht
22
# erzeugt werden soll.
23
#
24
function Preselect() {
25
	global $periode;
26
	global $unum;
27
	global $menu;
28
	global $rstufe;
29
 
30
	$db = OpenDB();
31
?>
32
<form action="prplanhilf.php" method="post">
33
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
34
<input type="hidden" name="headline" value="29">
35
<input type="hidden" name="func" value="prplan">
36
 
37
<table border=0>
38
<?php
39
	# Auswahl eines Projekts
40
	echo "<tr><td>Projektauswahl:</td>\n";
41
	echo "<td>";
42
 
43
	$query = "select pl_num, pl_prnum, pl_lfd, pr_name from plan, project ";
44
	$query .= "where pr_num = pl_prnum and pl_status in (2,3,4) ";
45
	$query .= "order by pl_prnum, pl_lfd desc";
46
 
47
	$result = QueryDB($db, $query);
48
 
49
	if (!$result) {
50
	   closeDB($db);
51
	   return;
52
	}
53
 
54
	echo "<select name=\"pl_num\">\n";
55
	$numrows = numrowsDB($result);
56
	$rows = 0;
57
 
58
	while ($rows < $numrows) {
59
	   $data = fetchDB($result, $rows);
60
	   $pl_num = $data[0];
61
	   $pl_prnum = $data[1];
62
	   $pl_lfd = $data[2];
63
	   $pr_name = $data[3];
64
	   echo "<option value=\"$pl_num\">$pl_lfd: $pl_prnum $pr_name</option>\n";
65
	   $rows++;
66
	}
67
 
68
	echo "</select>";
69
	echo "</td></tr>\n";
70
	echo "</table>\n";
71
	echo "<br><input type=\"submit\" name=\"submit\" value=\"Senden\"> <input type=\"reset\">\n";
72
	echo "</form>\n";
73
	closeDB($db);
74
}
75
 
76
function ShowPlanGesamt($print=false) {
77
	global $leneinheit;
78
	$pl_num = $_REQUEST['pl_num'];
79
 
80
	$db = OpenDB();
81
	# Tabelle Plan-Zusammenfassung
82
?>
83
<table width="40%" border=1>
84
   <tr>
85
      <td class="stbb">Gruppe</td>
86
      <td class="stbb">Jahr</td>
87
      <td class="stbb">Budget</td>
88
   </tr>
89
<?php
90
	# Plan auslesen (alle Tasks) und Aufwaende summieren
91
	$query = "select al_hours, al_pstart, kl_land from ";
92
	$query .= "allocation, mitarbeiter, task, key_land ";
93
	$query .= "where mi_num = al_ressource and kl_num = mi_land and ";
94
	$query .= "ta_num = al_task and ta_plnum = $pl_num ";
95
	$query .= "and ta_meeting = 0 ";
96
	$query .= "order by kl_land, al_pstart";
97
	$result = QueryDB($db, $query);
98
 
99
	if (!$result) {
100
	   closeDB($db);
101
	   return;
102
	}
103
 
104
	$numrows = numrowsDB($result);
105
 
106
	if ($numrows <= 0) {
107
	   Error("Der von Ihnen gew&auml;hlte Plan $pl_num enth&auml;lt keine Tasks!");
108
	   closeDB($db);
109
	   return;
110
	}
111
 
112
	$rows = 0;
113
	$sum = 0.0;
114
	$total = 0.0;
115
	$j = 0;
116
	$r = 0;
117
	$oldland = "";
118
 
119
	while ($rows < $numrows) {
120
	   $data = fetchDB($result, $rows);
121
	   $al_hours = $data[0];
122
	   $al_pstart = $data[1];
123
	   $kl_land = $data[2];
124
 
125
	   $jahr = gmdate("Y", $al_pstart);
126
 
127
	   if ($rows == 0) {
128
	      $j = $jahr;
129
	      $oldland = $kl_land;
130
	   }
131
 
132
	   if ($j != $jahr || $oldland != $kl_land) {
133
	      printf ("<tr><td>$oldland</td><td align=\"center\">$j</td><td align=\"right\">%s</td></tr>\n", FormatNum($sum, 3));
134
	      $sum = 0;
135
	      $j = $jahr;
136
	      $oldland = $kl_land;
137
	      $r = $rows;
138
	   }
139
 
140
	   $sum += $al_hours;
141
	   $total += $al_hours;
142
	   $rows++;
143
	}
144
 
145
	if ($r != $rows)
146
	   printf ("<tr><td>$kl_land</td><td align=\"center\">$jahr</td><td align=\"right\">%s</td></tr>\n", FormatNum($sum, 3));
147
 
148
	# Anzeigen der Summe
149
	printf ("<tr><td colspan=2 class=\"stbb\">Summe:</td><td align=\"right\"><b>%s</b></td></tr>\n", FormatNum($total, 3));
150
	echo "</table>\n";
151
	closeDB($db);
152
}
153
 
154
function ShowPlanBasis($print=false) {
155
	global $leneinheit;
156
	global $phase;
157
	$pl_num = $_REQUEST['pl_num'];
158
 
159
	$db = OpenDB();
160
?>
161
<table width="80%" border=1>
162
   <tr>
163
<?
164
	if ($phase) {
165
	   echo "<td class=\"stbb\">Phase</td>\n";
166
	   echo "<td class=\"stbb\">Subphasen</td>\n";
167
	} else {
168
	   echo "<td class=\"stbb\">Task</td>\n";
169
	}
170
?>
171
      <td class="stbb">Aktivit&auml;t/T&auml;tigkeit</td>
172
      <td class="stbb">Gruppe</td>
173
      <td class="stbb">Monat</td>
174
      <td class="stbb">Jahr</td>
175
      <td class="stbb">Basis</td>
176
   </tr>
177
<?php
178
	# Plan auslesen (alle Tasks) und Aufwaende summieren
179
	$query = "select al_hours, al_pstart, al_phase, ta_name, ta_notiz,";
180
	$query .= "kl_land, kp_phase from ";
181
	$query .= "allocation, mitarbeiter, task, key_land, key_phase ";
182
	$query .= "where mi_num = al_ressource and kl_num = mi_land and ";
183
	$query .= "ta_num = al_task and kp_num = al_phase and ta_plnum = $pl_num ";
184
	$query .= "and ta_meeting = 0 ";
185
	$query .= "order by al_phase, al_pstart, mi_land, ta_id";
186
	$result = QueryDB($db, $query);
187
 
188
	if (!$result) {
189
	   closeDB($db);
190
	   return;
191
	}
192
 
193
	$numrows = numrowsDB($result);
194
 
195
	if ($numrows <= 0) {
196
	   Error("Der von Ihnen gew&auml;hlte Plan $pl_num enth&auml;lt keine Tasks!");
197
	   closeDB($db);
198
	   return;
199
	}
200
 
201
	$rows = 0;
202
	$sum = 0.0;
203
	$total = 0.0;
204
	$j = 0;
205
	$m = 0;
206
	$r = 0;
207
	$oldland = "";
208
 
209
	while ($rows < $numrows) {
210
	   $data = fetchDB($result, $rows);
211
	   $al_hours = $data[0];
212
	   $al_pstart = $data[1];
213
	   $al_phase = $data[2];
214
	   $ta_name = $data[3];
215
	   $ta_notiz = $data[4];
216
	   $kl_land = $data[5];
217
	   $kp_phase = $data[6];
218
 
219
	   $jahr = gmdate("Y", $al_pstart);
220
	   $mon = gmdate("n", $al_pstart);
221
 
222
	   if ($rows == 0) {
223
	      $old['jahr'] = $jahr;
224
	      $old['mon'] = $mon;
225
	      $old['land'] = $kl_land;
226
	      $old['phase'] = $al_phase;
227
	      $old['tphase'] = $kp_phase;
228
	      $old['name'] = $ta_name;
229
	      $oldnotiz = $ta_notiz;
230
	   }
231
 
232
	   if ($old['jahr'] != $jahr || $old['mon'] != $mon || $old['land'] != $kl_land || $old['phase'] != $al_phase || $old['name'] != $ta_name) {
233
	      if ($phase)
234
	         echo "<tr><td>" . $old['phase'] . " " . $old['tphase'] . "</td>";
235
	      else
236
	         echo "<tr>";
237
 
238
	      echo "<td>" . $old['name'] . "</td>";
239
	      echo "<td>$oldnotiz</td>";
240
	      echo "<td>" . $old['land'] . "</td>";
241
	      echo "<td align=\"center\">" . $old['mon'] . "</td>";
242
	      echo "<td align=\"center\">" . $old['jahr'] . "</td>";
243
	      printf ("<td align=\"right\">%s</td></tr>\n", FormatNum($sum, 3));
244
	      $sum = 0;
245
	      $old['jahr'] = $jahr;
246
	      $old['mon'] = $mon;
247
	      $old['land'] = $kl_land;
248
	      $old['phase'] = $al_phase;
249
	      $old['tphase'] = $kp_phase;
250
	      $old['name'] = $ta_name;
251
	      $oldnotiz = "";
252
	      $r = $rows;
253
	   }
254
 
255
	   $sum += $al_hours;
256
	   $total += $al_hours;
257
 
258
	   if (strlen($ta_notiz)) {
259
	      if (strlen($oldnotiz))
260
	         $oldnotiz .= "<br>";
261
 
262
	      $oldnotiz .= $ta_notiz;
263
	   }
264
 
265
	   $rows++;
266
	}
267
 
268
	if ($r != $rows) {
269
	   if ($phase)
270
	      echo "<tr><td>$al_phase $kp_phase</td>";
271
	   else
272
	      echo "<tr>";
273
 
274
	   echo "<td>$ta_name</td>";
275
	   echo "<td>$ta_notiz</td>";
276
	   echo "<td>$kl_land</td>";
277
	   echo "<td align=\"center\">$mon</td>";
278
	   echo "<td align=\"center\">$jahr</td>";
279
	   printf ("<td align=\"right\">%s</td></tr>\n", FormatNum($sum, 3));
280
	}
281
 
282
	# Anzeigen der Summe
283
	if ($phase)
284
	   $span = 6;
285
	else
286
	   $span = 5;
287
 
288
	printf ("<tr><td colspan=$span class=\"stbb\">Summe:</td><td align=\"right\"><b>%s</b></td></tr>\n", FormatNum($total, 3));
289
	echo "</table>\n";
290
	closeDB($db);
291
}
292
 
293
function CreateTempPlan($db, $pl_num, $prnum) {
294
	global $leneinheit;
295
 
296
	# Als erstes erzeugen wir eine temporaere Tabelle in die wir die
297
	# einzelnen Daten unseres Plans zusammentragen und korrekt zuordnen.
298
	#
299
	$query = "create local temporary table TempPlan (";
300
	$query .= "tmp_lfd integer not null unique, tmp_miname integer,";
301
	$query .= "tmp_phase integer, tmp_periode integer, tmp_plan double precision,";
302
	$query .= "tmp_ist double precision, tmp_taname varchar(50), tmp_notiz varchar(8192),";
303
	$query .= "constraint \"tempplan_pkey\" primary key (\"tmp_lfd\"))";
304
	$result = QueryDB($db, $query);
305
 
306
	if (!$result)
307
	   return false;
308
 
309
	# Nun erzeugen wir einen Plan, ausgehend von den Tasks. Das ist der
310
	# erste von insgesamt zwei Schritten!
311
	#
312
	$query = "select al_hours, al_pstart, al_phase, ta_name, ta_notiz,";
313
	$query .= "al_ressource from allocation, task where ";
314
	$query .= "ta_num = al_task and ta_plnum = $pl_num ";
315
	$query .= "and ta_meeting = 0";
316
	$result = QueryDB($db, $query);
317
 
318
	if (!$result)
319
	   return false;
320
 
321
	$numrows = numrowsDB($result);
322
 
323
	if ($numrows <= 0) {
324
	   Error("Der von Ihnen gew&auml;hlte Plan $pl_num enth&auml;lt keine Tasks!");
325
	   return false;
326
	}
327
 
328
	$rows = 0;
329
	$zaehler = 1;
330
 
331
	while ($rows < $numrows) {
332
	   $data = fetchDB($result, $rows);
333
	   $al_hours = $data[0];
334
	   $al_pstart = $data[1];
335
	   $al_phase = $data[2];
336
	   $ta_name = $data[3];
337
	   $ta_notiz = $data[4];
338
	   $al_ressource = $data[5];
339
 
340
	   $mon = gmdate("n", $al_pstart);
341
	   $year = gmdate("Y", $al_pstart);
342
	   $al_pstart = gmmktime(0, 0, 0, $mon, 1, $year);
343
 
344
	   $query = "insert into TempPlan (tmp_lfd, tmp_miname, tmp_phase,";
345
	   $query .= "tmp_periode, tmp_plan, tmp_ist, tmp_taname, tmp_notiz) ";
346
	   $query .= "values ($zaehler, $al_ressource, $al_phase, $al_pstart,";
347
	   $query .= "$al_hours, 0, '$ta_name', '$ta_notiz')";
348
 
349
	   if (!QueryDB($db, $query))
350
	      return false;
351
 
352
	   $rows++;
353
	   $zaehler++;
354
	}
355
 
356
	# Nun suchen wir alle IST-Meldungen und ergaenzen die Daten, sofern
357
	# sie bereits vorhanden sind, oder fuegen einen neuen Datensatz ein.
358
	#
359
	$query = "select wd_minum, wd_datum, wd_hours / $leneinheit, wd_phase, ";
360
	$query .= "ta_name from wdone, task where ";
361
	$query .= "wd_prnum = $prnum and ta_num = wd_task";
362
	$result = QueryDB($db, $query);
363
 
364
	if (!$result)
365
	   return false;
366
 
367
	$numrows = numrowsDB($result);
368
 
369
	if ($numrows <= 0) {
370
	   Error("Der von Ihnen gew&auml;hlte Plan $pl_num enth&auml;lt keine IST-Buchungen!");
371
	   return true;
372
	}
373
 
374
	$rows = 0;
375
 
376
	while ($rows < $numrows) {
377
	   $data = fetchDB($result, $rows);
378
	   $wd_minum = $data[0];
379
	   $wd_datum = $data[1];
380
	   $wd_ist = $data[2];
381
	   $wd_phase = $data[3];
382
	   $ta_name = $data[4];
383
 
384
	   $mon = gmdate("n", $wd_datum);
385
	   $year = gmdate("Y", $wd_datum);
386
	   $per = gmmktime(0, 0, 0, $mon, 1, $year);
387
	   $query = "select tmp_lfd, tmp_ist from TempPlan where ";
388
	   $query .= "tmp_miname = $wd_minum and tmp_periode = $per ";
389
	   $query .= "and tmp_taname = '$ta_name'";
390
	   $result2 = QueryDB($db, $query);
391
 
392
	   if (!$result2)
393
	      return false;
394
 
395
	   $nr = numrowsDB($result2);
396
 
397
	   if ($nr > 0) {
398
	      $data = fetchDB($result2, 0);
399
	      $tmp_lfd = $data[0];
400
	      $tmp_ist = $data[1];
401
 
402
	      $wd_ist += $tmp_ist;
403
 
404
	      $query = "update TempPlan set tmp_ist = $wd_ist ";
405
	      $query .= "where tmp_lfd = $tmp_lfd";
406
 
407
	      if (!QueryDB($db, $query))
408
	         return false;
409
	   } else {
410
	      $mon = gmdate("n", $wd_datum);
411
	      $year = gmdate("Y", $wd_datum);
412
	      $wd_datum = gmmktime(0, 0, 0, $mon, 1, $year);
413
 
414
	      $query = "insert into TempPlan (tmp_lfd, tmp_miname, tmp_phase,";
415
	      $query .= "tmp_periode, tmp_plan, tmp_ist, tmp_taname) ";
416
	      $query .= "values ($zaehler, $wd_minum, $wd_phase, $wd_datum,";
417
	      $query .= "0, $wd_ist, '$ta_name')";
418
 
419
	      if (!QueryDB($db, $query))
420
	         return false;
421
 
422
	      $zaehler++;
423
	   }
424
 
425
	   $rows++;
426
	}
427
 
428
	return true;
429
}
430
 
431
function ShowPlanDetail($print=false) {
432
	global $leneinheit;
433
	global $phase;
434
	$pl_num = $_REQUEST['pl_num'];
435
 
436
	$db = OpenDB();
437
	# Ermitteln der Projektnummer
438
	$query = "select pl_prnum from plan where pl_num = $pl_num";
439
	$result = QueryDB($db, $query);
440
 
441
	if (!$result) {
442
	   closeDB($db);
443
	   return;
444
	}
445
 
446
	$data = fetchDB($result, 0);
447
	$prnum = $data[0];
448
 
449
	# Folgende Funktion erzeugt uns einen Plan mit zugehoerigen IST-Werten,
450
	# wobei diese bereits innerhalb einer Periode aufsummiert wurden.
451
	#
452
	if (CreateTempPlan($db, $pl_num, $prnum) == false) {
453
	   closeDB($db);
454
	   return;
455
	}
456
 
457
	# Tabellenkopf
458
?>
459
<table width="99%" border=1>
460
   <tr>
461
<?
462
	if ($phase) {
463
	   echo "<td class=\"stbb\">Phase</td>\n";
464
	   echo "<td class=\"stbb\">Subphasen</td>\n";
465
	} else {
466
	   echo "<td class=\"stbb\">Task</td>\n";
467
	}
468
?>
469
      <td class="stbb">Aktivit&auml;t/T&auml;tigkeit</td>
470
      <td class="stbb">Ressource</td>
471
      <td class="stbb">Gruppe</td>
472
      <td class="stbb">Monat</td>
473
      <td class="stbb">Jahr</td>
474
      <td class="stbb">Ist</td>
475
      <td class="stbb">Rest</td>
476
      <td class="stbb">RM&nbsp;aktuell</td>
477
   </tr>
478
<?php
479
	# Auslesen der zuvor temporaer erzeugten Tabelle und Darstellung
480
	# der Inhalte.
481
	#
482
	$query = "select tmp_miname, tmp_phase, tmp_periode, tmp_plan,";
483
	$query .= "tmp_ist, tmp_taname, tmp_notiz, mi_nname, mi_vname,";
484
	$query .= "kl_land, kp_phase from TempPlan, mitarbeiter, key_land,";
485
	$query .= "key_phase where mi_num = tmp_miname and kl_num = mi_land ";
486
	$query .= "and kp_num = tmp_phase ";
487
	$query .= "order by tmp_phase, tmp_periode, mi_nname, mi_vname";
488
	$result = QueryDB($db, $query);
489
 
490
	if (!$result) {
491
	   closeDB($db);
492
	   return;
493
	}
494
 
495
	$numrows = numrowsDB($result);
496
 
497
	if ($numrows <= 0) {
498
	   Error("Der von Ihnen gew&auml;hlte Plan $pl_num enth&auml;lt keine Tasks!");
499
	   closeDB($db);
500
	   return;
501
	}
502
 
503
	$rows = 0;
504
	$sum = 0.0;
505
	$total = 0.0;
506
	$tothour = 0.0;
507
 
508
	while ($rows < $numrows) {
509
	   $data = fetchDB($result, $rows);
510
	   $tmp_miname = $data[0];
511
	   $tmp_phase = $data[1];
512
	   $tmp_periode = $data[2];
513
	   $tmp_plan = $data[3];
514
	   $tmp_ist = $data[4];
515
	   $tmp_taname = $data[5];
516
	   $tmp_notiz = $data[6];
517
	   $mi_nname = $data[7];
518
	   $mi_vname = $data[8];
519
	   $kl_land = $data[9];
520
	   $kp_phase = $data[10];
521
 
522
	   $mon = gmdate("n", $tmp_periode);
523
	   $jahr = gmdate("Y", $tmp_periode);
524
 
525
	   # Schreiben der Zeile
526
	   if ($phase)
527
	      echo "<tr><td>$tmp_phase $kp_phase</td>";
528
	   else
529
	      echo "<tr>";
530
 
531
	   echo "<td>$tmp_taname</td>";
532
	   echo "<td>$tmp_notiz</td>";
533
	   echo "<td>$mi_nname $mi_vname</td>";
534
	   echo "<td>$kl_land</td>";
535
	   echo "<td align=\"center\">$mon</td>";
536
	   echo "<td align=\"center\">$jahr</td>";
537
	   printf ("<td align=\"right\">%s</td>", FormatNum($tmp_ist, 3));
538
	   $h = $tmp_plan - $tmp_ist;
539
 
540
	   if ($h < 0)
541
	      printf ("<td align=\"right\" class=\"five\">%s</td>", FormatNum($h, 3));
542
	   else
543
	      printf ("<td align=\"right\">%s</td>", FormatNum($h, 3));
544
 
545
	   if ($tmp_ist == 0 && $tmp_plan > 0)
546
	      printf ("<td align=\"right\" class=\"green\">%s</td></tr>\n", FormatNum($tmp_plan, 3));
547
	   else
548
	      printf ("<td align=\"right\">%s</td></tr>\n", FormatNum($tmp_plan, 3));
549
 
550
	   $tothour += $tmp_plan;
551
	   $total += $h;
552
	   $sum += $tmp_ist;
553
	   $rows++;
554
	}
555
 
556
	# Anzeigen der Summen
557
	if ($phase)
558
	   $span = 7;
559
	else
560
	   $span = 6;
561
 
562
	echo "<tr><td colspan=$span class=\"stbb\">Summe:</td>";
563
	printf("<td align=\"right\"><b>%s</b></td>", FormatNum($sum, 3));
564
	printf("<td align=\"right\"><b>%s</b></td>", FormatNum($total, 3));
565
	printf("<td align=\"right\"><b>%s</b></td></tr>\n", FormatNum($tothour, 3));
566
	echo "</table>\n";
567
	closeDB($db);
568
}
569
 
570
# Auswertung des Menues:
571
#
572
if ($knopf == 25)		// Planungshilfe
573
   Preselect();
574
 
575
# Auswertung der Funktionen
576
if ($func == "prplan") {
577
   $pl_num = $_REQUEST['pl_num'];
578
 
579
   # Ermitteln des Projektnamens und Anzeigen des selben.
580
   $db = OpenDB();
581
   $query = "select pl_prnum, pr_name from plan, project ";
582
   $query .= "where pr_num = pl_prnum and pl_num = $pl_num";
583
   $result = QueryDB($db, $query);
584
   $data = fetchDB($result, 0);
585
   $selpro = $data[0];
586
   $pr_name = $data[1];
587
   echo "<p class=\"cry\">Projekt: $selpro $pr_name</p>";
588
   echo "<br>\n";
589
   closeDB($db);
590
 
591
   echo "<a href=\"#\" onClick=\"javascript:open_mwindow('prplanhilf.php?pl_num=$pl_num&header=2&func=PrintPlan', 'Planungshilfe: $selpro $pr_name', 750, 550)\">";
592
   echo "<img src=\"image/print.png\" border=0 alt=\"Drucken\"></a>\n";
593
 
594
   ShowPlanGesamt();
595
   ShowPlanBasis();
596
   ShowPlanDetail();
597
}
598
 
599
if ($func == "PrintPlan") {
600
   $pl_num = $_REQUEST['pl_num'];
601
 
602
   # Ermitteln des Projektnamens und Anzeigen des selben.
603
   $db = OpenDB();
604
   $query = "select pl_prnum, pr_name from plan, project ";
605
   $query .= "where pr_num = pl_prnum and pl_num = $pl_num";
606
   $result = QueryDB($db, $query);
607
   $data = fetchDB($result, 0);
608
   $selpro = $data[0];
609
   $pr_name = $data[1];
610
   echo "<p class=\"cry\">Projekt: $selpro $pr_name</p>";
611
   echo "<br>\n";
612
   closeDB($db);
613
 
614
   ShowPlanGesamt(true);
615
   ShowPlanBasis(true);
616
   ShowPlanDetail(true);
617
}
618
 
619
require('footer.inc');
620
?>