4 |
andreas |
1 |
<?php
|
|
|
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 |
$drm = array(true, false, false, false, false, true, false, true);
|
|
|
11 |
|
|
|
12 |
$knopf = 0;
|
|
|
13 |
$func = $_REQUEST['func'];
|
|
|
14 |
|
|
|
15 |
# Auswertungsmenue
|
|
|
16 |
if (isset($_REQUEST['pjplan'])) { $knopf = 21; $headline = 27; }
|
|
|
17 |
|
|
|
18 |
require_once('menu.inc');
|
|
|
19 |
require_once('knumber.inc');
|
|
|
20 |
|
|
|
21 |
# Folgende Funktion erlaubt die Auswahl eines Projekts dessen Plan
|
|
|
22 |
# erzeugt werden soll.
|
|
|
23 |
#
|
|
|
24 |
function Preselect() {
|
|
|
25 |
global $periode;
|
|
|
26 |
global $unum;
|
|
|
27 |
global $menu;
|
|
|
28 |
global $rstufe;
|
|
|
29 |
global $pmlight;
|
|
|
30 |
global $dtformatshort;
|
|
|
31 |
|
|
|
32 |
$db = OpenDB();
|
|
|
33 |
?>
|
|
|
34 |
<form name="preselect" action="printplan.php" method="post">
|
|
|
35 |
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
|
|
|
36 |
<input type="hidden" name="headline" value="27">
|
|
|
37 |
<input type="hidden" name="func" value="printplan">
|
|
|
38 |
|
|
|
39 |
<table class="input">
|
|
|
40 |
<?php
|
|
|
41 |
# Auswahl eines Projekts
|
|
|
42 |
echo "<tr><td>Projektauswahl:</td>\n";
|
|
|
43 |
echo "<td>";
|
|
|
44 |
|
|
|
45 |
$query = "select pl_num, pl_prnum, pl_lfd, pr_name, pl_status from ";
|
|
|
46 |
$query .= "plan, project where pr_num = pl_prnum and pr_status = 0 ";
|
|
|
47 |
$query .= "order by pl_prnum, pl_lfd desc";
|
|
|
48 |
|
|
|
49 |
$result = QueryDB($db, $query);
|
|
|
50 |
|
|
|
51 |
if (!$result) {
|
|
|
52 |
closeDB($db);
|
|
|
53 |
return;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
echo "<select name=\"pl_num\">\n";
|
|
|
57 |
$numrows = numrowsDB($result);
|
|
|
58 |
$rows = 0;
|
|
|
59 |
|
|
|
60 |
while ($rows < $numrows) {
|
|
|
61 |
$data = fetchDB($result, $rows);
|
|
|
62 |
$pl_num = $data[0];
|
|
|
63 |
$pl_prnum = $data[1];
|
|
|
64 |
$pl_lfd = $data[2];
|
|
|
65 |
$pr_name = $data[3];
|
|
|
66 |
$pl_status = $data[4];
|
|
|
67 |
|
|
|
68 |
switch ($pl_status) {
|
|
|
69 |
case 1: $stat = "In Erstellung"; break;
|
|
|
70 |
case 2: $stat = "Freigegeben"; break;
|
|
|
71 |
case 3: $stat = ""; break;
|
|
|
72 |
case 4: $stat = "Aktiv"; break;
|
|
|
73 |
case 5: $stat = "Inaktiv"; break;
|
|
|
74 |
case 6: $stat = "Abgeschlossen"; break;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
echo "<option value=\"$pl_num\">$pl_lfd ($stat): $pl_prnum $pr_name</option>\n";
|
|
|
78 |
$rows++;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
echo "</select>";
|
|
|
82 |
echo "</td></tr>\n";
|
|
|
83 |
echo "<tr><td>IST-Werte berücksichtigen bis:</td>\n";
|
|
|
84 |
$sd = GetVisualDate($dtformatshort, true);
|
|
|
85 |
|
|
|
86 |
if (!$pmlight) {
|
|
|
87 |
$dat = time();
|
|
|
88 |
$day = gmdate("j", $dat);
|
|
|
89 |
$mon = gmdate("n", $dat);
|
|
|
90 |
$year = gmdate("Y", $dat);
|
|
|
91 |
$dm = daysinmonth($mon, $year);
|
|
|
92 |
|
|
|
93 |
if ($day < ($dm / 2)) {
|
|
|
94 |
$mon--;
|
|
|
95 |
|
|
|
96 |
if ($mon < 1) {
|
|
|
97 |
$year--;
|
|
|
98 |
$mon = 12;
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
$vd = GetShortDate(gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year));
|
|
|
103 |
} else
|
|
|
104 |
$vd = "";
|
|
|
105 |
|
|
|
106 |
echo "<td><input type=\"text\" name=\"datum\" value=\"$vd\" size=7 maxlength=7> $sd</td></tr>\n";
|
|
|
107 |
echo "</table>\n";
|
|
|
108 |
echo "<table class=\"indent\"><tr><td>";
|
|
|
109 |
ButtonSubmit("Senden", "preselect");
|
|
|
110 |
echo "</td></tr></table>\n";
|
|
|
111 |
echo "</form>\n";
|
|
|
112 |
closeDB($db);
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
function GetWD_HOURS($db, $dt, $ressource, $hash) {
|
|
|
116 |
global $leneinheit;
|
|
|
117 |
|
|
|
118 |
$mon = gmdate("n", $dt);
|
|
|
119 |
$year = gmdate("Y", $dt);
|
|
|
120 |
$dta = gmmktime(0, 0, 0, $mon, 1, $year);
|
|
|
121 |
$dte = gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year);
|
|
|
122 |
$query = "select sum(wd_hours)/$leneinheit from wdone where ";
|
|
|
123 |
$query .= "wd_minum = $ressource and ";
|
|
|
124 |
$query .= "wd_datum between $dta and $dte and ";
|
|
|
125 |
$query .= "wd_task in (select ta_num from task, allocation where ";
|
|
|
126 |
$query .= "al_task = ta_num and ta_hash = '$hash' and ";
|
|
|
127 |
$query .= "al_ressource = $ressource)";
|
|
|
128 |
|
|
|
129 |
if (!($reswd = QueryDB($db, $query)))
|
|
|
130 |
return 0;
|
|
|
131 |
|
|
|
132 |
if (numrowsDB($reswd)> 0) {
|
|
|
133 |
$data = fetchDB($reswd, 0);
|
|
|
134 |
$wd_hours = $data[0];
|
|
|
135 |
} else
|
|
|
136 |
$wd_hours = 0;
|
|
|
137 |
|
|
|
138 |
return $wd_hours;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
function PrintMa($db, $dstart, $dend, $al_task, $color, $pl_num, $ressource) {
|
|
|
142 |
global $periode;
|
|
|
143 |
global $einheit;
|
|
|
144 |
global $leneinheit;
|
|
|
145 |
global $menu;
|
|
|
146 |
global $role;
|
|
|
147 |
global $pmlight;
|
|
|
148 |
|
|
|
149 |
$nav = "pl_num=$pl_num&al_task=$al_task&menu=$menu&headline=20";
|
|
|
150 |
$dt = $_REQUEST['datum'];
|
|
|
151 |
|
|
|
152 |
if (isset($dt) && strlen($dt) > 0) {
|
|
|
153 |
$darr = explode(".", $dt);
|
|
|
154 |
$datum = gmmktime(0, 0, 0, $darr[0], daysinmonth($darr[0], $darr[1]), $darr[1]);
|
|
|
155 |
} else
|
|
|
156 |
$datum = 0;
|
|
|
157 |
|
|
|
158 |
$query = "select am_num, am_task, am_ressource, am_hours, am_pstart,";
|
|
|
159 |
$query .= "am_pduration, am_role, am_krnum, am_nname, am_vname, am_phase ";
|
|
|
160 |
$query .= "from allocmi where am_task = $al_task order by ";
|
|
|
161 |
$query .= "am_nname, am_vname, am_pstart";
|
|
|
162 |
$erg = QueryDB($db, $query);
|
|
|
163 |
|
|
|
164 |
if (!$erg)
|
|
|
165 |
return 0;
|
|
|
166 |
|
|
|
167 |
$erganz = numrowsDB($erg);
|
|
|
168 |
$ergrow = 0;
|
|
|
169 |
$oressource = 0;
|
|
|
170 |
$dt = 0;
|
|
|
171 |
$sum = 0;
|
|
|
172 |
$sumi = 0;
|
|
|
173 |
$sumip = 0;
|
|
|
174 |
$total = 0;
|
|
|
175 |
|
|
|
176 |
while ($ergrow < $erganz) {
|
|
|
177 |
$data = fetchDB($erg, $ergrow);
|
|
|
178 |
$am_num = $data[0];
|
|
|
179 |
$am_task = $data[1];
|
|
|
180 |
$am_ressource = $data[2];
|
|
|
181 |
$am_hours = $data[3];
|
|
|
182 |
$am_pstart = $data[4];
|
|
|
183 |
$am_pduration = $data[5];
|
|
|
184 |
$am_role = $data[6];
|
|
|
185 |
$am_krnum = $data[7];
|
|
|
186 |
$am_nname = $data[8];
|
|
|
187 |
$am_vname = $data[9];
|
|
|
188 |
$am_phase = $data[10];
|
|
|
189 |
|
|
|
190 |
if ($oressource != $am_ressource) {
|
|
|
191 |
if ($oressource != 0) {
|
|
|
192 |
$ed = GetEDate($einheit, $ta_start, $ta_duration);
|
|
|
193 |
|
|
|
194 |
if ($dt < $ed) {
|
|
|
195 |
while (PerDateComp($dt, $ed) >= 0) {
|
|
|
196 |
if ($datum > 0 && $dt <= $datum) {
|
|
|
197 |
$wd_hours = GetWD_HOURS($db, $dt, $oressource, $ta_hash);
|
|
|
198 |
$sumip += $wd_hours;
|
|
|
199 |
|
|
|
200 |
if ($wd_hours > 0)
|
|
|
201 |
printf("<td style=\"background-color: #$color; border: 1px solid black;\">I: %s</td>\n",
|
|
|
202 |
FormatNum($wd_hours, 3));
|
|
|
203 |
else
|
|
|
204 |
echo "<td style=\"background-color: #$color; border: 1px solid black;\"> </td>\n";
|
|
|
205 |
} else
|
|
|
206 |
echo "<td style=\"background-color: #$color; border: 1px solid black;\"> </td>\n";
|
|
|
207 |
|
|
|
208 |
$dt = IncDate($periode, $dt);
|
|
|
209 |
}
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
while (PerDateComp($dt, $dend) >= 0) {
|
|
|
213 |
if ($datum > 0 && $dt <= $datum) {
|
|
|
214 |
if (($wd_hours = GetWD_HOURS($db, $dt, $oressource, $ta_hash)) > 0) {
|
|
|
215 |
printf("<td class=\"selnum\">I: %s</td>\n", FormatNum($wd_hours, 3));
|
|
|
216 |
$sumip += $wd_hours;
|
|
|
217 |
} else
|
|
|
218 |
echo "<td class=\"sel\"> </td>";
|
|
|
219 |
} else
|
|
|
220 |
echo "<td class=\"sel\"> </td>";
|
|
|
221 |
|
|
|
222 |
$dt = IncDate($periode, $dt);
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
echo "<td class=\"selnum\"";
|
|
|
226 |
|
|
|
227 |
if ($datum > 0)
|
|
|
228 |
printf("<b>%s</b></td>", FormatNum($sumip, 3));
|
|
|
229 |
else
|
|
|
230 |
printf("><b>%s</b></td>", FormatNum($sum, 3));
|
|
|
231 |
|
|
|
232 |
$total += $sumip;
|
|
|
233 |
$sum = 0;
|
|
|
234 |
$sumi = 0;
|
|
|
235 |
$sumip = 0;
|
|
|
236 |
echo "</tr>\n";
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
# Starrer Zeilenbegin ...
|
|
|
240 |
echo "<tr>\n";
|
|
|
241 |
# Nummerierung
|
|
|
242 |
echo "<td class=\"sel\"> </td>\n";
|
|
|
243 |
# Ressource
|
|
|
244 |
echo "<td class=\"sel\" colspan=2 width=\"20%\"> </td>\n";
|
|
|
245 |
echo "<td class=\"sel\"><i>$am_nname $am_vname</i></td>\n";
|
|
|
246 |
# Tasklaenge mit Einheit
|
|
|
247 |
echo "<td class=\"sel\" colspan=3> </td>\n";
|
|
|
248 |
# Mitarbeiterrolle
|
|
|
249 |
if ($role)
|
|
|
250 |
echo "<td class=\"sel\">$am_role</td>\n";
|
|
|
251 |
|
|
|
252 |
# Zellen bis zum Taskanfang schreiben
|
|
|
253 |
$query = "select ta_start, ta_duration, ta_hash from task where ta_num = $am_task";
|
|
|
254 |
|
|
|
255 |
if (!($res = QueryDB($db, $query))) {
|
|
|
256 |
Error("Keinen dazupassenden Task gefunden!");
|
|
|
257 |
return 0;
|
|
|
258 |
}
|
|
|
259 |
|
|
|
260 |
$data = fetchDB($res, 0);
|
|
|
261 |
$ta_start = $data[0];
|
|
|
262 |
$ta_duration = $data[1];
|
|
|
263 |
$ta_hash = $data[2];
|
|
|
264 |
$dt = $dstart;
|
|
|
265 |
|
|
|
266 |
while (PerDateComp($dt, $ta_start) > 0) {
|
|
|
267 |
if ($datum > 0 && $dt <= $datum) {
|
|
|
268 |
if (($wd_hours = GetWD_HOURS($db, $dt, $am_ressource, $ta_hash)) > 0) {
|
|
|
269 |
printf("<td class=\"selnum\">I: %s</td>\n", FormatNum($wd_hours, 3));
|
|
|
270 |
$sumip += $wd_hours;
|
|
|
271 |
} else
|
|
|
272 |
echo "<td class=\"sel\"> </td>\n";
|
|
|
273 |
} else
|
|
|
274 |
echo "<td class=\"sel\"> </td>";
|
|
|
275 |
|
|
|
276 |
$dt = IncDate($periode, $dt);
|
|
|
277 |
}
|
|
|
278 |
|
|
|
279 |
$oressource = $am_ressource;
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
# Rest der Zeile schreiben
|
|
|
283 |
$PerStart = GetPeriode($am_pstart);
|
|
|
284 |
$pyear = gmdate("Y", $am_pstart);
|
|
|
285 |
$PerAkt = GetPeriode($dt);
|
|
|
286 |
$tyear = gmdate("Y", $dt);
|
|
|
287 |
|
|
|
288 |
# Wurde ein gueltiges Datum angegeben, dann blenden wir
|
|
|
289 |
# die IST-Daten zum Task ein.
|
|
|
290 |
if ($datum > 0 && $dt <= $datum) {
|
|
|
291 |
$wd_hours = GetWD_HOURS($db, $dt, $am_ressource, $ta_hash);
|
|
|
292 |
$sumi += $wd_hours;
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
if ($PerStart == $PerAkt && $pyear == $tyear) {
|
|
|
296 |
echo "<td style=\"background-color: #$color; text-align: right; border: 1px solid black;\">";
|
|
|
297 |
|
|
|
298 |
if ($datum > 0 && $dt <= $datum)
|
|
|
299 |
printf("I: %s</td>\n", FormatNum($wd_hours, 3));
|
|
|
300 |
else if ($datum > 0)
|
|
|
301 |
printf("P: %s</td>\n", FormatNum($am_hours, 3));
|
|
|
302 |
else
|
|
|
303 |
printf("%s</td>\n", FormatNum($am_hours, 3));
|
|
|
304 |
|
|
|
305 |
$sum += $am_hours;
|
|
|
306 |
|
|
|
307 |
if ($datum > 0 && $dt > $datum)
|
|
|
308 |
$sumip += $am_hours;
|
|
|
309 |
else if ($datum > 0 && $dt <= $datum)
|
|
|
310 |
$sumip += $wd_hours;
|
|
|
311 |
|
|
|
312 |
$ergrow++;
|
|
|
313 |
} else if ($datum > 0 && $wd_hours > 0 && $dt <= $datum) {
|
|
|
314 |
printf("<td style=\"background-color: #$color; text-align: right; border: 1px solid black;\">I: %s</td>\n",
|
|
|
315 |
FormatNum($wd_hours, 3));
|
|
|
316 |
$sumip += $wd_hours;
|
|
|
317 |
} else
|
|
|
318 |
echo "<td style=\"background-color: #$color; border: 1px solid black;\"> </td>\n";
|
|
|
319 |
|
|
|
320 |
$dt = IncDate($periode, $dt);
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
if ($erganz > 0) {
|
|
|
324 |
$ed = GetEDate($einheit, $ta_start, $ta_duration);
|
|
|
325 |
|
|
|
326 |
if ($dt < $ed) {
|
|
|
327 |
while (PerDateComp($dt, $ed) >= 0) {
|
|
|
328 |
if ($datum > 0 && $dt <= $datum) {
|
|
|
329 |
$wd_hours = GetWD_HOURS($db, $dt, $am_ressource, $ta_hash);
|
|
|
330 |
$sumip += $wd_hours;
|
|
|
331 |
|
|
|
332 |
if ($wd_hours > 0)
|
|
|
333 |
printf ("<td style=\"background-color: #$color; border: 1px solid black;\">I: %s</td>\n",
|
|
|
334 |
FormatNum($wd_hours, 3));
|
|
|
335 |
else
|
|
|
336 |
echo "<td style=\"background-color: #$color; border: 1px solid black;\"> </td>\n";
|
|
|
337 |
} else
|
|
|
338 |
echo "<td style=\"background-color: #$color; border: 1px solid black;\"> </td>\n";
|
|
|
339 |
|
|
|
340 |
$dt = IncDate($periode, $dt);
|
|
|
341 |
}
|
|
|
342 |
}
|
|
|
343 |
|
|
|
344 |
while (PerDateComp($dt, $dend) >= 0) {
|
|
|
345 |
if ($datum > 0 && $dt <= $datum) {
|
|
|
346 |
$wd_hours = GetWD_HOURS($db, $dt, $am_ressource, $ta_hash);
|
|
|
347 |
$sumip += $wd_hours;
|
|
|
348 |
|
|
|
349 |
if ($wd_hours > 0)
|
|
|
350 |
printf ("<td class=\"selnum\">I: %s</td>\n",
|
|
|
351 |
FormatNum($wd_hours, 3));
|
|
|
352 |
else
|
|
|
353 |
echo "<td class=\"sel\"> </td>\n";
|
|
|
354 |
} else
|
|
|
355 |
echo "<td class=\"sel\"> </td>";
|
|
|
356 |
|
|
|
357 |
$dt = IncDate($periode, $dt);
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
echo "<td class=\"selnum\">";
|
|
|
361 |
|
|
|
362 |
if ($datum > 0)
|
|
|
363 |
printf("<b>%s</b></td>", FormatNum($sumip, 3));
|
|
|
364 |
else
|
|
|
365 |
printf("<b>%s</b></td>", FormatNum($sum, 3));
|
|
|
366 |
|
|
|
367 |
$total += $sumip;
|
|
|
368 |
echo "</tr>\n";
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
return $total;
|
|
|
372 |
}
|
|
|
373 |
|
|
|
374 |
# Folgende Funktion zeichnet einen Plan in einer Form, welche gedruckt
|
|
|
375 |
# werden kann.
|
|
|
376 |
# Es wird immer der Zeitraum vom Start des Projekts bis zu seinem Ende
|
|
|
377 |
# dargestellt. Bei sehr langen Projekten oder sehr kleinen Perioden, kann
|
|
|
378 |
# die Tabelle durchaus sehr breit werden.
|
|
|
379 |
#
|
|
|
380 |
function PrintPlan($pl_num) {
|
|
|
381 |
global $rstufe;
|
|
|
382 |
global $unum;
|
|
|
383 |
global $periode;
|
|
|
384 |
global $verteil;
|
|
|
385 |
global $einheit;
|
|
|
386 |
global $menu;
|
|
|
387 |
global $dtformatshort;
|
|
|
388 |
global $role;
|
|
|
389 |
global $leneinheit;
|
|
|
390 |
|
|
|
391 |
if ($pl_num <= 0) {
|
|
|
392 |
Error("Interner Fehler: Es wurde keine Plannummer an \"PrintPlan\" übergeben!");
|
|
|
393 |
return;
|
|
|
394 |
}
|
|
|
395 |
|
|
|
396 |
if ($rstufe == 0 || $rstufe == 5 || $rstufe == 7) {
|
|
|
397 |
Error("Berechtigungsfehler!");
|
|
|
398 |
return;
|
|
|
399 |
}
|
|
|
400 |
|
|
|
401 |
$dt = $_REQUEST['datum'];
|
|
|
402 |
|
|
|
403 |
if (isset($dt) && strlen($dt) > 0) {
|
|
|
404 |
$darr = explode(".", $dt);
|
|
|
405 |
$datum = gmmktime(0, 0, 0, $darr[0], daysinmonth($darr[0], $darr[1]), $darr[1]);
|
|
|
406 |
} else
|
|
|
407 |
$datum = 0;
|
|
|
408 |
|
|
|
409 |
$db = OpenDB();
|
|
|
410 |
$query = "select pr_name, pl_prnum, mi_nname, mi_vname from ";
|
|
|
411 |
$query .= "plan, project, mitarbeiter where pl_num = $pl_num and ";
|
|
|
412 |
$query .= "pr_num = pl_prnum and mi_num = pr_pl";
|
|
|
413 |
$result = QueryDB($db, $query);
|
|
|
414 |
|
|
|
415 |
if (!$result) {
|
|
|
416 |
closeDB($db);
|
|
|
417 |
return;
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
$data = fetchDB($result, 0);
|
|
|
421 |
$pr_name = $data[0];
|
|
|
422 |
$pl_prnum = $data[1];
|
|
|
423 |
$mi_nname = $data[2];
|
|
|
424 |
$mi_vname = $data[3];
|
|
|
425 |
echo "<table class=\"sel\"><tr><td class=\"selakt\"><table border=0>";
|
|
|
426 |
echo "<tr><td>Projekt:</td><td>$pl_prnum $pr_name</td></tr>\n";
|
|
|
427 |
echo "<tr><td>Projektleiter:</td><td>$mi_nname $mi_vname</td></tr>\n";
|
|
|
428 |
# Anzeigen, bis zu welchem Datum IST-Buchungen beruecksichtigt
|
|
|
429 |
# werden.
|
|
|
430 |
if ($datum > 0) {
|
|
|
431 |
echo "<tr><td>IST−Buchungen berücksichtigt bis:</td>";
|
|
|
432 |
echo "<td>" . GetShortDate($datum) . "</td></tr>\n";
|
|
|
433 |
}
|
|
|
434 |
|
|
|
435 |
echo "</table></tr></td></table>\n";
|
|
|
436 |
# Zeichnen der fixen Kopfspalten.
|
|
|
437 |
$nav = "pl_num=$pl_num&menu=$menu&headline=27";
|
|
|
438 |
?>
|
|
|
439 |
<table class="sel">
|
|
|
440 |
<tr>
|
|
|
441 |
<th class="sel" rowspan=2>Num.</th>
|
|
|
442 |
<th class="sel" colspan=3 rowspan=2>
|
|
|
443 |
<table border=0 width="100%"><tr><td align="center" colspan=2>Taskname</td></tr>
|
|
|
444 |
<tr><td> </td><td align="right">Ressource</td></tr>
|
|
|
445 |
</table>
|
|
|
446 |
</th>
|
|
|
447 |
<th class="sel" rowspan=2 colspan=3>
|
|
|
448 |
<table border=0 width="100%"><tr><td align="center" colspan=3>Arbeit</td></tr>
|
|
|
449 |
<td align="center">Dauer</td>
|
|
|
450 |
<td align="center">Start</td>
|
|
|
451 |
<td align="center">Ende</td></tr>
|
|
|
452 |
</table>
|
|
|
453 |
</th>
|
|
|
454 |
<?php
|
|
|
455 |
if ($role)
|
|
|
456 |
echo " <th class=\"sel\" rowspan=2>Rolle</th>\n";
|
|
|
457 |
|
|
|
458 |
# Ermitteln des Projektstarts um den Tabellenkopf fertig zu schreiben.
|
|
|
459 |
$query = "select ta_start, ta_duration, ta_meeting from task where ";
|
|
|
460 |
$query .= "ta_plnum = $pl_num order by ta_start";
|
|
|
461 |
$result = QueryDB($db, $query);
|
|
|
462 |
|
|
|
463 |
if (!$result) {
|
|
|
464 |
closeDB($db);
|
|
|
465 |
return;
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
$numrows = numrowsDB($result);
|
|
|
469 |
$row = 0;
|
|
|
470 |
$fdate = 0;
|
|
|
471 |
$ldate = 0;
|
|
|
472 |
|
|
|
473 |
while ($row < $numrows) {
|
|
|
474 |
$data = fetchDB($result, $row);
|
|
|
475 |
$ta_start = $data[0];
|
|
|
476 |
$ta_duration = $data[1];
|
|
|
477 |
$ta_meeting = $data[2];
|
|
|
478 |
|
|
|
479 |
if ($row == 0)
|
|
|
480 |
$fdate = $ta_start;
|
|
|
481 |
|
|
|
482 |
if ($ta_meeting)
|
|
|
483 |
$ed = $ta_start;
|
|
|
484 |
else
|
|
|
485 |
$ed = GetEDate($einheit, $ta_start, $ta_duration);
|
|
|
486 |
|
|
|
487 |
if ($ed > $ldate)
|
|
|
488 |
$ldate = $ed;
|
|
|
489 |
|
|
|
490 |
$row++;
|
|
|
491 |
}
|
|
|
492 |
|
|
|
493 |
# Erstellen des restlichen Tabellenkopfs ...
|
|
|
494 |
$tm = gmdate("j.n.Y", $fdate);
|
|
|
495 |
$dt = explode(".", $tm);
|
|
|
496 |
$smon = $dt[1];
|
|
|
497 |
$syear = $dt[2];
|
|
|
498 |
$dt = $fdate;
|
|
|
499 |
$cols = 0;
|
|
|
500 |
$tbcols = 1;
|
|
|
501 |
$oyear = $syear;
|
|
|
502 |
|
|
|
503 |
while (PerDateComp($dt, $ldate) > 0) {
|
|
|
504 |
$syear = gmdate("Y", $dt);
|
|
|
505 |
|
|
|
506 |
if ($oyear != $syear) {
|
|
|
507 |
if ($cols <= 1)
|
|
|
508 |
echo "<th class=\"sel\">$oyear</th>\n";
|
|
|
509 |
else
|
|
|
510 |
echo "<th class=\"sel\" colspan=$cols>$oyear</th>\n";
|
|
|
511 |
|
|
|
512 |
$oyear = $syear;
|
|
|
513 |
$cols = 0;
|
|
|
514 |
}
|
|
|
515 |
|
|
|
516 |
$cols++;
|
|
|
517 |
$tbcols++;
|
|
|
518 |
$dt = IncDate($periode, $dt);
|
|
|
519 |
}
|
|
|
520 |
|
|
|
521 |
$cols++;
|
|
|
522 |
|
|
|
523 |
if ($cols <= 1)
|
|
|
524 |
echo "<th class=\"sel\">$syear</th>\n";
|
|
|
525 |
else
|
|
|
526 |
echo "<th class=\"sel\" colspan=$cols>$syear</th>\n";
|
|
|
527 |
|
|
|
528 |
# Ueberschrift der letzten Spalte, welche die Summierungen der
|
|
|
529 |
# geplanten Aufwaende enthaelt.
|
|
|
530 |
echo "<th class=\"sel\" rowspan=2>Summe<br>Aufwand</th>\n";
|
|
|
531 |
echo "</tr>\n";
|
|
|
532 |
$dt = $fdate;
|
|
|
533 |
|
|
|
534 |
while (PerDateComp($dt, $ldate) >= 0) {
|
|
|
535 |
printf ("<th class=\"sel\">%s</th>\n", GetStrMonth($smon));
|
|
|
536 |
$smon++;
|
|
|
537 |
$dt = IncDate($periode, $dt);
|
|
|
538 |
|
|
|
539 |
if ($smon > 12) {
|
|
|
540 |
$syear++;
|
|
|
541 |
$smon = 1;
|
|
|
542 |
}
|
|
|
543 |
}
|
|
|
544 |
|
|
|
545 |
echo "</tr>\n";
|
|
|
546 |
|
|
|
547 |
# Nun muessen wir die Tabelle mit Inhalten fuellen
|
|
|
548 |
$query = "select ta_num, ta_id, ta_name, ta_meeting, ta_start,";
|
|
|
549 |
$query .= "ta_duration, ta_level, ta_phase, ta_color, ta_plnum ";
|
|
|
550 |
$query .= "from task where ta_plnum = $pl_num order by ta_id";
|
|
|
551 |
$result = QueryDB($db, $query);
|
|
|
552 |
|
|
|
553 |
if (!$result) {
|
|
|
554 |
closeDB($db);
|
|
|
555 |
return;
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
$numrows = numrowsDB($result);
|
|
|
559 |
$row = 0;
|
|
|
560 |
$snum = "1";
|
|
|
561 |
$ma = false;
|
|
|
562 |
$done = false;
|
|
|
563 |
$total = 0;
|
|
|
564 |
|
|
|
565 |
while ($row < $numrows) {
|
|
|
566 |
if (!$ma) {
|
|
|
567 |
$data = fetchDB($result, $row);
|
|
|
568 |
$ta_num = $data[0];
|
|
|
569 |
$ta_id = $data[1];
|
|
|
570 |
$ta_name = $data[2];
|
|
|
571 |
$ta_meeting = $data[3];
|
|
|
572 |
$ta_start = $data[4];
|
|
|
573 |
$ta_duration = $data[5];
|
|
|
574 |
$ta_level = $data[6];
|
|
|
575 |
$ta_phase = $data[7];
|
|
|
576 |
$ta_color = $data[8];
|
|
|
577 |
$ta_plnum = $data[9];
|
|
|
578 |
|
|
|
579 |
# Der Task muss oben summiert sein, also in der Taskzeile
|
|
|
580 |
# selbst. Wurde jedoch ein Datum angegeben, dann muessen wir
|
|
|
581 |
# bis zum Datum die IST-Werte summieren und erst ab da die
|
|
|
582 |
# Planwerte.
|
|
|
583 |
if ($ta_level == 1) {
|
|
|
584 |
$query = "select ta_num, ta_level, ta_name from task where ";
|
|
|
585 |
$query .= "ta_plnum = $ta_plnum and ta_id > $ta_id and ";
|
|
|
586 |
$query .= "ta_meeting = 0 order by ta_id";
|
|
|
587 |
|
|
|
588 |
if (!($resta = QueryDB($db, $query))) {
|
|
|
589 |
closeDB($db);
|
|
|
590 |
return;
|
|
|
591 |
}
|
|
|
592 |
|
|
|
593 |
$men = numrowsDB($resta);
|
|
|
594 |
$i = 0;
|
|
|
595 |
$al_hours = 0;
|
|
|
596 |
$wd_hours = 0;
|
|
|
597 |
|
|
|
598 |
while ($i < $men) {
|
|
|
599 |
$data = fetchDB($resta, $i);
|
|
|
600 |
$xnum = $data[0];
|
|
|
601 |
$xlevel = $data[1];
|
|
|
602 |
$xname = $data[2];
|
|
|
603 |
|
|
|
604 |
if ($xlevel <= $ta_level)
|
|
|
605 |
break;
|
|
|
606 |
|
|
|
607 |
$query = "select sum(al_hours) from allocation where ";
|
|
|
608 |
$query .= "al_task = $xnum and al_pstart > $datum";
|
|
|
609 |
|
|
|
610 |
if (!($resal = QueryDB($db, $query))) {
|
|
|
611 |
closeDB($db);
|
|
|
612 |
return;
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
$data = fetchDB($resal, 0);
|
|
|
616 |
$al_hours += $data[0];
|
|
|
617 |
# Summieren der IST-Werte
|
|
|
618 |
$query = "select sum(wd_hours)/$leneinheit from wdone where ";
|
|
|
619 |
$query .= "wd_datum <= $datum and ";
|
|
|
620 |
$query .= "wd_task in (select ta_num from task, plan where ";
|
|
|
621 |
$query .= "pl_num = ta_plnum and ta_name = '$xname' and ";
|
|
|
622 |
$query .= "pl_prnum = $pl_prnum)";
|
|
|
623 |
|
|
|
624 |
if (!($reswd = QueryDB($db, $query)))
|
|
|
625 |
return 0;
|
|
|
626 |
|
|
|
627 |
$data = fetchDB($reswd, 0);
|
|
|
628 |
$wd_hours += $data[0];
|
|
|
629 |
$i++;
|
|
|
630 |
}
|
|
|
631 |
} else {
|
|
|
632 |
$query = "select sum(al_hours) from allocation where ";
|
|
|
633 |
$query .= "al_task = $ta_num and al_pstart > $datum";
|
|
|
634 |
|
|
|
635 |
if (!($resal = QueryDB($db, $query))) {
|
|
|
636 |
closeDB($db);
|
|
|
637 |
return;
|
|
|
638 |
}
|
|
|
639 |
|
|
|
640 |
$data = fetchDB($resal, 0);
|
|
|
641 |
$al_hours = $data[0];
|
|
|
642 |
# Summieren der IST-Werte
|
|
|
643 |
$query = "select sum(wd_hours)/$leneinheit from wdone where ";
|
|
|
644 |
$query .= "wd_datum <= $datum and ";
|
|
|
645 |
$query .= "wd_task in (select ta_num from task, plan where ";
|
|
|
646 |
$query .= "pl_num = ta_plnum and ta_name = '$ta_name' and ";
|
|
|
647 |
$query .= "pl_prnum = $pl_prnum)";
|
|
|
648 |
|
|
|
649 |
if (!($reswd = QueryDB($db, $query)))
|
|
|
650 |
return 0;
|
|
|
651 |
|
|
|
652 |
$data = fetchDB($reswd, 0);
|
|
|
653 |
$wd_hours = $data[0];
|
|
|
654 |
}
|
|
|
655 |
}
|
|
|
656 |
|
|
|
657 |
# Starrer Zeilenbegin ...
|
|
|
658 |
echo "<tr>\n";
|
|
|
659 |
if (!$ma)
|
|
|
660 |
$snum = GetTaskNum($pl_num, $ta_id, $ta_level, $ta_phase, $ta_meeting, $snum, &$typ, $db);
|
|
|
661 |
|
|
|
662 |
# Nummerierung
|
|
|
663 |
if (!$ma) {
|
|
|
664 |
if ($ta_meeting)
|
|
|
665 |
echo "<td class=\"nwb\">$snum</td>\n";
|
|
|
666 |
else
|
|
|
667 |
echo "<td class=\"sel\">$snum</td>\n";
|
|
|
668 |
} else {
|
|
|
669 |
echo "<td class=\"sel\"> </td>\n";
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
# Tasknamendarstellung abhaenging vom Level
|
|
|
673 |
if (!$ma) {
|
|
|
674 |
if ($ta_level == 1 || !$typ) {
|
|
|
675 |
if ($ta_meeting)
|
|
|
676 |
echo "<td class=\"nwb\" colspan=3>$ta_name</td>\n";
|
|
|
677 |
else
|
|
|
678 |
echo "<td class=\"nw\" colspan=3>$ta_name</td>\n";
|
|
|
679 |
} else {
|
|
|
680 |
if ($ta_meeting)
|
|
|
681 |
echo "<td class=\"sel\" width=\"10%\"> </td><td class=\"nwb\" colspan=2>$ta_name</td>\n";
|
|
|
682 |
else
|
|
|
683 |
echo "<td class=\"sel\" width=\"10%\"> </td><td class=\"nw\" colspan=2>$ta_name</td>\n";
|
|
|
684 |
}
|
|
|
685 |
}
|
|
|
686 |
|
|
|
687 |
# Anzeigen Spalte: Arbeit
|
|
|
688 |
if (!$ta_meeting) {
|
|
|
689 |
if ($typ) {
|
|
|
690 |
$sein = GetStrEinheit($einheit);
|
|
|
691 |
echo "<td class=\"nw\" align=\"right\">$ta_duration $sein</td>\n";
|
|
|
692 |
$dt = gmdate($dtformatshort, $ta_start);
|
|
|
693 |
$ed = GetEDate($einheit, $ta_start, $ta_duration);
|
|
|
694 |
$dte = gmdate($dtformatshort, $ed);
|
|
|
695 |
echo "<td class=\"selmid\">$dt</td>\n";
|
|
|
696 |
echo "<td class=\"selmid\">$dte</td>\n";
|
|
|
697 |
} else {
|
|
|
698 |
echo "<td class=\"sel\" colspan=3> </td>\n";
|
|
|
699 |
}
|
|
|
700 |
} else {
|
|
|
701 |
echo "<td class=\"nwb\" align=\"center\">M</td>\n";
|
|
|
702 |
$dt = gmdate($dtformatshort, $ta_start);
|
|
|
703 |
echo "<td class=\"selmid\" colspan=2>$dt</td>\n";
|
|
|
704 |
}
|
|
|
705 |
|
|
|
706 |
# Spalte "Mitarbeierrolle" nur bei Mitarbeitern!
|
|
|
707 |
if ($role)
|
|
|
708 |
echo "<td class=\"sel\"> </td>\n";
|
|
|
709 |
|
|
|
710 |
# Dynamischer Aufbau der restlichen Tabelle.
|
|
|
711 |
$color = dechex($ta_color);
|
|
|
712 |
$len = strlen($color);
|
|
|
713 |
|
|
|
714 |
while ($len < 6) {
|
|
|
715 |
$color = "0" . $color;
|
|
|
716 |
$len++;
|
|
|
717 |
}
|
|
|
718 |
|
|
|
719 |
$dt = $fdate;
|
|
|
720 |
|
|
|
721 |
# Die leeren Spalten vor Beginn eines Tasks zeichnen.
|
|
|
722 |
while (PerDateComp($dt, $ta_start) > 0) {
|
|
|
723 |
$dt = IncDate($periode, $dt);
|
|
|
724 |
echo "<td class=\"sel\"> </td>";
|
|
|
725 |
}
|
|
|
726 |
|
|
|
727 |
if ($ta_meeting)
|
|
|
728 |
$edate = $ta_start;
|
|
|
729 |
else
|
|
|
730 |
$edate = GetEDate($einheit, $ta_start, $ta_duration);
|
|
|
731 |
|
|
|
732 |
# Den Zeitraum eines Tasks "grafisch" darstellen und den Aufwand
|
|
|
733 |
# pro Periode anzeigen.
|
|
|
734 |
do {
|
|
|
735 |
if ($typ)
|
|
|
736 |
echo "<td style=\"background-color: #$color; border: 1px solid black;\"> </td>\n";
|
|
|
737 |
else if ($ta_meeting)
|
|
|
738 |
echo "<td style=\"color: #$color;background-color: #969696; border: 1px solid black;\"><center>###</center></td>\n";
|
|
|
739 |
else
|
|
|
740 |
echo "<td style=\"color: #$color;background-color: #dddddd; border: 1px solid black;\"><center>===</center></td>\n";
|
|
|
741 |
|
|
|
742 |
$dt = IncDate($periode, $dt);
|
|
|
743 |
}
|
|
|
744 |
while (PerDateComp($dt, $edate) >= 0);
|
|
|
745 |
|
|
|
746 |
# Die leeren Spalten nach dem Ende eines Tasks zeichnen.
|
|
|
747 |
while (PerDateComp($dt, $ldate) >= 0) {
|
|
|
748 |
$dt = IncDate($periode, $dt);
|
|
|
749 |
echo "<td class=\"sel\"> </td>";
|
|
|
750 |
}
|
|
|
751 |
|
|
|
752 |
# Ausfuellen der Summenspalte
|
|
|
753 |
if (($typ && !$ma) || $ta_level == 1) {
|
|
|
754 |
echo "<td class=\"two\" align=\"right\">";
|
|
|
755 |
printf ("<b><u>%s</u></b></td>\n", FormatNum($al_hours+$wd_hours, 3));
|
|
|
756 |
} else
|
|
|
757 |
echo "<td class=\"sel\"> </td>\n";
|
|
|
758 |
|
|
|
759 |
if ($typ && !$ma) {
|
|
|
760 |
if ($ta_num == $tanum)
|
|
|
761 |
$sum = PrintMa($db, $fdate, $ldate, $ta_num, $color, $pl_num, $ressource);
|
|
|
762 |
else
|
|
|
763 |
$sum = PrintMa($db, $fdate, $ldate, $ta_num, $color, $pl_num, 0);
|
|
|
764 |
|
|
|
765 |
$total += $sum;
|
|
|
766 |
}
|
|
|
767 |
|
|
|
768 |
echo "</tr>\n";
|
|
|
769 |
|
|
|
770 |
if ($ma) {
|
|
|
771 |
$ma = false;
|
|
|
772 |
$done = true;
|
|
|
773 |
}
|
|
|
774 |
|
|
|
775 |
if (!$done && $ta_num == $id)
|
|
|
776 |
$ma = true;
|
|
|
777 |
|
|
|
778 |
if (!$ma)
|
|
|
779 |
$row++;
|
|
|
780 |
}
|
|
|
781 |
|
|
|
782 |
# Anfuegen der Summierungen
|
|
|
783 |
if ($datum == 0 && $total > 0) {
|
|
|
784 |
if ($role)
|
|
|
785 |
$span = 8 + $tbcols;
|
|
|
786 |
else
|
|
|
787 |
$span = 7 + $tbcols;
|
|
|
788 |
|
|
|
789 |
if (($typ && !$ma) || $ta_level == 1) {
|
|
|
790 |
echo "<tr><td class=\"sel\" colspan=$span> </td>";
|
|
|
791 |
echo "<td class=\"two\" align=\"right\">";
|
|
|
792 |
printf("<b><u>%s</u></b></td></tr>\n", FormatNum($al_hours+$wd_hours, 3));
|
|
|
793 |
}
|
|
|
794 |
|
|
|
795 |
echo "<tr><td class=\"selnum\" colspan=$span>Gesamtsumme:</td>";
|
|
|
796 |
printf("<td class=\"selgray\" align=\"right\"><b><u>%s</u></b></td></tr>\n", FormatNum($total, 3));
|
|
|
797 |
}
|
|
|
798 |
|
|
|
799 |
echo "</table>\n";
|
|
|
800 |
closeDB($db);
|
|
|
801 |
}
|
|
|
802 |
|
|
|
803 |
# Auswertung des Menues:
|
|
|
804 |
#
|
|
|
805 |
if ($knopf == 21) // Statusbericht
|
|
|
806 |
Preselect();
|
|
|
807 |
|
|
|
808 |
# Auswertung der Funktionen
|
|
|
809 |
if ($func == "printplan") {
|
|
|
810 |
$pl_num = $_REQUEST['pl_num'];
|
|
|
811 |
$datum = $_REQUEST['datum'];
|
|
|
812 |
echo "<table class=\"indent\"><tr><td>\n";
|
|
|
813 |
ButtonPrint("Drucken", "printplan.php", "pl_num=$pl_num&datum=$datum&header=2&func=PlanPrint");
|
|
|
814 |
echo "</td></tr></table>\n";
|
|
|
815 |
PrintPlan($pl_num);
|
|
|
816 |
}
|
|
|
817 |
|
|
|
818 |
if ($func == "PlanPrint") {
|
|
|
819 |
$pl_num = $_REQUEST['pl_num'];
|
|
|
820 |
|
|
|
821 |
PrintPlan($pl_num);
|
|
|
822 |
}
|
|
|
823 |
|
|
|
824 |
require('footer.inc');
|
|
|
825 |
|
|
|
826 |
?>
|