Subversion Repositories public

Rev

Rev 4 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 39
1
<?php
1
<?php
2
/*
2
/*
3
 * Modul:        istpm.php
3
 * Modul:        istpm.php
4
 * Zweck:        Verwaltet die IST-Erfassung, Eingabe in Monaten
4
 * Zweck:        Verwaltet die IST-Erfassung, Eingabe in Monaten
5
 * Aufruf:       Durch Menuepunkt "IST-Erfassung" in "forms.php->menu.inc"
5
 * Aufruf:       Durch Menuepunkt "IST-Erfassung" in "forms.php->menu.inc"
6
 * Beschreibung: Dieses Modul verwaltet die IST-Erfassung in ganzen Monaten.
6
 * Beschreibung: Dieses Modul verwaltet die IST-Erfassung in ganzen Monaten.
7
 *               Es koennen also nur PT's fuer jeweils 1 Monat eingegeben
7
 *               Es koennen also nur PT's fuer jeweils 1 Monat eingegeben
8
 *               werden. Dabei werden diese Eingaben intern so gespeichert,
8
 *               werden. Dabei werden diese Eingaben intern so gespeichert,
9
 *               dass die PT's auf die Tage des Monats aufgeteilt werden,
9
 *               dass die PT's auf die Tage des Monats aufgeteilt werden,
10
 *               so das es scheint als waeren die Eingaben pro Tag in Stunden
10
 *               so das es scheint als waeren die Eingaben pro Tag in Stunden
11
 *               erfolgt.
11
 *               erfolgt.
12
 */
12
 */
13
require_once('version.inc');
13
require_once('version.inc');
14
require_once('dbaccess.inc');
14
require_once('dbaccess.inc');
15
require_once('language.inc');
15
require_once('language.inc');
16
require_once('header.inc');
16
require_once('header.inc');
17
require_once('crypt.inc');
17
require_once('crypt.inc');
18
require_once('settings.inc');
18
require_once('settings.inc');
19
require_once('helper.inc');
19
require_once('helper.inc');
20
 
20
 
21
/*
21
/*
22
0: Verwalter
22
0: Verwalter
23
1: Administrator
23
1: Administrator
24
2: Projektleiter
24
2: Projektleiter
25
3: Mitarbeiter
25
3: Mitarbeiter
26
4: Kontroller
26
4: Kontroller
27
5: Kein Zugang!
27
5: Kein Zugang!
28
6: Ressourcenmanager
28
6: Ressourcenmanager
29
7: Revisor
29
7: Revisor
30
*/
30
*/
31
$drm = array(true, false, false, false, false, true, true, true);
31
$drm = array(true, false, false, false, false, true, true, true);
32
$headline = 10;
32
$headline = 10;
33
 
33
 
34
require_once('menu.inc');
34
require_once('menu.inc');
35
require_once('knumber.inc');
35
require_once('knumber.inc');
36
 
36
 
37
$func = $_REQUEST['func'];
37
$func = $_REQUEST['func'];
38
 
38
 
39
# In diesem Modul global verwendete Variablen
39
# In diesem Modul global verwendete Variablen
40
$sumparr = array(0,0,0,0,0,0,0,0,0);	// Spaltensummen der Eingabezeilen
40
$sumparr = array(0,0,0,0,0,0,0,0,0);	// Spaltensummen der Eingabezeilen
41
$sumiarr = array(0,0,0,0,0,0,0,0,0);
41
$sumiarr = array(0,0,0,0,0,0,0,0,0);
42
$sumallp = 0.0;		// Spaltensumme der Tasks
42
$sumallp = 0.0;		// Spaltensumme der Tasks
43
$sumalli = 0.0;
43
$sumalli = 0.0;
44
$TempExist = false;	// Temporaere Tabelle existiert?
44
$TempExist = false;	// Temporaere Tabelle existiert?
45
 
45
 
46
# Folgende Funktion gibt die IST-Daten bzw. Eingabezeilen fuer einen
46
# Folgende Funktion gibt die IST-Daten bzw. Eingabezeilen fuer einen
47
# Mitarbeiter innerhalb der Tabelle aus.
47
# Mitarbeiter innerhalb der Tabelle aus.
48
#
48
#
49
function ShowMitarbeiter($db, $minum, $anz, $von, $bis, $pr_num, $pl_num, $mi=true) {
49
function ShowMitarbeiter($db, $minum, $anz, $von, $bis, $pr_num, $pl_num, $mi=true) {
50
	global $menu;
50
	global $menu;
51
	global $headline;
51
	global $headline;
52
	global $rstufe;
52
	global $rstufe;
53
	global $unum;
53
	global $unum;
54
	global $leneinheit;
54
	global $leneinheit;
55
	global $periode;
55
	global $periode;
56
	global $dtformatshort;
56
	global $dtformatshort;
57
	global $ist_erledigung;
57
	global $ist_erledigung;
58
	global $ist_future;
58
	global $ist_future;
59
	global $verrmodul;
59
	global $verrmodul;
60
	global $sumparr;
60
	global $sumparr;
61
	global $sumiarr;
61
	global $sumiarr;
62
	global $sumallp;
62
	global $sumallp;
63
	global $sumalli;
63
	global $sumalli;
64
	global $TempExist;
64
	global $TempExist;
65
 
65
 
66
	# Ermitteln ab wann noch erfasst werden darf.
66
	# Ermitteln ab wann noch erfasst werden darf.
67
	$query = "select ab_datum from abschluss where ab_prnum = $pr_num ";
67
	$query = "select ab_datum from abschluss where ab_prnum = $pr_num ";
68
	$query .= "order by ab_datum desc";
68
	$query .= "order by ab_datum desc";
69
 
69
 
70
	if (!($result = QueryDB($db, $query)))
70
	if (!($result = QueryDB($db, $query)))
71
	   return false;
71
	   return false;
72
 
72
 
73
	if (numrowsDB($result) > 0) {
73
	if (numrowsDB($result) > 0) {
74
	   $data = fetchDB($result, 0);
74
	   $data = fetchDB($result, 0);
75
	   $ab_datum = $data[0];
75
	   $ab_datum = $data[0];
76
	} else
76
	} else
77
	   $ab_datum = 0;
77
	   $ab_datum = 0;
78
 
78
 
79
	# Projekt oder Konto?
79
	# Projekt oder Konto?
80
	$query = "select pr_status from project where pr_num = $pr_num";
80
	$query = "select pr_status from project where pr_num = $pr_num";
81
 
81
 
82
	if (!($result = QueryDB($db, $query)))
82
	if (!($result = QueryDB($db, $query)))
83
	   return false;
83
	   return false;
84
 
84
 
85
	$data = fetchDB($result, 0);
85
	$data = fetchDB($result, 0);
86
	$pr_status = $data[0];
86
	$pr_status = $data[0];
87
 
87
 
88
	# Auslesen der Tasks welche bebucht werden koennen. Tasks die einem
88
	# Auslesen der Tasks welche bebucht werden koennen. Tasks die einem
89
	# aelteren Plan angehoeren auf dem bereits IST-Buchungen existieren,
89
	# aelteren Plan angehoeren auf dem bereits IST-Buchungen existieren,
90
	# werden ebenfalls ausgegeben, koennen aber nicht bebucht werden.
90
	# werden ebenfalls ausgegeben, koennen aber nicht bebucht werden.
91
	# Nur Plaene mit Status "Aktiv" koennen bebucht werden!
91
	# Nur Plaene mit Status "Aktiv" koennen bebucht werden!
92
	$akt = $von;
92
	$akt = $von;
93
 
93
 
94
	if ($pr_status == 0) {
94
	if ($pr_status == 0) {
95
	   # Um das zu bekommen was wir wollen, muessen wir mit Hilfe einer
95
	   # Um das zu bekommen was wir wollen, muessen wir mit Hilfe einer
96
	   # temporaeren Tabelle arbeiten, welche wir nur in einer Schleife
96
	   # temporaeren Tabelle arbeiten, welche wir nur in einer Schleife
97
	   # korrekt erstellen koennen.
97
	   # korrekt erstellen koennen.
98
	   if (!$TempExist) {
98
	   if (!$TempExist) {
99
	      $query = "create local temporary table TempTask (";
99
	      $query = "create local temporary table TempTask (";
100
	      $query .= "tmp_num integer not null unique, tmp_tanum integer, ";
100
	      $query .= "tmp_num integer not null unique, tmp_tanum integer, ";
101
	      $query .= "tmp_taname varchar(50), tmp_plan float8, tmp_ist float8,";
101
	      $query .= "tmp_taname varchar(50), tmp_plan float8, tmp_ist float8,";
102
	      $query .= "tmp_periode integer, tmp_start integer,tmp_lfd smallint,";
102
	      $query .= "tmp_periode integer, tmp_start integer,tmp_lfd smallint,";
103
	      $query .= "tmp_duration smallint, tmp_hash char(34), tmp_edit bool,";
103
	      $query .= "tmp_duration smallint, tmp_hash char(34), tmp_edit bool,";
104
	      $query .= "constraint \"temptask_pkey\" primary key (\"tmp_num\"))";
104
	      $query .= "constraint \"temptask_pkey\" primary key (\"tmp_num\"))";
105
	      $TempExist = true;
105
	      $TempExist = true;
106
	   } else {
106
	   } else {
107
	      $query = "delete from TempTask";
107
	      $query = "delete from TempTask";
108
	   }
108
	   }
109
 
109
 
110
	   if (!($result = QueryDB($db, $query)))
110
	   if (!($result = QueryDB($db, $query)))
111
	      return false;
111
	      return false;
112
 
112
 
113
	   $query = "select distinct on (ta_num) ta_name, ta_num, ta_start, ";
113
	   $query = "select distinct on (ta_num) ta_name, ta_num, ta_start, ";
114
	   $query .= "ta_duration, ta_hash from task, allocation ";
114
	   $query .= "ta_duration, ta_hash from task, allocation ";
115
	   $query .= "where al_task = ta_num and al_ressource = $minum and ";
115
	   $query .= "where al_task = ta_num and al_ressource = $minum and ";
116
	   $query .= "ta_meeting = 0 and ta_level > 1 and ";
116
	   $query .= "ta_meeting = 0 and ta_level > 1 and ";
117
	   $query .= "(ta_plnum = $pl_num or ta_plnum in ( ";
117
	   $query .= "(ta_plnum = $pl_num or ta_plnum in ( ";
118
	   $query .= "select distinct pl_num from wdone, plan, task where ";
118
	   $query .= "select distinct pl_num from wdone, plan, task where ";
119
	   $query .= "ta_num = wd_task and pl_num = ta_plnum and ";
119
	   $query .= "ta_num = wd_task and pl_num = ta_plnum and ";
120
	   $query .= "wd_prnum = $pr_num and wd_minum = $minum and ";
120
	   $query .= "wd_prnum = $pr_num and wd_minum = $minum and ";
121
	   $query .= "wd_datum between $von and $bis and ";
121
	   $query .= "wd_datum between $von and $bis and ";
122
	   $query .= "pl_status in (2,3,4,5,6) order by pl_num desc)) and ";
122
	   $query .= "pl_status in (2,3,4,5,6) order by pl_num desc)) and ";
123
 
123
 
124
	   if (!$ist_future) {
124
	   if (!$ist_future) {
125
	      $query .= "ta_start <= $bis ";
125
	      $query .= "ta_start <= $bis ";
126
	   } else {
126
	   } else {
127
	      $query .= "(ta_start between $von and $bis or ";
127
	      $query .= "(ta_start between $von and $bis or ";
128
	      $query .= "ta_start+ta_duration*86400 between $von and $bis or ";
128
	      $query .= "ta_start+ta_duration::int8*86400 between $von and $bis or ";
129
	      $query .= "$von between ta_start and ta_start+ta_duration*86400 or ";
129
	      $query .= "$von between ta_start and ta_start+ta_duration::int8*86400 or ";
130
	      $query .= "$bis between ta_start and ta_start+ta_duration*86400 or ";
130
	      $query .= "$bis between ta_start and ta_start+ta_duration::int8*86400 or ";
131
	      $query .= "ta_num in (select distinct wd_task from wdone where ";
131
	      $query .= "ta_num in (select distinct wd_task from wdone where ";
132
	      $query .= "wd_minum = $minum and wd_prnum = $pr_num and ";
132
	      $query .= "wd_minum = $minum and wd_prnum = $pr_num and ";
133
	      $query .= "wd_datum between $von and $bis)) ";
133
	      $query .= "wd_datum between $von and $bis)) ";
134
	   }
134
	   }
135
 
135
 
136
	   $query .= "order by ta_num desc";
136
	   $query .= "order by ta_num desc";
137
 
137
 
138
	   if (!($result = QueryDB($db, $query)))
138
	   if (!($result = QueryDB($db, $query)))
139
	      return false;
139
	      return false;
140
 
140
 
141
	   $menge = numrowsDB($result);
141
	   $menge = numrowsDB($result);
142
	   $i = 0;
142
	   $i = 0;
143
	   $oldhash = "";
143
	   $oldhash = "";
144
	   $counter = 1;
144
	   $counter = 1;
145
 
145
 
146
	   while ($i < $menge) {
146
	   while ($i < $menge) {
147
	      $data = fetchDB($result, $i);
147
	      $data = fetchDB($result, $i);
148
	      $ta_name = $data[0];
148
	      $ta_name = $data[0];
149
	      $ta_num = $data[1];
149
	      $ta_num = $data[1];
150
	      $ta_start = $data[2];
150
	      $ta_start = $data[2];
151
	      $ta_duration = $data[3];
151
	      $ta_duration = $data[3];
152
	      $ta_hash = $data[4];
152
	      $ta_hash = $data[4];
153
 
153
 
154
	      # Fuer jede Periode die angezeigt werden soll, muss ein Datensatz
154
	      # Fuer jede Periode die angezeigt werden soll, muss ein Datensatz
155
	      # eingefuegt werden.
155
	      # eingefuegt werden.
156
	      $akt = $von;
156
	      $akt = $von;
157
	      $z = 0;
157
	      $z = 0;
158
 
158
 
159
	      while ($z < $anz) {
159
	      while ($z < $anz) {
160
		 # Nachsehen, ob schon ein Satz existiert. Wenn ja, dann muessen
160
		 # Nachsehen, ob schon ein Satz existiert. Wenn ja, dann muessen
161
		 # wir die IST-Werte aufaddieren. Beim Planwert gilt immer der
161
		 # wir die IST-Werte aufaddieren. Beim Planwert gilt immer der
162
		 # Neueste.
162
		 # Neueste.
163
		 $query = "select tmp_num from TempTask where ";
163
		 $query = "select tmp_num from TempTask where ";
164
		 $query .= "tmp_hash = '$ta_hash' and tmp_periode = $akt";
164
		 $query .= "tmp_hash = '$ta_hash' and tmp_periode = $akt";
165
 
165
 
166
		 if (!($resco = QueryDB($db, $query)))
166
		 if (!($resco = QueryDB($db, $query)))
167
		    return false;
167
		    return false;
168
 
168
 
169
		 if (numrowsDB($resco) > 0) {
169
		 if (numrowsDB($resco) > 0) {
170
		    $data = fetchDB($resco, 0);
170
		    $data = fetchDB($resco, 0);
171
		    $tmp_num = $data[0];
171
		    $tmp_num = $data[0];
172
		 } else
172
		 } else
173
		    $tmp_num = 0;
173
		    $tmp_num = 0;
174
 
174
 
175
		 $mon = gmdate("n", $akt);
175
		 $mon = gmdate("n", $akt);
176
		 $year = gmdate("Y", $akt);
176
		 $year = gmdate("Y", $akt);
177
		 $per_bis = gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year);
177
		 $per_bis = gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year);
178
 
178
 
179
		 if ($oldhash != $ta_hash) {
179
		 if ($oldhash != $ta_hash) {
180
		    $query = "select sum(al_hours) from allocation where ";
180
		    $query = "select sum(al_hours) from allocation where ";
181
		    $query .= "al_task = $ta_num and al_ressource = $minum and ";
181
		    $query .= "al_task = $ta_num and al_ressource = $minum and ";
182
		    $query .= "al_pstart between $akt and $per_bis";
182
		    $query .= "al_pstart between $akt and $per_bis";
183
 
183
 
184
		    if (!($ressu = QueryDB($db, $query)))
184
		    if (!($ressu = QueryDB($db, $query)))
185
		       return false;
185
		       return false;
186
 
186
 
187
		    if (numrowsDB($ressu) > 0) {
187
		    if (numrowsDB($ressu) > 0) {
188
		       $data = fetchDB($ressu, 0);
188
		       $data = fetchDB($ressu, 0);
189
		       $al_hours = $data[0];
189
		       $al_hours = $data[0];
190
		    } else
190
		    } else
191
		       $al_hours = 0.0;
191
		       $al_hours = 0.0;
192
 
192
 
193
		    if (!isset($al_hours))
193
		    if (!isset($al_hours))
194
		       $al_hours = 0.0;
194
		       $al_hours = 0.0;
195
		 } else
195
		 } else
196
		    $al_hours = 0.0;
196
		    $al_hours = 0.0;
197
 
197
 
198
		 $query = "select sum(wd_hours) / $leneinheit from wdone where ";
198
		 $query = "select sum(wd_hours) / $leneinheit from wdone where ";
199
		 $query .= "wd_prnum = $pr_num and wd_minum = $minum and ";
199
		 $query .= "wd_prnum = $pr_num and wd_minum = $minum and ";
200
		 $query .= "wd_task = $ta_num and ";
200
		 $query .= "wd_task = $ta_num and ";
201
		 $query .= "wd_datum between $akt and $per_bis";
201
		 $query .= "wd_datum between $akt and $per_bis";
202
 
202
 
203
		 if (!($ressu = QueryDB($db, $query)))
203
		 if (!($ressu = QueryDB($db, $query)))
204
		    return false;
204
		    return false;
205
 
205
 
206
		 if (numrowsDB($ressu) > 0) {
206
		 if (numrowsDB($ressu) > 0) {
207
		    $data = fetchDB($ressu, 0);
207
		    $data = fetchDB($ressu, 0);
208
		    $wd_hours = $data[0];
208
		    $wd_hours = $data[0];
209
 
209
 
210
		    if (!isset($wd_hours))
210
		    if (!isset($wd_hours))
211
		       $wd_hours = 0.0;
211
		       $wd_hours = 0.0;
212
		 } else
212
		 } else
213
		    $wd_hours = 0.0;
213
		    $wd_hours = 0.0;
214
 
214
 
215
		 # Ermitteln, ob der Eintrag editierbar ist...
215
		 # Ermitteln, ob der Eintrag editierbar ist...
216
		 # Da wir hier ein ganzes Monat bewerten, koennen wir nicht
216
		 # Da wir hier ein ganzes Monat bewerten, koennen wir nicht
217
		 # anhand des Kennzeichens in wdone (wd_edit) ermitteln, ob
217
		 # anhand des Kennzeichens in wdone (wd_edit) ermitteln, ob
218
		 # ein Eintrag editierbar ist oder nicht. Statt dessen muessen
218
		 # ein Eintrag editierbar ist oder nicht. Statt dessen muessen
219
		 # wir das anhand des letzten Abschlussdatums feststellen.
219
		 # wir das anhand des letzten Abschlussdatums feststellen.
220
		 #
220
		 #
221
		 if ($akt > $ab_datum)
221
		 if ($akt > $ab_datum)
222
		    $wd_edit = "true";
222
		    $wd_edit = "true";
223
		 else
223
		 else
224
		    $wd_edit = "false";
224
		    $wd_edit = "false";
225
 
225
 
226
		 # Planstatus ermitteln
226
		 # Planstatus ermitteln
227
		 $query = "select pl_status from plan, task where ";
227
		 $query = "select pl_status from plan, task where ";
228
		 $query .= "pl_num = ta_plnum and ta_num = $ta_num";
228
		 $query .= "pl_num = ta_plnum and ta_num = $ta_num";
229
 
229
 
230
		 if (!($ressu = QueryDB($db, $query)))
230
		 if (!($ressu = QueryDB($db, $query)))
231
		   return false;
231
		   return false;
232
 
232
 
233
		 $data = fetchDB($ressu, 0);
233
		 $data = fetchDB($ressu, 0);
234
		 $wstatus = $data[0];
234
		 $wstatus = $data[0];
235
 
235
 
236
		 if ($tmp_num == 0) {
236
		 if ($tmp_num == 0) {
237
		    if ($wstatus == 5 || $wstatus == 6) {
237
		    if ($wstatus == 5 || $wstatus == 6) {
238
		       $wd_edit = "false";
238
		       $wd_edit = "false";
239
 
239
 
240
		       if ($wstatus == 5 && $wd_hours <= 0.0)
240
		       if ($wstatus == 5 && $wd_hours <= 0.0)
241
		          $al_hours = 0.0;
241
		          $al_hours = 0.0;
242
		    }
242
		    }
243
 
243
 
244
		    $slash_name = addslashes($ta_name);
244
		    $slash_name = addslashes($ta_name);
245
		    $query = "insert into TempTask (tmp_num, tmp_tanum, ";
245
		    $query = "insert into TempTask (tmp_num, tmp_tanum, ";
246
		    $query .= "tmp_taname, tmp_start, tmp_duration, ";
246
		    $query .= "tmp_taname, tmp_start, tmp_duration, ";
247
		    $query .= "tmp_hash, tmp_periode, tmp_plan, tmp_ist, tmp_edit) ";
247
		    $query .= "tmp_hash, tmp_periode, tmp_plan, tmp_ist, tmp_edit) ";
248
		    $query .= "values ($counter, $ta_num, '$slash_name', $ta_start, ";
248
		    $query .= "values ($counter, $ta_num, '$slash_name', $ta_start, ";
249
		    $query .= "$ta_duration, '$ta_hash', $akt, $al_hours, $wd_hours,";
249
		    $query .= "$ta_duration, '$ta_hash', $akt, $al_hours, $wd_hours,";
250
		    $query .= "$wd_edit)";
250
		    $query .= "$wd_edit)";
251
		    $counter++;
251
		    $counter++;
252
		 } else {
252
		 } else {
253
		    $query = "update TempTask set tmp_ist = tmp_ist + $wd_hours ";
253
		    $query = "update TempTask set tmp_ist = tmp_ist + $wd_hours ";
254
		    $query .= "where tmp_num = $tmp_num";
254
		    $query .= "where tmp_num = $tmp_num";
255
		 }
255
		 }
256
 
256
 
257
		 if (!QueryDB($db, $query))
257
		 if (!QueryDB($db, $query))
258
		    return false;
258
		    return false;
259
 
259
 
260
		 $akt = IncDate($periode, $akt);
260
		 $akt = IncDate($periode, $akt);
261
		 $z++;
261
		 $z++;
262
	      }
262
	      }
263
 
263
 
264
	      $oldhash = $ta_hash;
264
	      $oldhash = $ta_hash;
265
	      $i++;
265
	      $i++;
266
	   }
266
	   }
267
 
267
 
268
	   $query = "select tmp_taname, tmp_plan, tmp_tanum, tmp_start, ";
268
	   $query = "select tmp_taname, tmp_plan, tmp_tanum, tmp_start, ";
269
	   $query .= "tmp_duration, tmp_hash, tmp_ist, tmp_periode, tmp_edit ";
269
	   $query .= "tmp_duration, tmp_hash, tmp_ist, tmp_periode, tmp_edit ";
270
	   $query .= "from TempTask order by tmp_num";
270
	   $query .= "from TempTask order by tmp_num";
271
	} else {
271
	} else {
272
	   $query = "select ta_name, ta_id, ta_num, ta_start, ta_duration, ta_hash from task ";
272
	   $query = "select ta_name, ta_id, ta_num, ta_start, ta_duration, ta_hash from task ";
273
	   $query .= "where ta_plnum = $pl_num";
273
	   $query .= "where ta_plnum = $pl_num";
274
	}
274
	}
275
 
275
 
276
	if (!($res = QueryDB($db, $query)))
276
	if (!($res = QueryDB($db, $query)))
277
	   return false;
277
	   return false;
278
 
278
 
279
	$rows = numrowsDB($res);
279
	$rows = numrowsDB($res);
280
	$r = 0;
280
	$r = 0;
281
	$oldhash = "";
281
	$oldhash = "";
282
 
282
 
283
	while ($r < $rows) {
283
	while ($r < $rows) {
284
	   $data = fetchDB($res, $r);
284
	   $data = fetchDB($res, $r);
285
	   $ta_name = $data[0];
285
	   $ta_name = $data[0];
286
	   $plan = $data[1];
286
	   $plan = $data[1];
287
	   $ta_num = $data[2];
287
	   $ta_num = $data[2];
288
	   $ta_start = $data[3];
288
	   $ta_start = $data[3];
289
	   $ta_duration = $data[4];
289
	   $ta_duration = $data[4];
290
	   $ta_hash = $data[5];
290
	   $ta_hash = $data[5];
291
 
291
 
292
	   if ($pr_status == 0) {
292
	   if ($pr_status == 0) {
293
	      $ist = $data[6];
293
	      $ist = $data[6];
294
	      $tmp_periode = $data[7];
294
	      $tmp_periode = $data[7];
295
	      $tmp_edit = $data[8];
295
	      $tmp_edit = $data[8];
296
	   }
296
	   }
297
 
297
 
298
	   # Ermitteln des Planstatus zum aktuellen Task. Ist dieser
298
	   # Ermitteln des Planstatus zum aktuellen Task. Ist dieser
299
	   # "Inaktiv" dann darf nur dann eine Planausgabe erfolgen, wenn
299
	   # "Inaktiv" dann darf nur dann eine Planausgabe erfolgen, wenn
300
	   # es einen IST-Wert in der entsprechenden Periode gibt.
300
	   # es einen IST-Wert in der entsprechenden Periode gibt.
301
	   $query = "select pl_status, pl_lfd from plan, task where ";
301
	   $query = "select pl_status, pl_lfd from plan, task where ";
302
	   $query .= "pl_num = ta_plnum and ta_num = $ta_num";
302
	   $query .= "pl_num = ta_plnum and ta_num = $ta_num";
303
 
303
 
304
	   if (!($resta = QueryDB($db, $query)))
304
	   if (!($resta = QueryDB($db, $query)))
305
	      return false;
305
	      return false;
306
 
306
 
307
	   $data = fetchDB($resta, 0);
307
	   $data = fetchDB($resta, 0);
308
	   $pl_status = $data[0];
308
	   $pl_status = $data[0];
309
	   $pl_lfd = $data[1];
309
	   $pl_lfd = $data[1];
310
 
310
 
311
	   # Taskname
311
	   # Taskname
312
	   echo "<tr><td class=\"sel\">$ta_name</td>";
312
	   echo "<tr><td class=\"sel\">$ta_name</td>";
313
 
313
 
314
	   # Plannummer und Planstatus
314
	   # Plannummer und Planstatus
315
	   switch ($pl_status) {
315
	   switch ($pl_status) {
316
	      case 0: $sstat = GetMessage($db, 234, "Konto"); break;
316
	      case 0: $sstat = GetMessage($db, 234, "Konto"); break;
317
	      case 1: $sstat = GetMessage($db, 85, "In Erstellung"); break;
317
	      case 1: $sstat = GetMessage($db, 85, "In Erstellung"); break;
318
	      case 2: $sstat = GetMessage($db, 86, "Freigegeben"); break;
318
	      case 2: $sstat = GetMessage($db, 86, "Freigegeben"); break;
319
	      case 4: $sstat = GetMessage($db, 87, "Aktiv"); break;
319
	      case 4: $sstat = GetMessage($db, 87, "Aktiv"); break;
320
	      case 5: $sstat = GetMessage($db, 88, "Inaktiv"); break;
320
	      case 5: $sstat = GetMessage($db, 88, "Inaktiv"); break;
321
	      case 6: $sstat = GetMessage($db, 89, "Abgeschlossen"); break;
321
	      case 6: $sstat = GetMessage($db, 89, "Abgeschlossen"); break;
322
	      default: $sstat = "$pl_status";
322
	      default: $sstat = "$pl_status";
323
	   }
323
	   }
324
 
324
 
325
	   if ($pr_status == 0 && $ab_datum > 0)
325
	   if ($pr_status == 0 && $ab_datum > 0)
326
	      $sstat .= "<br>" . GetMessage($db, 392, "Abg. bis: %s", gmdate($dtformatshort, $ab_datum));
326
	      $sstat .= "<br>" . GetMessage($db, 392, "Abg. bis: %s", gmdate($dtformatshort, $ab_datum));
327
	   else if ($ab_datum > 0)
327
	   else if ($ab_datum > 0)
328
	      $sstat = GetMessage($db, 392, "Abg. bis: %s", gmdate($dtformatshort, $ab_datum));
328
	      $sstat = GetMessage($db, 392, "Abg. bis: %s", gmdate($dtformatshort, $ab_datum));
329
 
329
 
330
	   if ($pr_status == 0)
330
	   if ($pr_status == 0)
331
	      echo "<td class=\"sel\">$pl_lfd: $sstat</td>\n";
331
	      echo "<td class=\"sel\">$pl_lfd: $sstat</td>\n";
332
	   else
332
	   else
333
	      echo "<td class=\"sel\">$sstat</td>\n";
333
	      echo "<td class=\"sel\">$sstat</td>\n";
334
 
334
 
335
	   # Mitarbeiter oder Projektleiter
335
	   # Mitarbeiter oder Projektleiter
336
	   if ($rstufe != 3 && $mi) {
336
	   if ($rstufe != 3 && $mi) {
337
	      $query = "select mi_nname, mi_vname from mitarbeiter where ";
337
	      $query = "select mi_nname, mi_vname from mitarbeiter where ";
338
	      $query .= "mi_num = $minum";
338
	      $query .= "mi_num = $minum";
339
 
339
 
340
	      if (!($resmi = QueryDB($db, $query)))
340
	      if (!($resmi = QueryDB($db, $query)))
341
	         return false;
341
	         return false;
342
 
342
 
343
	      $data = fetchDB($resmi, 0);
343
	      $data = fetchDB($resmi, 0);
344
 
344
 
345
	      if (!$data) {
345
	      if (!$data) {
346
	         Error(GetMessage($db, 235, "Mitarbeiter konnte nicht ermittelt werden!"));
346
	         Error(GetMessage($db, 235, "Mitarbeiter konnte nicht ermittelt werden!"));
347
	         return false;
347
	         return false;
348
	      }
348
	      }
349
 
349
 
350
	      $mi_nname = $data[0];
350
	      $mi_nname = $data[0];
351
	      $mi_vname = $data[1];
351
	      $mi_vname = $data[1];
352
	      echo "<td class=\"sel\">$mi_nname $mi_vname</td>\n";
352
	      echo "<td class=\"sel\">$mi_nname $mi_vname</td>\n";
353
	   } else
353
	   } else
354
	      echo "<td class=\"sel\">&nbsp;</td>\n";
354
	      echo "<td class=\"sel\">&nbsp;</td>\n";
355
 
355
 
356
	   # Erledigungsgrad ermitteln
356
	   # Erledigungsgrad ermitteln
357
	   if ($ist_erledigung) {
357
	   if ($ist_erledigung) {
358
	      $query = "select sum(wd_hours)/$leneinheit from wdone, task ";
358
	      $query = "select sum(wd_hours)/$leneinheit from wdone, task ";
359
	      $query .= "where wd_minum = $minum and wd_prnum = $pr_num and ";
359
	      $query .= "where wd_minum = $minum and wd_prnum = $pr_num and ";
360
	      $query .= "ta_num = wd_task and ta_hash ='$ta_hash'";
360
	      $query .= "ta_num = wd_task and ta_hash ='$ta_hash'";
361
 
361
 
362
	      if (!($reser = QueryDB($db, $query)))
362
	      if (!($reser = QueryDB($db, $query)))
363
	         return false;
363
	         return false;
364
 
364
 
365
	      $data = fetchDB($reser, 0);
365
	      $data = fetchDB($reser, 0);
366
 
366
 
367
	      if (!$data) {
367
	      if (!$data) {
368
	         Error(GetMessage($db, 236, "Erledigungsgrad konnte nicht ermittelt werden!"));
368
	         Error(GetMessage($db, 236, "Erledigungsgrad konnte nicht ermittelt werden!"));
369
	         return false;
369
	         return false;
370
	      }
370
	      }
371
 
371
 
372
	      $ist = $data[0];
372
	      $ist = $data[0];
373
 
373
 
374
	      if ($plan != 0)
374
	      if ($plan != 0)
375
	         $proz = $ist / $plan * 100.0;
375
	         $proz = $ist / $plan * 100.0;
376
	      else
376
	      else
377
	         $proz = 0.0;
377
	         $proz = 0.0;
378
	   }
378
	   }
379
 
379
 
380
	   echo "<td class=\"sel\">" . GetMessage($db, 237, "Plan:<br>IST:") . "</td>\n";
380
	   echo "<td class=\"sel\">" . GetMessage($db, 237, "Plan:<br>IST:") . "</td>\n";
381
	   $sumi = 0.0;
381
	   $sumi = 0.0;
382
	   $sump = 0.0;
382
	   $sump = 0.0;
383
	   $z = 0;
383
	   $z = 0;
384
	   $akt = $von;
384
	   $akt = $von;
385
 
385
 
386
	   while ($z < $anz) {
386
	   while ($z < $anz) {
387
	      $mon = gmdate("n", $akt);
387
	      $mon = gmdate("n", $akt);
388
	      $year = gmdate("Y", $akt);
388
	      $year = gmdate("Y", $akt);
389
	      $dstart = gmmktime(0, 0, 0, $mon, 1, $year);
389
	      $dstart = gmmktime(0, 0, 0, $mon, 1, $year);
390
	      $dend = gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year);
390
	      $dend = gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year);
391
 
391
 
392
	      if ($pr_status == 1) {
392
	      if ($pr_status == 1) {
393
	         $query = "select sum(wd_hours)/$leneinheit, wd_task from wdone, task ";
393
	         $query = "select sum(wd_hours)/$leneinheit, wd_task from wdone, task ";
394
	         $query .= "where wd_minum = $minum and ta_num = wd_task and ";
394
	         $query .= "where wd_minum = $minum and ta_num = wd_task and ";
395
	         $query .= "ta_hash = '$ta_hash' and wd_prnum = $pr_num and ";
395
	         $query .= "ta_hash = '$ta_hash' and wd_prnum = $pr_num and ";
396
	         $query .= "wd_datum >= $dstart and wd_datum <= $dend ";
396
	         $query .= "wd_datum >= $dstart and wd_datum <= $dend ";
397
	         $query .= "group by wd_task";
397
	         $query .= "group by wd_task";
398
 
398
 
399
	         if (!($reswd = QueryDB($db, $query)))
399
	         if (!($reswd = QueryDB($db, $query)))
400
	            return false;
400
	            return false;
401
 
401
 
402
	         if (numrowsDB($reswd) > 0) {
402
	         if (numrowsDB($reswd) > 0) {
403
		    $data = fetchDB($reswd, 0);
403
		    $data = fetchDB($reswd, 0);
404
		    $wd_hours = $data[0];
404
		    $wd_hours = $data[0];
405
		    $wd_task = $data[1];
405
		    $wd_task = $data[1];
406
 
406
 
407
		    if ($akt > $ab_datum)
407
		    if ($akt > $ab_datum)
408
		       $wd_edit = true;
408
		       $wd_edit = true;
409
		    else
409
		    else
410
		       $wd_edit = false;
410
		       $wd_edit = false;
411
 
411
 
412
		    $query = "select wd_num, wd_rk, wd_verr, wd_text from ";
412
		    $query = "select wd_num, wd_rk, wd_verr, wd_text from ";
413
		    $query .= "wdone, task where wd_minum = $minum and ";
413
		    $query .= "wdone, task where wd_minum = $minum and ";
414
		    $query .= "wd_prnum = $pr_num and ta_num = wd_task and ";
414
		    $query .= "wd_prnum = $pr_num and ta_num = wd_task and ";
415
		    $query .= "ta_hash = '$ta_hash' and wd_datum between $dstart and $dend ";
415
		    $query .= "ta_hash = '$ta_hash' and wd_datum between $dstart and $dend ";
416
		    $query .= "order by wd_datum";
416
		    $query .= "order by wd_datum";
417
 
417
 
418
		    if (!($resdr = QueryDB($db, $query)))
418
		    if (!($resdr = QueryDB($db, $query)))
419
		       return false;
419
		       return false;
420
 
420
 
421
		    $data = fetchDB($resdr, 0);
421
		    $data = fetchDB($resdr, 0);
422
		    $wd_num = $data[0];
422
		    $wd_num = $data[0];
423
		    $wd_rk = $data[1];
423
		    $wd_rk = $data[1];
424
		    $wd_verr = $data[2];
424
		    $wd_verr = $data[2];
425
		    $wd_text = $data[3];
425
		    $wd_text = $data[3];
426
 
426
 
427
		    if (CheckTrue($wd_verr))
427
		    if (CheckTrue($wd_verr))
428
		       $wd_verr = true;
428
		       $wd_verr = true;
429
		    else
429
		    else
430
		       $wd_verr = false;
430
		       $wd_verr = false;
431
		 } else {
431
		 } else {
432
		    $wd_hours = 0;
432
		    $wd_hours = 0;
433
		    $wd_edit = 1;
433
		    $wd_edit = 1;
434
		    $wd_task = $ta_num;
434
		    $wd_task = $ta_num;
435
		    $wd_num = 0;
435
		    $wd_num = 0;
436
		    $wd_rk = 0;
436
		    $wd_rk = 0;
437
		    $wd_verr = true;
437
		    $wd_verr = true;
438
		    $wd_text = "";
438
		    $wd_text = "";
439
		 }
439
		 }
440
	      } else {
440
	      } else {
441
	         $query = "select wd_num, wd_rk, wd_verr, wd_text from wdone where ";
441
	         $query = "select wd_num, wd_rk, wd_verr, wd_text from wdone where ";
442
	         $query .= "wd_minum = $minum and wd_prnum = $pr_num and ";
442
	         $query .= "wd_minum = $minum and wd_prnum = $pr_num and ";
443
	         $query .= "wd_task = $ta_num and wd_datum between $dstart and $dend ";
443
	         $query .= "wd_task = $ta_num and wd_datum between $dstart and $dend ";
444
	         $query .= "order by wd_datum";
444
	         $query .= "order by wd_datum";
445
 
445
 
446
	         if (!($reswd = QueryDB($db, $query)))
446
	         if (!($reswd = QueryDB($db, $query)))
447
	            return false;
447
	            return false;
448
 
448
 
449
	         if (numrowsDB($reswd) > 0) {
449
	         if (numrowsDB($reswd) > 0) {
450
	            $data = fetchDB($reswd, 0);
450
	            $data = fetchDB($reswd, 0);
451
		    $wd_num = $data[0];
451
		    $wd_num = $data[0];
452
		    $wd_rk = $data[1];
452
		    $wd_rk = $data[1];
453
		    $wd_verr = $data[2];
453
		    $wd_verr = $data[2];
454
		    $wd_text = $data[3];
454
		    $wd_text = $data[3];
455
 
455
 
456
		    if (CheckTrue($wd_verr))
456
		    if (CheckTrue($wd_verr))
457
		       $wd_verr = true;
457
		       $wd_verr = true;
458
		    else
458
		    else
459
		       $wd_verr = false;
459
		       $wd_verr = false;
460
	         } else {
460
	         } else {
461
		    $wd_num = 0;
461
		    $wd_num = 0;
462
		    $wd_rk = 0;
462
		    $wd_rk = 0;
463
		    $wd_verr = true;
463
		    $wd_verr = true;
464
		    $wd_text = "";
464
		    $wd_text = "";
465
	         }
465
	         }
466
 
466
 
467
	         $wd_hours = $ist;
467
	         $wd_hours = $ist;
468
	         $wd_edit = $tmp_edit;
468
	         $wd_edit = $tmp_edit;
469
	         $wd_task = $ta_num;
469
	         $wd_task = $ta_num;
470
	      }
470
	      }
471
 
471
 
472
	      if ($pr_status == 0) {
472
	      if ($pr_status == 0) {
473
		 $tmon = gmdate("n", $ta_start);
473
		 $tmon = gmdate("n", $ta_start);
474
		 $tyear = gmdate("Y", $ta_start);
474
		 $tyear = gmdate("Y", $ta_start);
475
		 $td = gmmktime(0, 0, 0, $tmon, 1, $tyear);
475
		 $td = gmmktime(0, 0, 0, $tmon, 1, $tyear);
476
	      } else
476
	      } else
477
		 $td = 0;
477
		 $td = 0;
478
 
478
 
479
	      if ($ist_future) {
479
	      if ($ist_future) {
480
		 if ($pr_status == 0) {
480
		 if ($pr_status == 0) {
481
		    $ta_end = $ta_start + $ta_duration * 86400;
481
		    $ta_end = $ta_start + $ta_duration * 86400;
482
		    $temon = gmdate("n", $ta_end);
482
		    $temon = gmdate("n", $ta_end);
483
		    $teyear = gmdate("Y", $ta_end);
483
		    $teyear = gmdate("Y", $ta_end);
484
		    $te = gmmktime(0, 0, 0, $temon, daysinmonth($temon, $teyear), $teyear);
484
		    $te = gmmktime(0, 0, 0, $temon, daysinmonth($temon, $teyear), $teyear);
485
		    $dcomp = ($akt >= $td && $akt <= $te) ? true : false;
485
		    $dcomp = ($akt >= $td && $akt <= $te) ? true : false;
486
		 } else {
486
		 } else {
487
		    $te = 0;
487
		    $te = 0;
488
		    $dcomp = true;
488
		    $dcomp = true;
489
		 }
489
		 }
490
	      } else
490
	      } else
491
		 $dcomp = ($akt >= $td) ? true : false;
491
		 $dcomp = ($akt >= $td) ? true : false;
492
 
492
 
493
	      if ($pr_status == 0) {
493
	      if ($pr_status == 0) {
494
		 $al_hours = $plan;
494
		 $al_hours = $plan;
495
		 $sump += $al_hours;
495
		 $sump += $al_hours;
496
		 $sumparr[$z] += $al_hours;
496
		 $sumparr[$z] += $al_hours;
497
	      } else
497
	      } else
498
	         $al_hours = 0;
498
	         $al_hours = 0;
499
 
499
 
500
	      # Heraus finden, ob der aktuelle Task dem neuesten Plan gehoert,
500
	      # Heraus finden, ob der aktuelle Task dem neuesten Plan gehoert,
501
	      # oder nicht. Wenn es sich um einen aelteren Plan handelt
501
	      # oder nicht. Wenn es sich um einen aelteren Plan handelt
502
	      # (Status = Inaktiv) dann darf keine IST-Eingabe moeglich sein.
502
	      # (Status = Inaktiv) dann darf keine IST-Eingabe moeglich sein.
503
	      if ($dcomp) {
503
	      if ($dcomp) {
504
		 $query = "select pl_status from plan where ";
504
		 $query = "select pl_status from plan where ";
505
		 $query .= "pl_num = $pl_num";
505
		 $query .= "pl_num = $pl_num";
506
 
506
 
507
		 if (!($resdc = QueryDB($db, $query)))
507
		 if (!($resdc = QueryDB($db, $query)))
508
		    return false;
508
		    return false;
509
 
509
 
510
		 $data = fetchDB($resdc, 0);
510
		 $data = fetchDB($resdc, 0);
511
		 $akt_status = $data[0];
511
		 $akt_status = $data[0];
512
 
512
 
513
		 if ($pl_status < $akt_status || $pl_status == 6) {
513
		 if ($pl_status < $akt_status || $pl_status == 6) {
514
		    $dcomp = false;
514
		    $dcomp = false;
515
		    $pplan = true;
515
		    $pplan = true;
516
		 }
516
		 }
517
	      } else
517
	      } else
518
	         $pplan = false;
518
	         $pplan = false;
519
 
519
 
520
//	      if ($akt > $ab_datum && $dcomp && CheckTrue($wd_edit)) {
520
//	      if ($akt > $ab_datum && $dcomp && CheckTrue($wd_edit)) {
521
	      if ((($rstufe == 1 || $rstufe == 4) && $akt <= $ab_datum && $dcomp) || ($akt > $ab_datum && $dcomp)) {
521
	      if ((($rstufe == 1 || $rstufe == 4) && $akt <= $ab_datum && $dcomp) || ($akt > $ab_datum && $dcomp)) {
522
		 $class = "selnum";
522
		 $class = "selnum";
523
		 $name = "dt_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $akt;
523
		 $name = "dt_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $akt;
524
		 echo "<td class=\"$class\"><table border=0 cellspacing=0 cellpadding=0><tr><td class=\"$class\">";
524
		 echo "<td class=\"$class\"><table border=0 cellspacing=0 cellpadding=0><tr><td class=\"$class\">";
525
		 printf("%s<br><input type=\"text\" name=\"$name\" value=\"%s\" size=6 maxlength=6 onChange=\"javascript:document.getElementById('message').style.visibility = 'visible';\"></td>\n",
525
		 printf("%s<br><input type=\"text\" name=\"$name\" value=\"%s\" size=6 maxlength=6 onChange=\"javascript:document.getElementById('message').style.visibility = 'visible';\"></td>\n",
526
			FormatNum($al_hours, 3),
526
			FormatNum($al_hours, 3),
527
			($wd_hours <= 0) ? "" : FormatNum($wd_hours, 3));
527
			($wd_hours <= 0) ? "" : FormatNum($wd_hours, 3));
528
 
528
 
529
		 if ($verrmodul) {
529
		 if ($verrmodul) {
530
		    $dr_num = 0;
530
		    $dr_num = 0;
531
		    $dr_date_start = "";
531
		    $dr_date_start = "";
532
		    $dr_time_start = "";
532
		    $dr_time_start = "";
533
		    $dr_date_end = "";
533
		    $dr_date_end = "";
534
		    $dr_time_end = "";
534
		    $dr_time_end = "";
535
		    $dr_target = "";
535
		    $dr_target = "";
536
		    $dr_purpose = "";
536
		    $dr_purpose = "";
537
		    $dr_pnightr = false;
537
		    $dr_pnightr = false;
538
		    $dr_nightr = 0;
538
		    $dr_nightr = 0;
539
		    $dr_amount = 0;
539
		    $dr_amount = 0;
540
		    $dr_kmcar = 0;
540
		    $dr_kmcar = 0;
541
		    $dr_kfzkenn = "";
541
		    $dr_kfzkenn = "";
542
		    $dr_kmdrain = 0;
542
		    $dr_kmdrain = 0;
543
		    $dr_pkmplain = false;
543
		    $dr_pkmplain = false;
544
		    $dr_kmplain = 0;
544
		    $dr_kmplain = 0;
545
		    $dr_costloc = 0;
545
		    $dr_costloc = 0;
546
		    $dr_whg = $stdwhg;
546
		    $dr_whg = $stdwhg;
547
 
547
 
548
		    if ($wd_num > 0) {
548
		    if ($wd_num > 0) {
549
		       $dtdb = GetDBDateFormat();
549
		       $dtdb = GetDBDateFormat();
550
		       $query = "select dr_num, to_char(dr_date_start, '$dtdb'),";
550
		       $query = "select dr_num, to_char(dr_date_start, '$dtdb'),";
551
		       $query .= "to_char(dr_date_start, 'HH24:MI'), ";
551
		       $query .= "to_char(dr_date_start, 'HH24:MI'), ";
552
		       $query .= "to_char(dr_date_end, '$dtdb'), to_char(dr_date_end, 'HH24:MI'),";
552
		       $query .= "to_char(dr_date_end, '$dtdb'), to_char(dr_date_end, 'HH24:MI'),";
553
		       $query .= "dr_target, dr_purpose, dr_pnightr, dr_nightr, dr_amount,";
553
		       $query .= "dr_target, dr_purpose, dr_pnightr, dr_nightr, dr_amount,";
554
		       $query .= "dr_kmcar, dr_kfzkenn, dr_kmdrain, dr_pkmplain,";
554
		       $query .= "dr_kmcar, dr_kfzkenn, dr_kmdrain, dr_pkmplain,";
555
		       $query .= "dr_kmplain, dr_costloc, dr_whg, dr_remark from dration ";
555
		       $query .= "dr_kmplain, dr_costloc, dr_whg, dr_remark from dration ";
556
		       $query .= "where dr_wdnum = $wd_num";
556
		       $query .= "where dr_wdnum = $wd_num";
557
 
557
 
558
		       if (!($resdr = QueryDB($db, $query)))
558
		       if (!($resdr = QueryDB($db, $query)))
559
		          return false;
559
		          return false;
560
 
560
 
561
		       if (numrowsDB($resdr) > 0) {
561
		       if (numrowsDB($resdr) > 0) {
562
		          $data = fetchDB($resdr, 0);
562
		          $data = fetchDB($resdr, 0);
563
			  $dr_num = $data[0];
563
			  $dr_num = $data[0];
564
			  $dr_date_start = $data[1];
564
			  $dr_date_start = $data[1];
565
			  $dr_time_start = $data[2];
565
			  $dr_time_start = $data[2];
566
			  $dr_date_end = $data[3];
566
			  $dr_date_end = $data[3];
567
			  $dr_time_end = $data[4];
567
			  $dr_time_end = $data[4];
568
			  $dr_target = $data[5];
568
			  $dr_target = $data[5];
569
			  $dr_purpose = $data[6];
569
			  $dr_purpose = $data[6];
570
			  $dr_pnightr = $data[7];
570
			  $dr_pnightr = $data[7];
571
			  $dr_nightr = $data[8];
571
			  $dr_nightr = $data[8];
572
			  $dr_amount = $data[9];
572
			  $dr_amount = $data[9];
573
			  $dr_kmcar = $data[10];
573
			  $dr_kmcar = $data[10];
574
			  $dr_kfzkenn = $data[11];
574
			  $dr_kfzkenn = $data[11];
575
			  $dr_kmdrain = $data[12];
575
			  $dr_kmdrain = $data[12];
576
			  $dr_pkmplain = $data[13];
576
			  $dr_pkmplain = $data[13];
577
			  $dr_kmplain = $data[14];
577
			  $dr_kmplain = $data[14];
578
			  $dr_costloc = $data[15];
578
			  $dr_costloc = $data[15];
579
			  $dr_whg = $data[16];
579
			  $dr_whg = $data[16];
580
			  $dr_remark = $data[17];
580
			  $dr_remark = $data[17];
581
		       }
581
		       }
582
		    }
582
		    }
583
 
583
 
584
		    echo "<td>";
584
		    echo "<td>";
585
		    ButtonImagePrint("pencil.png", "Ergaenzungen", "verrmist.php",
585
		    ButtonImagePrint("pencil.png", "Ergaenzungen", "verrmist.php",
586
		 	"menu=$menu&headline=$headline&minum=$minum&pr_num=$pr_num&".
586
		 	"menu=$menu&headline=$headline&minum=$minum&pr_num=$pr_num&".
587
		 	"ta_num=$wd_task&datum=$akt&header=2&func=AddIst&".
587
		 	"ta_num=$wd_task&datum=$akt&header=2&func=AddIst&".
588
			"dr_whg=$dr_whg", 725, 720, true);
588
			"dr_whg=$dr_whg", 725, 720, true);
589
		 }
589
		 }
590
 
590
 
591
		 echo "</td></tr></table>";
591
		 echo "</td></tr></table>";
592
 
592
 
593
		 if ($verrmodul) {
593
		 if ($verrmodul) {
594
		    if (!isset($dr_date_start) || strlen($dr_date_start) < 6) {
594
		    if (!isset($dr_date_start) || strlen($dr_date_start) < 6) {
595
		       $dr_date_start = date($dtformatshort, $akt);
595
		       $dr_date_start = date($dtformatshort, $akt);
596
		       $dr_time_start = "08:00";
596
		       $dr_time_start = "08:00";
597
		    }
597
		    }
598
 
598
 
599
		    if (!isset($dr_date_end) || strlen($dr_date_end) < 6) {
599
		    if (!isset($dr_date_end) || strlen($dr_date_end) < 6) {
600
		       $dr_date_end = $dr_date_start;
600
		       $dr_date_end = $dr_date_start;
601
		       $dr_time_end = "18:00";
601
		       $dr_time_end = "18:00";
602
		    }
602
		    }
603
 
603
 
604
		    $hidden = "vr_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
604
		    $hidden = "vr_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
605
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$wd_verr\">\n";
605
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$wd_verr\">\n";
606
		    $hidden = "rk_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
606
		    $hidden = "rk_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
607
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$wd_rk\">\n";
607
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$wd_rk\">\n";
608
		    $hidden = "am_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
608
		    $hidden = "am_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
609
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_amount\">\n";
609
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_amount\">\n";
610
		    $hidden = "nu_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
610
		    $hidden = "nu_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
611
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_num\">\n";
611
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_num\">\n";
612
		    $hidden = "wh_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
612
		    $hidden = "wh_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
613
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_whg\">\n";
613
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_whg\">\n";
614
		    $hidden = "tx_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
614
		    $hidden = "tx_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
615
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$wd_text\">\n";
615
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$wd_text\">\n";
616
		    $hidden = "ds_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
616
		    $hidden = "ds_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
617
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_date_start\">\n";
617
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_date_start\">\n";
618
		    $hidden = "de_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
618
		    $hidden = "de_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
619
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_date_end\">\n";
619
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_date_end\">\n";
620
		    $hidden = "ts_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
620
		    $hidden = "ts_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
621
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_time_start\">\n";
621
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_time_start\">\n";
622
		    $hidden = "te_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
622
		    $hidden = "te_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
623
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_time_end\">\n";
623
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_time_end\">\n";
624
		    $hidden = "ta_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
624
		    $hidden = "ta_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
625
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_target\">\n";
625
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_target\">\n";
626
		    $hidden = "pu_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
626
		    $hidden = "pu_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
627
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_purpose\">\n";
627
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_purpose\">\n";
628
		    $hidden = "pn_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
628
		    $hidden = "pn_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
629
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_pnightr\">\n";
629
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_pnightr\">\n";
630
		    $hidden = "ni_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
630
		    $hidden = "ni_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
631
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_nightr\">\n";
631
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_nightr\">\n";
632
		    $hidden = "mc_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
632
		    $hidden = "mc_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
633
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kmcar\">\n";
633
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kmcar\">\n";
634
		    $hidden = "kf_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
634
		    $hidden = "kf_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
635
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kfzkenn\">\n";
635
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kfzkenn\">\n";
636
		    $hidden = "md_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
636
		    $hidden = "md_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
637
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kmdrain\">\n";
637
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kmdrain\">\n";
638
		    $hidden = "pp_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
638
		    $hidden = "pp_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
639
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_pkmplain\">\n";
639
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_pkmplain\">\n";
640
		    $hidden = "mp_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
640
		    $hidden = "mp_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
641
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kmplain\">\n";
641
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_kmplain\">\n";
642
		    $hidden = "cl_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
642
		    $hidden = "cl_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
643
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_costloc\">\n";
643
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_costloc\">\n";
644
		    $hidden = "rm_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
644
		    $hidden = "rm_" . $minum . "_" . $pr_num . "_" . $ta_num . "_" . $akt;
645
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_remark\">\n";
645
		    echo "<input type=\"hidden\" name=\"$hidden\" value=\"$dr_remark\">\n";
646
		 }
646
		 }
647
 
647
 
648
		 echo "</td>\n";
648
		 echo "</td>\n";
649
	      }
649
	      }
650
	      else if ($pplan)
650
	      else if ($pplan)
651
	         printf("<td class=\"selnum\">%s<br>%s</td>\n",
651
	         printf("<td class=\"selnum\">%s<br>%s</td>\n",
652
	            FormatNum($al_hours, 3), FormatNum($wd_hours, 3));
652
	            FormatNum($al_hours, 3), FormatNum($wd_hours, 3));
653
	      else
653
	      else
654
	         printf("<td class=\"selnum\">%s<br>%s</td>\n",
654
	         printf("<td class=\"selnum\">%s<br>%s</td>\n",
655
	         	($al_hours <= 0) ? "" : FormatNum($al_hours, 3),
655
	         	($al_hours <= 0) ? "" : FormatNum($al_hours, 3),
656
	         	($wd_hours <= 0) ? "" : FormatNum($wd_hours, 3));
656
	         	($wd_hours <= 0) ? "" : FormatNum($wd_hours, 3));
657
 
657
 
658
	      $akt = IncDate($periode, $akt);
658
	      $akt = IncDate($periode, $akt);
659
	      $sumi += $wd_hours;
659
	      $sumi += $wd_hours;
660
	      $sumiarr[$z] += $wd_hours;
660
	      $sumiarr[$z] += $wd_hours;
661
	      $z++;
661
	      $z++;
662
 
662
 
663
	      if ($pr_status == 0 && $z < $anz) {
663
	      if ($pr_status == 0 && $z < $anz) {
664
		 $r++;
664
		 $r++;
665
 
665
 
666
		 if ($r >= $rows) {
666
		 if ($r >= $rows) {
667
		    $r--;
667
		    $r--;
668
		 } else {
668
		 } else {
669
		    $data = fetchDB($res, $r);
669
		    $data = fetchDB($res, $r);
670
		    $ta_name = $data[0];
670
		    $ta_name = $data[0];
671
		    $plan = $data[1];
671
		    $plan = $data[1];
672
		    $ta_num = $data[2];
672
		    $ta_num = $data[2];
673
		    $ta_start = $data[3];
673
		    $ta_start = $data[3];
674
		    $ta_duration = $data[4];
674
		    $ta_duration = $data[4];
675
		    $ta_hash = $data[5];
675
		    $ta_hash = $data[5];
676
		    $ist = $data[6];
676
		    $ist = $data[6];
677
		    $tmp_periode = $data[7];
677
		    $tmp_periode = $data[7];
678
		 }
678
		 }
679
	      }
679
	      }
680
	   }
680
	   }
681
 
681
 
682
	   printf("<td class=\"selakt\" align=\"right\"><b>%s</b></td>\n", FormatNum($sump, 3));
682
	   printf("<td class=\"selakt\" align=\"right\"><b>%s</b></td>\n", FormatNum($sump, 3));
683
 
683
 
684
	   if ($sumi > $sump && $pr_status == 0)
684
	   if ($sumi > $sump && $pr_status == 0)
685
	      printf("<td class=\"five\" align=\"right\"><br><b>%s</b></td>\n", FormatNum($sumi, 3));
685
	      printf("<td class=\"five\" align=\"right\"><br><b>%s</b></td>\n", FormatNum($sumi, 3));
686
	   else
686
	   else
687
	      printf("<td class=\"selakt\" align=\"right\"><br><b>%s</b></td>\n", FormatNum($sumi, 3));
687
	      printf("<td class=\"selakt\" align=\"right\"><br><b>%s</b></td>\n", FormatNum($sumi, 3));
688
 
688
 
689
	   # Um die Summen des gesamten Task anzeigen zu koennen, muessen wir
689
	   # Um die Summen des gesamten Task anzeigen zu koennen, muessen wir
690
	   # erst alles summieren. Das gilt jedoch nur fuer Projekte und nicht
690
	   # erst alles summieren. Das gilt jedoch nur fuer Projekte und nicht
691
	   # fuer Konten!
691
	   # fuer Konten!
692
	   if ($pr_status == 0) {
692
	   if ($pr_status == 0) {
693
	      $query = "select sum(al_hours) from allocation where ";
693
	      $query = "select sum(al_hours) from allocation where ";
694
	      $query .= "al_task = $ta_num and al_ressource = $minum";
694
	      $query .= "al_task = $ta_num and al_ressource = $minum";
695
 
695
 
696
	      if (!($ressu = QueryDB($db, $query)))
696
	      if (!($ressu = QueryDB($db, $query)))
697
	         return false;
697
	         return false;
698
 
698
 
699
	      $data = fetchDB($ressu, 0);
699
	      $data = fetchDB($ressu, 0);
700
	      $plan = $data[0];
700
	      $plan = $data[0];
701
 
701
 
702
	      $query = "select sum(wd_hours) / $leneinheit from wdone, task where ";
702
	      $query = "select sum(wd_hours) / $leneinheit from wdone, task where ";
703
	      $query .= "ta_num = wd_task and ta_hash = '$ta_hash' and ";
703
	      $query .= "ta_num = wd_task and ta_hash = '$ta_hash' and ";
704
	      $query .= "wd_minum = $minum and wd_prnum = $pr_num";
704
	      $query .= "wd_minum = $minum and wd_prnum = $pr_num";
705
 
705
 
706
	      if (!($ressu = QueryDB($db, $query)))
706
	      if (!($ressu = QueryDB($db, $query)))
707
	         return false;
707
	         return false;
708
 
708
 
709
	      $data = fetchDB($ressu, 0);
709
	      $data = fetchDB($ressu, 0);
710
	      $ist = $data[0];
710
	      $ist = $data[0];
711
	   } else {
711
	   } else {
712
	      $plan = 0.0;
712
	      $plan = 0.0;
713
	      $ist = 0.0;
713
	      $ist = 0.0;
714
	   }
714
	   }
715
 
715
 
716
	   printf("<td class=\"selnum\"><b>%s</b></td>\n", FormatNum($plan, 3));
716
	   printf("<td class=\"selnum\"><b>%s</b></td>\n", FormatNum($plan, 3));
717
 
717
 
718
	   if (!$ist_erledigung && $ist > $plan && $pr_status == 0)
718
	   if (!$ist_erledigung && $ist > $plan && $pr_status == 0)
719
	      printf("<td class=\"five\" align=\"right\" valign=\"top\"><br><b>%s</b></td>\n", FormatNum($ist, 3));
719
	      printf("<td class=\"five\" align=\"right\" valign=\"top\"><br><b>%s</b></td>\n", FormatNum($ist, 3));
720
	   else
720
	   else
721
	      printf("<td class=\"selnum\"><b><br>%s</b></td>\n", FormatNum($ist, 3));
721
	      printf("<td class=\"selnum\"><b><br>%s</b></td>\n", FormatNum($ist, 3));
722
 
722
 
723
	   $sumallp += $plan;
723
	   $sumallp += $plan;
724
	   $sumalli += $ist;
724
	   $sumalli += $ist;
725
 
725
 
726
	   if ($ist_erledigung) {
726
	   if ($ist_erledigung) {
727
	      if ($proz > 100.0 && $pr_status == 0)
727
	      if ($proz > 100.0 && $pr_status == 0)
728
	         printf ("<td class=\"five\" align=\"right\">%s%%</td></tr>\n", FormatNum($proz, 1));
728
	         printf ("<td class=\"five\" align=\"right\">%s%%</td></tr>\n", FormatNum($proz, 1));
729
	      else
729
	      else
730
	         printf ("<td class=\"selnum\">%s%%</td></tr>\n", FormatNum($proz, 1));
730
	         printf ("<td class=\"selnum\">%s%%</td></tr>\n", FormatNum($proz, 1));
731
	   }
731
	   }
732
 
732
 
733
	   $r++;
733
	   $r++;
734
	}
734
	}
735
 
735
 
736
//	if ($pr_status == 0)
736
//	if ($pr_status == 0)
737
//	   QueryDB($db, "drop table TempTask");
737
//	   QueryDB($db, "drop table TempTask");
738
 
738
 
739
	return true;
739
	return true;
740
}
740
}
741
 
741
 
742
# Folgende Funktion verwaltet und visualisiert die Auswahlmoeglichkeiten
742
# Folgende Funktion verwaltet und visualisiert die Auswahlmoeglichkeiten
743
# fuer die IST-Erfassung. Fuer die Darstellung und Eingabefelder der
743
# fuer die IST-Erfassung. Fuer die Darstellung und Eingabefelder der
744
# eigentlichen Isterfassung fuer einen Mitarbeiter, siehe ShowMitarbeiter()
744
# eigentlichen Isterfassung fuer einen Mitarbeiter, siehe ShowMitarbeiter()
745
#
745
#
746
function ManageTime() {
746
function ManageTime() {
747
	global $phase;
747
	global $phase;
748
	global $rstufe;
748
	global $rstufe;
749
	global $unum;
749
	global $unum;
750
	global $einheit;
750
	global $einheit;
751
	global $leneinheit;
751
	global $leneinheit;
752
	global $periode;
752
	global $periode;
753
	global $ist_erledigung;
753
	global $ist_erledigung;
754
	global $ist_future;
754
	global $ist_future;
755
	global $menu;
755
	global $menu;
756
	global $headline;
756
	global $headline;
757
	global $sumparr;
757
	global $sumparr;
758
	global $sumiarr;
758
	global $sumiarr;
759
	global $sumallp;
759
	global $sumallp;
760
	global $sumalli;
760
	global $sumalli;
761
	global $dtformatshort;
761
	global $dtformatshort;
762
 
762
 
763
	$db = OpenDB();
763
	$db = OpenDB();
764
	$nav = "menu=$menu&headline=$headline&project='+";
764
	$nav = "menu=$menu&headline=$headline&project='+";
765
 
765
 
766
	if ($rstufe != 3) {
766
	if ($rstufe != 3) {
767
	   $nav .= "document.ist.project.value+'&mitarbeiter='+";
767
	   $nav .= "document.ist.project.value+'&mitarbeiter='+";
768
	   $nav .= "document.ist.mitarbeiter.value+'&von='+";
768
	   $nav .= "document.ist.mitarbeiter.value+'&von='+";
769
	} else
769
	} else
770
	   $nav .= "document.ist.project.value+'&von='+";
770
	   $nav .= "document.ist.project.value+'&von='+";
771
 
771
 
772
	$nav .= "document.ist.von.value+'&bis='+document.ist.bis.value+'";
772
	$nav .= "document.ist.von.value+'&bis='+document.ist.bis.value+'";
773
 
773
 
774
	# Per default waehlen wir alle Projekte (eines Mitarbeiters) aus,
774
	# Per default waehlen wir alle Projekte (eines Mitarbeiters) aus,
775
	# alle Mitarbeiter die diesem Projekt zugeordnet sind, sofern es sich
775
	# alle Mitarbeiter die diesem Projekt zugeordnet sind, sofern es sich
776
	# um den Projektleiter handelt und die im Zeitraum der aktuellen
776
	# um den Projektleiter handelt und die im Zeitraum der aktuellen
777
	# Periode sind, aus.
777
	# Periode sind, aus.
778
	#
778
	#
779
	if ($rstufe == 2 || $rstufe == 3) {
779
	if ($rstufe == 2 || $rstufe == 3) {
780
	   $query = "select distinct on (pr_num) pr_num, pr_name, pr_pl, mi_nname, mi_vname, pl_num, pl_lfd, pl_status ";
780
	   $query = "select distinct on (pr_num) pr_num, pr_name, pr_pl, mi_nname, mi_vname, pl_num, pl_lfd, pl_status ";
781
	   $query .= "from project ";
781
	   $query .= "from project ";
782
	   $query .= "inner join plan on pl_prnum = pr_num and pl_status in (0,2,3,4,6) ";
782
	   $query .= "inner join plan on pl_prnum = pr_num and pl_status in (0,2,3,4,6) ";
783
	   $query .= "left join task on ta_plnum = pl_num ";
783
	   $query .= "left join task on ta_plnum = pl_num ";
784
	   $query .= "left join allocation on ta_num = al_task ";
784
	   $query .= "left join allocation on ta_num = al_task ";
785
	   $query .= "left join mitarbeiter on mi_num = pr_pl ";
785
	   $query .= "left join mitarbeiter on mi_num = pr_pl ";
786
 
786
 
787
	   if ($rstufe == 2)
787
	   if ($rstufe == 2)
788
	      $query .= "where pr_pl = $unum or pr_status = 1 or al_ressource = $unum ";
788
	      $query .= "where pr_pl = $unum or pr_status = 1 or al_ressource = $unum ";
789
	   else
789
	   else
790
	      $query .= "where pr_status = 1 or al_ressource = $unum";
790
	      $query .= "where pr_status = 1 or al_ressource = $unum";
791
 
791
 
792
	} else {
792
	} else {
793
	   $query = "select distinct on (pr_num) pr_num, pr_name, pr_pl, mi_nname, mi_vname, ";
793
	   $query = "select distinct on (pr_num) pr_num, pr_name, pr_pl, mi_nname, mi_vname, ";
794
	   $query .= "pl_num, pl_lfd, pl_status ";
794
	   $query .= "pl_num, pl_lfd, pl_status ";
795
	   $query .= "from project left join mitarbeiter on mi_num = pr_pl ";
795
	   $query .= "from project left join mitarbeiter on mi_num = pr_pl ";
796
	   $query .= "left join plan on pl_prnum = pr_num ";
796
	   $query .= "left join plan on pl_prnum = pr_num ";
797
	   $query .= "where pr_num in (select pl_prnum from plan where ";
797
	   $query .= "where pr_num in (select pl_prnum from plan where ";
798
	   $query .= "pl_status in (0, 2, 3, 4, 5, 6)) and pl_status in (0,2,3,4,5,6) ";
798
	   $query .= "pl_status in (0, 2, 3, 4, 5, 6)) and pl_status in (0,2,3,4,5,6) ";
799
	}
799
	}
800
 
800
 
801
	$query .= "order by pr_num, pl_lfd desc";
801
	$query .= "order by pr_num, pl_lfd desc";
802
 
802
 
803
	if (!($result = QueryDB($db, $query))) {
803
	if (!($result = QueryDB($db, $query))) {
804
	   closeDB($db);
804
	   closeDB($db);
805
	   return;
805
	   return;
806
	}
806
	}
807
 
807
 
808
	$rows = numrowsDB($result);
808
	$rows = numrowsDB($result);
809
 
809
 
810
	if ($rows <= 0) {
810
	if ($rows <= 0) {
811
	   Error(GetMessage($db, 238, "Es wurden keine bebuchbaren Projekte gefunden!"));
811
	   Error(GetMessage($db, 238, "Es wurden keine bebuchbaren Projekte gefunden!"));
812
	   closeDB($db);
812
	   closeDB($db);
813
	   return;
813
	   return;
814
	}
814
	}
815
 
815
 
816
	# Auswahlfelder fuer die IST-Buchungen anzeigen
816
	# Auswahlfelder fuer die IST-Buchungen anzeigen
817
	$project = $_REQUEST['project'];
817
	$project = $_REQUEST['project'];
818
	$mitarbeiter = $_REQUEST['mitarbeiter'];
818
	$mitarbeiter = $_REQUEST['mitarbeiter'];
819
	$von = $_REQUEST['von'];
819
	$von = $_REQUEST['von'];
820
	$bis = $_REQUEST['bis'];
820
	$bis = $_REQUEST['bis'];
821
	$func = $_REQUEST['func'];
821
	$func = $_REQUEST['func'];
822
 
822
 
823
	if (!isset($mitarbeiter))
823
	if (!isset($mitarbeiter))
824
	   $mitarbeiter = $unum;
824
	   $mitarbeiter = $unum;
825
 
825
 
826
	if (isset($von) && isset($bis)) {
826
	if (isset($von) && isset($bis)) {
827
	   $dxa = explode(GetDateSep(), $von);
827
	   $dxa = explode(GetDateSep(), $von);
828
	   $dxb = explode(GetDateSep(), $bis);
828
	   $dxb = explode(GetDateSep(), $bis);
829
	   $dta = gmmktime(0, 0, 0, $dxa[0], 1, $dxa[1]);
829
	   $dta = gmmktime(0, 0, 0, $dxa[0], 1, $dxa[1]);
830
	   $dtb = gmmktime(0, 0, 0, $dxb[0], 1, $dxb[1]);
830
	   $dtb = gmmktime(0, 0, 0, $dxb[0], 1, $dxb[1]);
831
 
831
 
832
	   if ($dta > $dtb) {
832
	   if ($dta > $dtb) {
833
	      Error(GetMessage($db, 239, "Das \"Datum von\" darf nicht gr&ouml;&szlig;er als das \"Datum bis\" sein!"));
833
	      Error(GetMessage($db, 239, "Das \"Datum von\" darf nicht gr&ouml;&szlig;er als das \"Datum bis\" sein!"));
834
	      unset($von);
834
	      unset($von);
835
	      unset($bis);
835
	      unset($bis);
836
	   } else {
836
	   } else {
837
	      if (isset($func) && $func == "PrevWeek") {
837
	      if (isset($func) && $func == "PrevWeek") {
838
	         $dxa[0]--;
838
	         $dxa[0]--;
839
 
839
 
840
		 if ($dxa[0] < 1) {
840
		 if ($dxa[0] < 1) {
841
		    $dxa[0] = 12;
841
		    $dxa[0] = 12;
842
		    $dxa[1]--;
842
		    $dxa[1]--;
843
		 }
843
		 }
844
 
844
 
845
		 $dta = gmmktime(0, 0, 0, $dxa[0], 1, $dxa[1]);
845
		 $dta = gmmktime(0, 0, 0, $dxa[0], 1, $dxa[1]);
846
	         $dxb[0]--;
846
	         $dxb[0]--;
847
 
847
 
848
		 if ($dxb[0] < 1) {
848
		 if ($dxb[0] < 1) {
849
		    $dxb[0] = 12;
849
		    $dxb[0] = 12;
850
		    $dxb[1]--;
850
		    $dxb[1]--;
851
		 }
851
		 }
852
 
852
 
853
		 $dtb = gmmktime(0, 0, 0, $dxb[0], 1, $dxb[1]);
853
		 $dtb = gmmktime(0, 0, 0, $dxb[0], 1, $dxb[1]);
854
	      } else if (isset($func) && $func == "NextWeek") {
854
	      } else if (isset($func) && $func == "NextWeek") {
855
	         $dxa[0]++;
855
	         $dxa[0]++;
856
 
856
 
857
		 if ($dxa[0] > 12) {
857
		 if ($dxa[0] > 12) {
858
		    $dxa[0] = 1;
858
		    $dxa[0] = 1;
859
		    $dxa[1]++;
859
		    $dxa[1]++;
860
		 }
860
		 }
861
 
861
 
862
		 $dta = gmmktime(0, 0, 0, $dxa[0], 1, $dxa[1]);
862
		 $dta = gmmktime(0, 0, 0, $dxa[0], 1, $dxa[1]);
863
	         $dxb[0]++;
863
	         $dxb[0]++;
864
 
864
 
865
		 if ($dxb[0] > 12) {
865
		 if ($dxb[0] > 12) {
866
		    $dxb[0] = 1;
866
		    $dxb[0] = 1;
867
		    $dxb[1]++;
867
		    $dxb[1]++;
868
		 }
868
		 }
869
 
869
 
870
		 $dtb = gmmktime(0, 0, 0, $dxb[0], 1, $dxb[1]);
870
		 $dtb = gmmktime(0, 0, 0, $dxb[0], 1, $dxb[1]);
871
	      }
871
	      }
872
 
872
 
873
	      if (isset($func) && $func == "Today") {
873
	      if (isset($func) && $func == "Today") {
874
	         unset($von);
874
	         unset($von);
875
		 unset($bis);
875
		 unset($bis);
876
	      } else {
876
	      } else {
877
	         $von = GetShortDate($dta);
877
	         $von = GetShortDate($dta);
878
		 $bis = GetShortDate($dtb);
878
		 $bis = GetShortDate($dtb);
879
	      }
879
	      }
880
	   }
880
	   }
881
 
881
 
882
	   unset($dxa);
882
	   unset($dxa);
883
	   unset($dxb);
883
	   unset($dxb);
884
	   unset($dta);
884
	   unset($dta);
885
	   unset($dtb);
885
	   unset($dtb);
886
	}
886
	}
887
 
887
 
888
	echo "<form name=\"ist\" action=\"istpm.php\" method=\"post\" onChange=\"javascript:AktDocument=this\">\n";
888
	echo "<form name=\"ist\" action=\"istpm.php\" method=\"post\" onChange=\"javascript:AktDocument=this\">\n";
889
	echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n";
889
	echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n";
890
	echo "<input type=\"hidden\" name=\"headline\" value=\"$headline\">\n";
890
	echo "<input type=\"hidden\" name=\"headline\" value=\"$headline\">\n";
891
	echo "<input type=\"hidden\" name=\"func\" value=\"save\">\n";
891
	echo "<input type=\"hidden\" name=\"func\" value=\"save\">\n";
892
	# Hier werden zwei Tabellen ineinander verschachtelt. Die aeussere
892
	# Hier werden zwei Tabellen ineinander verschachtelt. Die aeussere
893
	# Tabelle beinhaltet in der linken Spalte die Tabelle zum Setzen
893
	# Tabelle beinhaltet in der linken Spalte die Tabelle zum Setzen
894
	# der Grundeinstellungen.
894
	# der Grundeinstellungen.
895
	# Die rechte Spalte beinhaltet optional Hinweise fuer den Benutzer,
895
	# Die rechte Spalte beinhaltet optional Hinweise fuer den Benutzer,
896
	# wie z.B. dass Daten veraendert wurden, aber noch nicht gespeichert
896
	# wie z.B. dass Daten veraendert wurden, aber noch nicht gespeichert
897
	# sind.
897
	# sind.
898
	echo "<table width=\"98%\"border=0 cellpadding=0 cellspacing=0><tr><td>";
898
	echo "<table width=\"98%\"border=0 cellpadding=0 cellspacing=0><tr><td>";
899
	# Auswahlmoeglichkeiten in der linken Spalte:
899
	# Auswahlmoeglichkeiten in der linken Spalte:
900
	echo "<table class=\"input\">\n<tr>\n";
900
	echo "<table class=\"input\">\n<tr>\n";
901
	# Projekte anzeigen
901
	# Projekte anzeigen
902
	echo "<td>" . GetMessage($db, 240, "Projekte") . "</td>\n";
902
	echo "<td>" . GetMessage($db, 240, "Projekte") . "</td>\n";
903
	echo "<td><select name=\"project\" ";
903
	echo "<td><select name=\"project\" ";
904
	echo "onChange=\"javascript:MoveTo('istpm.php','$nav')\">\n";
904
	echo "onChange=\"javascript:MoveTo('istpm.php','$nav')\">\n";
905
	echo "<option value=\"0\">" . GetMessage($db, 241, "Alle") . "</option>\n";
905
	echo "<option value=\"0\">" . GetMessage($db, 241, "Alle") . "</option>\n";
906
	$r = 0;
906
	$r = 0;
907
	$flag = false;
907
	$flag = false;
908
 
908
 
909
	while ($r < $rows) {
909
	while ($r < $rows) {
910
	   $data = fetchDB($result, $r);
910
	   $data = fetchDB($result, $r);
911
	   $pr_num = $data[0];
911
	   $pr_num = $data[0];
912
	   $pr_name = $data[1];
912
	   $pr_name = $data[1];
913
	   $plnum = $data[5];
913
	   $plnum = $data[5];
914
	   $pl_lfd = $data[6];
914
	   $pl_lfd = $data[6];
915
	   $pl_status = $data[7];
915
	   $pl_status = $data[7];
916
 
916
 
917
	   if ($pl_status == 6) {
917
	   if ($pl_status == 6) {
918
	      $r++;
918
	      $r++;
919
	      continue;
919
	      continue;
920
	   }
920
	   }
921
 
921
 
922
	   $part = ($pl_status == 0) ? GetMessage($db, 242, "K:") : GetMessage($db, 243, "P:");
922
	   $part = ($pl_status == 0) ? GetMessage($db, 242, "K:") : GetMessage($db, 243, "P:");
923
 
923
 
924
	   if ($pr_num == $project) {
924
	   if ($pr_num == $project) {
925
	      echo "<option value=\"$pr_num\" selected>$part $pr_num $pr_name</option>\n";
925
	      echo "<option value=\"$pr_num\" selected>$part $pr_num $pr_name</option>\n";
926
	      $pl_selnum = $plnum;
926
	      $pl_selnum = $plnum;
927
	      $flag = true;
927
	      $flag = true;
928
	   } else
928
	   } else
929
	      echo "<option value=\"$pr_num\">$part $pr_num $pr_name</option>\n";
929
	      echo "<option value=\"$pr_num\">$part $pr_num $pr_name</option>\n";
930
 
930
 
931
	   $r++;
931
	   $r++;
932
	}
932
	}
933
 
933
 
934
	echo "</select></td></tr>\n";
934
	echo "</select></td></tr>\n";
935
 
935
 
936
	if (!$flag)
936
	if (!$flag)
937
	   $project = 0;
937
	   $project = 0;
938
 
938
 
939
	# optional Mitarbeiter anzeigen
939
	# optional Mitarbeiter anzeigen
940
	if ($rstufe == 1 || $rstufe == 2 || $rstufe == 4) {
940
	if ($rstufe == 1 || $rstufe == 2 || $rstufe == 4) {
941
	   echo "<tr><td>" . GetMessage($db, 244, "Mitarbeiter") . "</td><td><select name=\"mitarbeiter\" ";
941
	   echo "<tr><td>" . GetMessage($db, 244, "Mitarbeiter") . "</td><td><select name=\"mitarbeiter\" ";
942
	   echo "onChange=\"javascript:MoveTo('istpm.php','$nav')\">\n";
942
	   echo "onChange=\"javascript:MoveTo('istpm.php','$nav')\">\n";
943
	   echo "<option value=\"0\">" . GetMessage($db, 241, "Alle") . "</option>\n";
943
	   echo "<option value=\"0\">" . GetMessage($db, 241, "Alle") . "</option>\n";
944
 
944
 
945
	   $r = 0;
945
	   $r = 0;
946
 
946
 
947
	   while ($r < $rows) {
947
	   while ($r < $rows) {
948
	      $data = fetchDB($result, $r);
948
	      $data = fetchDB($result, $r);
949
	      $pr_pl[$r] = $data[2];
949
	      $pr_pl[$r] = $data[2];
950
	      $pl_num[$r] = $data[5];
950
	      $pl_num[$r] = $data[5];
951
	      $pl_status[$r] = $data[7];
951
	      $pl_status[$r] = $data[7];
952
	      $r++;
952
	      $r++;
953
	   }
953
	   }
954
 
954
 
955
	   if (isset($pl_selnum) && $pl_selnum > 0) {
955
	   if (isset($pl_selnum) && $pl_selnum > 0) {
956
	      $query = "select pl_status from plan where pl_num = $pl_selnum";
956
	      $query = "select pl_status from plan where pl_num = $pl_selnum";
957
 
957
 
958
	      if (!($res = QueryDB($db, $query))) {
958
	      if (!($res = QueryDB($db, $query))) {
959
	         closeDB($db);
959
	         closeDB($db);
960
	         return;
960
	         return;
961
	      }
961
	      }
962
 
962
 
963
	      $data = fetchDB($res, 0);
963
	      $data = fetchDB($res, 0);
964
	      $pstat = $data[0];
964
	      $pstat = $data[0];
965
	   } else
965
	   } else
966
	      $pstat = -1;
966
	      $pstat = -1;
967
 
967
 
968
	   if ($pstat != 0) {
968
	   if ($pstat != 0) {
969
	      $query = "select distinct al_ressource, mi_nname,";
969
	      $query = "select distinct al_ressource, mi_nname,";
970
	      $query .= "mi_vname from ";
970
	      $query .= "mi_vname from ";
971
	      $query .= "allocation, task, mitarbeiter where ";
971
	      $query .= "allocation, task, mitarbeiter where ";
972
	      $query .= "ta_num = al_task and mi_num = al_ressource and ";
972
	      $query .= "ta_num = al_task and mi_num = al_ressource and ";
973
	      $query .= "ta_plnum in (";
973
	      $query .= "ta_plnum in (";
974
 
974
 
975
	      if (isset($pl_selnum) && $pl_selnum > 0) {
975
	      if (isset($pl_selnum) && $pl_selnum > 0) {
976
		 $query .= "$pl_selnum";
976
		 $query .= "$pl_selnum";
977
	      } else {
977
	      } else {
978
		 $r = 0;
978
		 $r = 0;
979
		 $flag = false;
979
		 $flag = false;
980
 
980
 
981
		 while ($r < $rows) {
981
		 while ($r < $rows) {
982
		    if ($pl_status[$r] == 6) {
982
		    if ($pl_status[$r] == 6) {
983
		       $r++;
983
		       $r++;
984
		       continue;
984
		       continue;
985
		    }
985
		    }
986
 
986
 
987
		    if ($rstufe == 2 && $pr_pl[$r] != $unum) {
987
		    if ($rstufe == 2 && $pr_pl[$r] != $unum) {
988
		       $r++;
988
		       $r++;
989
		       continue;
989
		       continue;
990
		    }
990
		    }
991
 
991
 
992
		    if ($flag)
992
		    if ($flag)
993
		       $query .= "," . $pl_num[$r];
993
		       $query .= "," . $pl_num[$r];
994
		    else
994
		    else
995
		       $query .= $pl_num[$r];
995
		       $query .= $pl_num[$r];
996
 
996
 
997
		    $flag = true;
997
		    $flag = true;
998
		    $r++;
998
		    $r++;
999
		 }
999
		 }
1000
	      }
1000
	      }
1001
 
1001
 
1002
	      $query .= ") order by mi_nname, mi_vname";
1002
	      $query .= ") order by mi_nname, mi_vname";
1003
	   } else {
1003
	   } else {
1004
	      $query = "select mi_num, mi_nname, mi_vname from mitarbeiter ";
1004
	      $query = "select mi_num, mi_nname, mi_vname from mitarbeiter ";
1005
	      $query .= "where mi_plan = true order by mi_nname, mi_vname";
1005
	      $query .= "where mi_plan = true order by mi_nname, mi_vname";
1006
	   }
1006
	   }
1007
 
1007
 
1008
	   if (!($resmi = QueryDB($db, $query))) {
1008
	   if (!($resmi = QueryDB($db, $query))) {
1009
	      closeDB($db);
1009
	      closeDB($db);
1010
	      return;
1010
	      return;
1011
	   }
1011
	   }
1012
 
1012
 
1013
	   $nr = numrowsDB($resmi);
1013
	   $nr = numrowsDB($resmi);
1014
	   $r = 0;
1014
	   $r = 0;
1015
	   $flag = false;
1015
	   $flag = false;
1016
 
1016
 
1017
	   while ($r < $nr) {
1017
	   while ($r < $nr) {
1018
	      $data = fetchDB($resmi, $r);
1018
	      $data = fetchDB($resmi, $r);
1019
	      $al_ressource = $data[0];
1019
	      $al_ressource = $data[0];
1020
	      $mi_nname = $data[1];
1020
	      $mi_nname = $data[1];
1021
	      $mi_vname = $data[2];
1021
	      $mi_vname = $data[2];
1022
 
1022
 
1023
	      if ($al_ressource == $mitarbeiter) {
1023
	      if ($al_ressource == $mitarbeiter) {
1024
	         echo "<option value=\"$al_ressource\" selected>$mi_nname $mi_vname</option>\n";
1024
	         echo "<option value=\"$al_ressource\" selected>$mi_nname $mi_vname</option>\n";
1025
	         $flag = true;
1025
	         $flag = true;
1026
	      } else
1026
	      } else
1027
	         echo "<option value=\"$al_ressource\">$mi_nname $mi_vname</option>\n";
1027
	         echo "<option value=\"$al_ressource\">$mi_nname $mi_vname</option>\n";
1028
 
1028
 
1029
	      $r++;
1029
	      $r++;
1030
	   }
1030
	   }
1031
 
1031
 
1032
	   echo "</select></td></tr>\n";
1032
	   echo "</select></td></tr>\n";
1033
 
1033
 
1034
	   if (!$flag)
1034
	   if (!$flag)
1035
	      $mitarbeiter = 0;
1035
	      $mitarbeiter = 0;
1036
	}
1036
	}
1037
 
1037
 
1038
	# Zeitraum von anzeigen
1038
	# Zeitraum von anzeigen
1039
	$vd = GetVisualDate($dtformatshort, true);
1039
	$vd = GetVisualDate($dtformatshort, true);
1040
	echo "<tr><td>" . GetMessage($db, 245, "Zeitraum von") . " ($vd):</td>\n";
1040
	echo "<tr><td>" . GetMessage($db, 245, "Zeitraum von") . " ($vd):</td>\n";
1041
 
1041
 
1042
	if (isset($von) && strlen($von) >= 4) {
1042
	if (isset($von) && strlen($von) >= 4) {
1043
	   $sd = explode(GetDateSep(), $von);
1043
	   $sd = explode(GetDateSep(), $von);
1044
	   $dat = gmmktime(0, 0, 0, $sd[0], 1, $sd[1]);
1044
	   $dat = gmmktime(0, 0, 0, $sd[0], 1, $sd[1]);
1045
	   unset($sd);
1045
	   unset($sd);
1046
	} else {
1046
	} else {
1047
	   $dat = time();
1047
	   $dat = time();
1048
	   $day = gmdate("j", $dat);
1048
	   $day = gmdate("j", $dat);
1049
	   $mon = gmdate("n", $dat);
1049
	   $mon = gmdate("n", $dat);
1050
	   $year = gmdate("Y", $dat);
1050
	   $year = gmdate("Y", $dat);
1051
 
1051
 
1052
	   if ($day > (daysinmonth($mon, $year) / 2)) {
1052
	   if ($day > (daysinmonth($mon, $year) / 2)) {
1053
	      $mon++;
1053
	      $mon++;
1054
 
1054
 
1055
	      if ($mon > 12) {
1055
	      if ($mon > 12) {
1056
		 $mon = 1;
1056
		 $mon = 1;
1057
		 $year++;
1057
		 $year++;
1058
	      }
1058
	      }
1059
	   }
1059
	   }
1060
 
1060
 
1061
	   if ($mon <= 3) {
1061
	   if ($mon <= 3) {
1062
	      $mon = 12 - (3 - $mon) + 1;
1062
	      $mon = 12 - (3 - $mon) + 1;
1063
 
1063
 
1064
	      if ($mon == 13)
1064
	      if ($mon == 13)
1065
	         $mon = 1;
1065
	         $mon = 1;
1066
	      else
1066
	      else
1067
	         $year--;
1067
	         $year--;
1068
	   } else
1068
	   } else
1069
	      $mon -= 2;
1069
	      $mon -= 2;
1070
 
1070
 
1071
	   $dat = gmmktime(0, 0, 0, $mon, 1, $year);
1071
	   $dat = gmmktime(0, 0, 0, $mon, 1, $year);
1072
	}
1072
	}
1073
 
1073
 
1074
	$mon = gmdate("n", $dat);
1074
	$mon = gmdate("n", $dat);
1075
	$year = gmdate("Y", $dat);
1075
	$year = gmdate("Y", $dat);
1076
	$day = gmdate("j", $dat);
1076
	$day = gmdate("j", $dat);
1077
 
1077
 
1078
	$dvon = gmmktime(0, 0, 0, $mon, $day, $year);
1078
	$dvon = gmmktime(0, 0, 0, $mon, $day, $year);
1079
//	$anz = ($pmlight)? 3 : 7;
1079
//	$anz = ($pmlight)? 3 : 7;
1080
	echo "<td><table border=0 cellpadding=0><tr><td><input type=\"text\" name=\"von\" value=\"";
1080
	echo "<td><table border=0 cellpadding=0><tr><td><input type=\"text\" name=\"von\" value=\"";
1081
 
1081
 
1082
	$vd = GetShortDate($dvon);
1082
	$vd = GetShortDate($dvon);
1083
	echo "$vd\" size=7 maxlength=7 onBlur=\"javascript:CheckDate(this,1)\">";
1083
	echo "$vd\" size=7 maxlength=7 onBlur=\"javascript:CheckDate(this,1)\">";
1084
	$dfrom = $dvon;
1084
	$dfrom = $dvon;
1085
 
1085
 
1086
	# Zeitraum bis anzeigen
1086
	# Zeitraum bis anzeigen
1087
	if (isset($bis) && strlen($bis) >= 4) {
1087
	if (isset($bis) && strlen($bis) >= 4) {
1088
	   $sd = explode(GetDateSep(), $bis);
1088
	   $sd = explode(GetDateSep(), $bis);
1089
	   $dat = gmmktime(0, 0, 0, $sd[0], daysinmonth($sd[0], $sd[1]), $sd[1]);
1089
	   $dat = gmmktime(0, 0, 0, $sd[0], daysinmonth($sd[0], $sd[1]), $sd[1]);
1090
	   unset($sd);
1090
	   unset($sd);
1091
	} else {
1091
	} else {
1092
	   $mon = gmdate("n");
1092
	   $mon = gmdate("n");
1093
	   $year = gmdate("Y");
1093
	   $year = gmdate("Y");
1094
	   $aday = gmdate("j");
1094
	   $aday = gmdate("j");
1095
	   $day = daysinmonth($mon, $year);
1095
	   $day = daysinmonth($mon, $year);
1096
 
1096
 
1097
	   if ($aday > ($day / 2)) {
1097
	   if ($aday > ($day / 2)) {
1098
	      $mon++;
1098
	      $mon++;
1099
 
1099
 
1100
	      if ($mon > 12) {
1100
	      if ($mon > 12) {
1101
		 $mon = 1;
1101
		 $mon = 1;
1102
		 $year++;
1102
		 $year++;
1103
	      }
1103
	      }
1104
	   }
1104
	   }
1105
 
1105
 
1106
	   $dat = gmmktime(0, 0, 0, $mon, $day, $year) - 1;
1106
	   $dat = gmmktime(0, 0, 0, $mon, $day, $year) - 1;
1107
	}
1107
	}
1108
 
1108
 
1109
	$mon = gmdate("n", $dat);
1109
	$mon = gmdate("n", $dat);
1110
	$year = gmdate("Y", $dat);
1110
	$year = gmdate("Y", $dat);
1111
	$day = gmdate("j", $dat);
1111
	$day = gmdate("j", $dat);
1112
	$dbis = gmmktime(0, 0, 0, $mon, $day, $year);
1112
	$dbis = gmmktime(0, 0, 0, $mon, $day, $year);
1113
	echo " " . GetMessage($db, 246, "Bis:") . " <input type=\"text\" name=\"bis\" value=\"";
1113
	echo " " . GetMessage($db, 246, "Bis:") . " <input type=\"text\" name=\"bis\" value=\"";
1114
 
1114
 
1115
	$vd = GetShortDate($dbis);
1115
	$vd = GetShortDate($dbis);
1116
	echo "$vd\" size=7 maxlength=7 onBlur=\"javascript:CheckDate(this,1)\"></td>\n";
1116
	echo "$vd\" size=7 maxlength=7 onBlur=\"javascript:CheckDate(this,1)\"></td>\n";
1117
	$dto = $dbis;
1117
	$dto = $dbis;
1118
 
1118
 
1119
	echo "<td>";
1119
	echo "<td>";
1120
	ButtonImageMove("left.png", GetMessage($db, 247, "Woche zurück"), "istpm.php", "func=PrevWeek&$nav");
1120
	ButtonImageMove("left.png", GetMessage($db, 247, "Woche zur�ck"), "istpm.php", "func=PrevWeek&$nav");
1121
	echo "</td><td>";
1121
	echo "</td><td>";
1122
	ButtonImageMove("right.png", GetMessage($db, 248, "Woche vor"), "istpm.php", "func=NextWeek&$nav");
1122
	ButtonImageMove("right.png", GetMessage($db, 248, "Woche vor"), "istpm.php", "func=NextWeek&$nav");
1123
	echo "</td><td>";
1123
	echo "</td><td>";
1124
	ButtonImageMove("today.png", GetMessage($db, 249, "Heute"), "istpm.php", "func=Today&$nav");
1124
	ButtonImageMove("today.png", GetMessage($db, 249, "Heute"), "istpm.php", "func=Today&$nav");
1125
	echo "</td><td>";
1125
	echo "</td><td>";
1126
	ButtonLink(GetMessage($db, 250, "Zeitraum setzen"), "istpm.php","$nav");
1126
	ButtonLink(GetMessage($db, 250, "Zeitraum setzen"), "istpm.php","$nav");
1127
	echo "</td></tr></table></td></tr></table>\n";
1127
	echo "</td></tr></table></td></tr></table>\n";
1128
	# Ende der linken Spalte.
1128
	# Ende der linken Spalte.
1129
	echo "</td>\n";
1129
	echo "</td>\n";
1130
	# Textmitteilungen in der rechten Spalte:
1130
	# Textmitteilungen in der rechten Spalte:
1131
	echo "<td align=\"center\" valign=\"middle\"><div id=\"message\">\n";
1131
	echo "<td align=\"center\" valign=\"middle\"><div id=\"message\">\n";
1132
	echo "<table border=0 cellspacing=0 cellpadding=0><tr><td>";
1132
	echo "<table border=0 cellspacing=0 cellpadding=0><tr><td>";
1133
	echo "<img src=\"image/exclamation.jpeg\" alt=\"Exclamation mark\" width=30 height=30></td><td>";
1133
	echo "<img src=\"image/exclamation.jpeg\" alt=\"Exclamation mark\" width=30 height=30></td><td>";
1134
	Output($db, 376, "Bitte speichern Sie die ver&auml;nderten Daten!");
1134
	Output($db, 376, "Bitte speichern Sie die ver&auml;nderten Daten!");
1135
	echo "</td></tr></table>";
1135
	echo "</td></tr></table>";
1136
	# Ende der rechten Spalte und der Kopftabelle:
1136
	# Ende der rechten Spalte und der Kopftabelle:
1137
	echo "</div></td></tr></table>\n";
1137
	echo "</div></td></tr></table>\n";
1138
 
1138
 
1139
	# Aufbau der Tabelle zur IST-Erfassung
1139
	# Aufbau der Tabelle zur IST-Erfassung
1140
	#
1140
	#
1141
	# Tabellenkopf
1141
	# Tabellenkopf
1142
	echo "<table class=\"sel\"><tr>\n";
1142
	echo "<table class=\"sel\"><tr>\n";
1143
	echo "<th class=\"sel\" colspan=4></td>\n";
1143
	echo "<th class=\"sel\" colspan=4></td>\n";
1144
	# Button zum Senden / Rueckgaengig machen
1144
	# Button zum Senden / Rueckgaengig machen
1145
	echo "<table border=0 cellpadding=0 cellspacing=0><tr><td>\n";
1145
	echo "<table border=0 cellpadding=0 cellspacing=0><tr><td>\n";
1146
	Button(GetMessage($db, 177, "Speichern"), "ist");
1146
	Button(GetMessage($db, 177, "Speichern"), "ist");
1147
	echo "</td><td>";
1147
	echo "</td><td>";
1148
	ButtonProg(GetMessage($db, 251, "Zur&uuml;cksetzen"), "if (!DocChanged) document.getElementById('message').style.visibility = 'hidden'; document.ist.reset()");
1148
	ButtonProg(GetMessage($db, 251, "Zur&uuml;cksetzen"), "if (!DocChanged) document.getElementById('message').style.visibility = 'hidden'; document.ist.reset()");
1149
	echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
1149
	echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
1150
 
1150
 
1151
	if ($pl_selnum > 0 && $mitarbeiter == 0)
1151
	if ($pl_selnum > 0 && $mitarbeiter == 0)
1152
	   $sort = 1;		// Projektsicht
1152
	   $sort = 1;		// Projektsicht
1153
	else
1153
	else
1154
	   $sort = 2;		// Mitarbeitersicht
1154
	   $sort = 2;		// Mitarbeitersicht
1155
 
1155
 
1156
	$pr_nav = "menu=$menu&headline=$headline&func=pauswertung&";
1156
	$pr_nav = "menu=$menu&headline=$headline&func=pauswertung&";
1157
	$pr_nav .= "pjclosed=1&pl_num=$pl_selnum&mi_num=$mitarbeiter&dfrom=$dfrom&dto=$dto&";
1157
	$pr_nav .= "pjclosed=1&pl_num=$pl_selnum&mi_num=$mitarbeiter&dfrom=$dfrom&dto=$dto&";
1158
	$pr_nav .= "fields_0=1&fields_4=5&fields_5=6&sort=$sort&header=2";
1158
	$pr_nav .= "fields_0=1&fields_4=5&fields_5=6&sort=$sort&header=2";
1159
	ButtonPrint(GetMessage($db, 383, "Drucken"), "auswertpdf.php", $pr_nav, true);
1159
	ButtonPrint(GetMessage($db, 383, "Drucken"), "auswertpdf.php", $pr_nav, true);
1160
	echo "</td></tr></table>\n";
1160
	echo "</td></tr></table>\n";
1161
	echo "</th>\n";
1161
	echo "</th>\n";
1162
 
1162
 
1163
	# Ermitteln des gewuenschten Zeitraums
1163
	# Ermitteln des gewuenschten Zeitraums
1164
	$anz = GetAnzEntries($dvon, $dbis);
1164
	$anz = GetAnzEntries($dvon, $dbis);
1165
 
1165
 
1166
	if ($anz > 1)
1166
	if ($anz > 1)
1167
	   echo "<th class=\"sel\" colspan=$anz>";
1167
	   echo "<th class=\"sel\" colspan=$anz>";
1168
	else
1168
	else
1169
	   echo "<th class=\"sel\">";
1169
	   echo "<th class=\"sel\">";
1170
 
1170
 
1171
	echo GetMessage($db, 252, "PT pro Periode") . "</th>\n";
1171
	echo GetMessage($db, 252, "PT pro Periode") . "</th>\n";
1172
	echo "<th class=\"sel\" colspan=2>" . GetMessage($db, 253, "Summe&nbsp;Zeile") . "</th>\n";
1172
	echo "<th class=\"sel\" colspan=2>" . GetMessage($db, 253, "Summe&nbsp;Zeile") . "</th>\n";
1173
 
1173
 
1174
	if ($ist_erledigung)
1174
	if ($ist_erledigung)
1175
	   echo "<th class=\"sel\" colspan=3>" . GetMessage($db, 254, "Summe&nbsp;(PT)/Task") . "</th></tr>\n";
1175
	   echo "<th class=\"sel\" colspan=3>" . GetMessage($db, 254, "Summe&nbsp;(PT)/Task") . "</th></tr>\n";
1176
	else
1176
	else
1177
	   echo "<th class=\"sel\" colspan=2>" . GetMessage($db, 254, "Summe&nbsp;(PT)/Task") . "</th></tr>\n";
1177
	   echo "<th class=\"sel\" colspan=2>" . GetMessage($db, 254, "Summe&nbsp;(PT)/Task") . "</th></tr>\n";
1178
 
1178
 
1179
	echo "<tr><th class=\"sel\">" . GetMessage($db, 255, "Projekt&nbsp;/&nbsp;Task") . "</th>\n";
1179
	echo "<tr><th class=\"sel\">" . GetMessage($db, 255, "Projekt&nbsp;/&nbsp;Task") . "</th>\n";
1180
	echo "<th class=\"sel\">" . GetMessage($db, 256, "PlNr./Status") . "</th>\n";
1180
	echo "<th class=\"sel\">" . GetMessage($db, 256, "PlNr./Status") . "</th>\n";
1181
 
1181
 
1182
//	if ($rstufe != 3 && isset($mitarbeiter) && $mitarbeiter == 0)
1182
//	if ($rstufe != 3 && isset($mitarbeiter) && $mitarbeiter == 0)
1183
	if ($rstufe != 3)
1183
	if ($rstufe != 3)
1184
	   echo "<th class=\"sel\">" . GetMessage($db, 257, "PL&nbsp;/&nbsp;Mitarbeiter") . "</th>\n";
1184
	   echo "<th class=\"sel\">" . GetMessage($db, 257, "PL&nbsp;/&nbsp;Mitarbeiter") . "</th>\n";
1185
	else
1185
	else
1186
	   echo "<th class=\"sel\">" . GetMessage($db, 258, "Projektleiter") . "</th>\n";
1186
	   echo "<th class=\"sel\">" . GetMessage($db, 258, "Projektleiter") . "</th>\n";
1187
 
1187
 
1188
	echo "<th class=\"sel\"></th>\n";
1188
	echo "<th class=\"sel\"></th>\n";
1189
	$r = 0;
1189
	$r = 0;
1190
	$dt = $dvon;
1190
	$dt = $dvon;
1191
 
1191
 
1192
	while ($r < $anz) {
1192
	while ($r < $anz) {
1193
	   $datum = GetShortDate($dt);
1193
	   $datum = GetShortDate($dt);
1194
	   $dt = IncDate($periode, $dt);
1194
	   $dt = IncDate($periode, $dt);
1195
	   echo "<th class=\"sel\">$datum</th>\n";
1195
	   echo "<th class=\"sel\">$datum</th>\n";
1196
	   $r++;
1196
	   $r++;
1197
	}
1197
	}
1198
 
1198
 
1199
	echo "<th class=\"sel\">" . GetMessage($db, 259, "Plan") . "</th>\n";
1199
	echo "<th class=\"sel\">" . GetMessage($db, 259, "Plan") . "</th>\n";
1200
	echo "<th class=\"sel\">" . GetMessage($db, 260, "IST") . "</th>\n";
1200
	echo "<th class=\"sel\">" . GetMessage($db, 260, "IST") . "</th>\n";
1201
	echo "<th class=\"sel\">" . GetMessage($db, 259, "Plan") . "</th>\n";
1201
	echo "<th class=\"sel\">" . GetMessage($db, 259, "Plan") . "</th>\n";
1202
	echo "<th class=\"sel\">" . GetMessage($db, 260, "IST") . "</th>\n";
1202
	echo "<th class=\"sel\">" . GetMessage($db, 260, "IST") . "</th>\n";
1203
 
1203
 
1204
	if ($ist_erledigung)
1204
	if ($ist_erledigung)
1205
	   echo "<th class=\"sel\">" . GetMessage($db, 261, "Erl.") . "</th>\n";
1205
	   echo "<th class=\"sel\">" . GetMessage($db, 261, "Erl.") . "</th>\n";
1206
 
1206
 
1207
	echo "</tr>\n";
1207
	echo "</tr>\n";
1208
	# Tabelle mit Inhalten fuellen...
1208
	# Tabelle mit Inhalten fuellen...
1209
	$r = 0;
1209
	$r = 0;
1210
 
1210
 
1211
	while ($r < $rows) {
1211
	while ($r < $rows) {
1212
	   $data = fetchDB($result, $r);
1212
	   $data = fetchDB($result, $r);
1213
	   $pr_num = $data[0];
1213
	   $pr_num = $data[0];
1214
	   $pr_name = $data[1];
1214
	   $pr_name = $data[1];
1215
	   $pr_pl = $data[2];
1215
	   $pr_pl = $data[2];
1216
	   $mi_nname = $data[3];
1216
	   $mi_nname = $data[3];
1217
	   $mi_vname = $data[4];
1217
	   $mi_vname = $data[4];
1218
	   $pl_num = $data[5];
1218
	   $pl_num = $data[5];
1219
	   $pl_lfd = $data[6];
1219
	   $pl_lfd = $data[6];
1220
	   $pl_status = $data[7];
1220
	   $pl_status = $data[7];
1221
 
1221
 
1222
	   if ($pl_status == 1) {
1222
	   if ($pl_status == 1) {
1223
	      $r++;
1223
	      $r++;
1224
	      continue;
1224
	      continue;
1225
	   }
1225
	   }
1226
 
1226
 
1227
	   # Wenn ein bestimmtes Projekt gewaehlt wurde, nur dieses anzeigen.
1227
	   # Wenn ein bestimmtes Projekt gewaehlt wurde, nur dieses anzeigen.
1228
	   if (isset($project) && $project > 0 && $pr_num != $project) {
1228
	   if (isset($project) && $project > 0 && $pr_num != $project) {
1229
	      $r++;
1229
	      $r++;
1230
	      continue;
1230
	      continue;
1231
	   }
1231
	   }
1232
 
1232
 
1233
	   # Wenn der angemeldete User PL ist ($rstufe == 2) und ein bestimmter
1233
	   # Wenn der angemeldete User PL ist ($rstufe == 2) und ein bestimmter
1234
	   # Mitarbeiter ausgewaehlt wurde, dann duerfen nur mehr die Projekte
1234
	   # Mitarbeiter ausgewaehlt wurde, dann duerfen nur mehr die Projekte
1235
	   # des PL angezeigt werden!
1235
	   # des PL angezeigt werden!
1236
	   if ($rstufe == 2 && $mitarbeiter != $unum && $mitarbeiter > 0 && $pr_pl != $unum && $pl_status != 0) {
1236
	   if ($rstufe == 2 && $mitarbeiter != $unum && $mitarbeiter > 0 && $pr_pl != $unum && $pl_status != 0) {
1237
	      $r++;
1237
	      $r++;
1238
	      continue;
1238
	      continue;
1239
	   }
1239
	   }
1240
 
1240
 
1241
	   # Pruefen, ob es fuer das aktuelle Projekt auch Tasks zum Anzeigen
1241
	   # Pruefen, ob es fuer das aktuelle Projekt auch Tasks zum Anzeigen
1242
	   # gibt. Falls nicht, untersuchen wir das naechste Projekt.
1242
	   # gibt. Falls nicht, untersuchen wir das naechste Projekt.
1243
	   if ($pl_status > 0) {
1243
	   if ($pl_status > 0) {
1244
	      $query = "select count(*) from task, plan, allocation where ";
1244
	      $query = "select count(*) from task, plan, allocation where ";
1245
	      $query .= "pl_num = ta_plnum and al_task = ta_num and ";
1245
	      $query .= "pl_num = ta_plnum and al_task = ta_num and ";
1246
 
1246
 
1247
	      if (!$ist_future) {
1247
	      if (!$ist_future) {
1248
	         $query .= "ta_start <= $dbis and ";
1248
	         $query .= "ta_start <= $dbis and ";
1249
	      } else {
1249
	      } else {
1250
	         $query .= "(ta_start between $dvon and $dbis or ";
1250
	         $query .= "(ta_start between $dvon and $dbis or ";
1251
	         $query .= "ta_start+ta_duration*86400 between $dvon and $dbis or ";
1251
	         $query .= "ta_start+ta_duration::int8*86400 between $dvon and $dbis or ";
1252
	         $query .= "$dvon between ta_start and ta_start+ta_duration*86400 or ";
1252
	         $query .= "$dvon between ta_start and ta_start+ta_duration::int8*86400 or ";
1253
	         $query .= "$dbis between ta_start and ta_start+ta_duration*86400) and ";
1253
	         $query .= "$dbis between ta_start and ta_start+ta_duration::int8*86400) and ";
1254
	      }
1254
	      }
1255
 
1255
 
1256
	      $query .= "(ta_plnum = $pl_num or ta_plnum in (";
1256
	      $query .= "(ta_plnum = $pl_num or ta_plnum in (";
1257
	      $query .= "select distinct pl_num from wdone, plan, task where ";
1257
	      $query .= "select distinct pl_num from wdone, plan, task where ";
1258
	      $query .= "ta_num = wd_task and pl_num = ta_plnum and ";
1258
	      $query .= "ta_num = wd_task and pl_num = ta_plnum and ";
1259
	      $query .= "wd_prnum = $pr_num and ";
1259
	      $query .= "wd_prnum = $pr_num and ";
1260
 
1260
 
1261
	      if ($rstufe == 3 || ($rstufe == 2 && $mitarbeiter == 0 && $pr_pl != $unum))
1261
	      if ($rstufe == 3 || ($rstufe == 2 && $mitarbeiter == 0 && $pr_pl != $unum))
1262
	         $query .= "wd_minum = $unum and ";
1262
	         $query .= "wd_minum = $unum and ";
1263
	      else
1263
	      else
1264
	         $query .= "wd_minum = $mitarbeiter and ";
1264
	         $query .= "wd_minum = $mitarbeiter and ";
1265
 
1265
 
1266
	      $query .= "wd_datum between $dvon and $dbis and ";
1266
	      $query .= "wd_datum between $dvon and $dbis and ";
1267
	      $query .= "pl_status in (2,3,4,5,6))) and ";
1267
	      $query .= "pl_status in (2,3,4,5,6))) and ";
1268
	      $query .= "pl_prnum = $pr_num ";
1268
	      $query .= "pl_prnum = $pr_num ";
1269
 
1269
 
1270
	      if ($rstufe == 3 || ($rstufe == 2 && $mitarbeiter == 0 && $pr_pl != $unum))
1270
	      if ($rstufe == 3 || ($rstufe == 2 && $mitarbeiter == 0 && $pr_pl != $unum))
1271
	         $query .= " and al_ressource = $unum";
1271
	         $query .= " and al_ressource = $unum";
1272
	      else if (isset($mitarbeiter) && $mitarbeiter > 0)
1272
	      else if (isset($mitarbeiter) && $mitarbeiter > 0)
1273
	         $query .= " and al_ressource = $mitarbeiter";
1273
	         $query .= " and al_ressource = $mitarbeiter";
1274
 
1274
 
1275
	      if (!($resta = QueryDB($db, $query))) {
1275
	      if (!($resta = QueryDB($db, $query))) {
1276
	         closeDB($db);
1276
	         closeDB($db);
1277
	         return;
1277
	         return;
1278
	      }
1278
	      }
1279
 
1279
 
1280
	      $data = fetchDB($resta, 0);
1280
	      $data = fetchDB($resta, 0);
1281
 
1281
 
1282
	      if ($data[0] == 0) {
1282
	      if ($data[0] == 0) {
1283
	         $r++;
1283
	         $r++;
1284
	         continue;
1284
	         continue;
1285
	      }
1285
	      }
1286
	   }
1286
	   }
1287
 
1287
 
1288
	   echo "<tr><td class=\"selakt\">$pr_num&nbsp;$pr_name</td>\n";
1288
	   echo "<tr><td class=\"selakt\">$pr_num&nbsp;$pr_name</td>\n";
1289
 
1289
 
1290
	   if ($pl_status > 0) {
1290
	   if ($pl_status > 0) {
1291
	      echo "<td class=\"selakt\">" . GetMessage($db, 262, "Projekt") . "</td>\n";
1291
	      echo "<td class=\"selakt\">" . GetMessage($db, 262, "Projekt") . "</td>\n";
1292
	      echo "<td class=\"selakt\">$mi_nname&nbsp;$mi_vname</td>\n";
1292
	      echo "<td class=\"selakt\">$mi_nname&nbsp;$mi_vname</td>\n";
1293
	   } else {
1293
	   } else {
1294
	      echo "<td class=\"selakt\"><i>" . GetMessage($db, 234, "Konto") . "</i></td>\n";
1294
	      echo "<td class=\"selakt\"><i>" . GetMessage($db, 234, "Konto") . "</i></td>\n";
1295
	      echo "<td class=\"selakt\">$mi_nname&nbsp;$mi_vname</td>\n";
1295
	      echo "<td class=\"selakt\">$mi_nname&nbsp;$mi_vname</td>\n";
1296
//	      echo "<td class=\"selakt\">&nbsp;</td>\n";
1296
//	      echo "<td class=\"selakt\">&nbsp;</td>\n";
1297
	   }
1297
	   }
1298
 
1298
 
1299
	   echo "<td class=\"selakt\"></td>\n";
1299
	   echo "<td class=\"selakt\"></td>\n";
1300
	   echo "<td class=\"selakt\" colspan=$anz></td>\n";
1300
	   echo "<td class=\"selakt\" colspan=$anz></td>\n";
1301
	   echo "<td class=\"selakt\" colspan=5></td></tr>\n";
1301
	   echo "<td class=\"selakt\" colspan=5></td></tr>\n";
1302
	   # Abhaengig von der Rolle des angemeldeten Users, werden alle
1302
	   # Abhaengig von der Rolle des angemeldeten Users, werden alle
1303
	   # Tasks pro Mitarbeiter angezeigt.
1303
	   # Tasks pro Mitarbeiter angezeigt.
1304
	   #
1304
	   #
1305
	   # Auch bei Konten duerfen Projektleiter nur sich selbst eintragen
1305
	   # Auch bei Konten duerfen Projektleiter nur sich selbst eintragen
1306
	   # duerfen.
1306
	   # duerfen.
1307
	   #
1307
	   #
1308
	   if ($rstufe == 3 || ($rstufe == 2 && $pl_status == 0)) { 		// Mitarbeiter
1308
	   if ($rstufe == 3 || ($rstufe == 2 && $pl_status == 0)) { 		// Mitarbeiter
1309
	      if ($rstufe == 2)
1309
	      if ($rstufe == 2)
1310
		 $mi_flag = true;
1310
		 $mi_flag = true;
1311
	      else
1311
	      else
1312
		 $mi_flag = false;
1312
		 $mi_flag = false;
1313
 
1313
 
1314
	      if (!ShowMitarbeiter($db, $unum, $anz, $dvon, $dbis, $pr_num, $pl_num, $mi_flag)) {
1314
	      if (!ShowMitarbeiter($db, $unum, $anz, $dvon, $dbis, $pr_num, $pl_num, $mi_flag)) {
1315
	         closeDB($db);
1315
	         closeDB($db);
1316
	         return;
1316
	         return;
1317
	      }
1317
	      }
1318
	   } else if (isset($mitarbeiter) && $mitarbeiter > 0) {
1318
	   } else if (isset($mitarbeiter) && $mitarbeiter > 0) {
1319
	      if ($rstufe == 2)
1319
	      if ($rstufe == 2)
1320
		 $mi_flag = true;
1320
		 $mi_flag = true;
1321
	      else
1321
	      else
1322
		 $mi_flag = false;
1322
		 $mi_flag = false;
1323
 
1323
 
1324
	      if (!ShowMitarbeiter($db, $mitarbeiter, $anz, $dvon, $dbis, $pr_num, $pl_num, $mi_flag)) {
1324
	      if (!ShowMitarbeiter($db, $mitarbeiter, $anz, $dvon, $dbis, $pr_num, $pl_num, $mi_flag)) {
1325
		 closeDB($db);
1325
		 closeDB($db);
1326
		 return;
1326
		 return;
1327
	      }
1327
	      }
1328
	   } else {
1328
	   } else {
1329
	      if ($pl_status > 0) {
1329
	      if ($pl_status > 0) {
1330
		 $query = "select distinct on (al_ressource) al_ressource, mi_nname, mi_vname, pl_lfd ";
1330
		 $query = "select distinct on (al_ressource) al_ressource, mi_nname, mi_vname, pl_lfd ";
1331
		 $query .= "from allocation ";
1331
		 $query .= "from allocation ";
1332
		 $query .= "left join mitarbeiter on mi_num = al_ressource ";
1332
		 $query .= "left join mitarbeiter on mi_num = al_ressource ";
1333
		 $query .= "left join task on ta_num = al_task and ";
1333
		 $query .= "left join task on ta_num = al_task and ";
1334
 
1334
 
1335
		 if (!$ist_future) {
1335
		 if (!$ist_future) {
1336
		    $query .= "ta_start <= $dbis ";
1336
		    $query .= "ta_start <= $dbis ";
1337
		 } else {
1337
		 } else {
1338
		    $query .= "(ta_start between $dvon and $dbis or ";
1338
		    $query .= "(ta_start between $dvon and $dbis or ";
1339
		    $query .= "ta_start+ta_duration*86400 between $dvon and $dbis or ";
1339
		    $query .= "ta_start+ta_duration::int8*86400 between $dvon and $dbis or ";
1340
		    $query .= "$dvon between ta_start and ta_start+ta_duration*86400 or ";
1340
		    $query .= "$dvon between ta_start and ta_start+ta_duration::int8*86400 or ";
1341
		    $query .= "$dbis between ta_start and ta_start+ta_duration*86400) ";
1341
		    $query .= "$dbis between ta_start and ta_start+ta_duration::int8*86400) ";
1342
		 }
1342
		 }
1343
 
1343
 
1344
		 $query .= "inner join plan on pl_num = ta_plnum and pl_prnum = $pr_num and pl_status in (2,3,4,5,6) ";
1344
		 $query .= "inner join plan on pl_num = ta_plnum and pl_prnum = $pr_num and pl_status in (2,3,4,5,6) ";
1345
		 $query .= "order by al_ressource, pl_lfd desc, mi_nname, mi_vname";
1345
		 $query .= "order by al_ressource, pl_lfd desc, mi_nname, mi_vname";
1346
	      } else {
1346
	      } else {
1347
		 $query = "select mi_num, mi_nname, mi_vname from mitarbeiter ";
1347
		 $query = "select mi_num, mi_nname, mi_vname from mitarbeiter ";
1348
		 $query .= "where mi_plan = true order by mi_nname, mi_vname";
1348
		 $query .= "where mi_plan = true order by mi_nname, mi_vname";
1349
	      }
1349
	      }
1350
 
1350
 
1351
	      if (!($resal = QueryDB($db, $query))) {
1351
	      if (!($resal = QueryDB($db, $query))) {
1352
		 closeDB($db);
1352
		 closeDB($db);
1353
		 return;
1353
		 return;
1354
	      }
1354
	      }
1355
 
1355
 
1356
	      $cnt = numrowsDB($resal);
1356
	      $cnt = numrowsDB($resal);
1357
	      $z = 0;
1357
	      $z = 0;
1358
 
1358
 
1359
	      while ($z < $cnt) {
1359
	      while ($z < $cnt) {
1360
		 $data = fetchDB($resal, $z);
1360
		 $data = fetchDB($resal, $z);
1361
		 $al_ressource = $data[0];
1361
		 $al_ressource = $data[0];
1362
 
1362
 
1363
		 # In Projekten in denen der User kein PL ist, darf er nur sich
1363
		 # In Projekten in denen der User kein PL ist, darf er nur sich
1364
		 # selbst editieren!
1364
		 # selbst editieren!
1365
		 #
1365
		 #
1366
		 if ($rstufe == 2 && $pr_pl != $unum && $al_ressource != $unum) {
1366
		 if ($rstufe == 2 && $pr_pl != $unum && $al_ressource != $unum) {
1367
		    $z++;
1367
		    $z++;
1368
		    continue;
1368
		    continue;
1369
		 }
1369
		 }
1370
 
1370
 
1371
		 if (!ShowMitarbeiter($db, $al_ressource, $anz, $dvon, $dbis, $pr_num, $pl_num)) {
1371
		 if (!ShowMitarbeiter($db, $al_ressource, $anz, $dvon, $dbis, $pr_num, $pl_num)) {
1372
		    closeDB($db);
1372
		    closeDB($db);
1373
		    return;
1373
		    return;
1374
		 }
1374
		 }
1375
 
1375
 
1376
	         $z++;
1376
	         $z++;
1377
	      }
1377
	      }
1378
	   }
1378
	   }
1379
 
1379
 
1380
	   $r++;
1380
	   $r++;
1381
	}
1381
	}
1382
 
1382
 
1383
	# Endsummen schreiben
1383
	# Endsummen schreiben
1384
	echo "<tr><td class=\"selnum\" colspan=4>" . GetMessage($db, 263, "Summen Plan:") . "<br>";
1384
	echo "<tr><td class=\"selnum\" colspan=4>" . GetMessage($db, 263, "Summen Plan:") . "<br>";
1385
	echo GetMessage($db, 264, "Summen IST:") . "</td>\n";
1385
	echo GetMessage($db, 264, "Summen IST:") . "</td>\n";
1386
	$z = 0;
1386
	$z = 0;
1387
	$sumptot = 0.0;
1387
	$sumptot = 0.0;
1388
	$sumitot = 0.0;
1388
	$sumitot = 0.0;
1389
 
1389
 
1390
	while ($z < $anz) {
1390
	while ($z < $anz) {
1391
	   printf("<td class=\"selltgray\" align=\"right\"><b>%s<br>%s</b></td>", FormatNum($sumparr[$z], 3),
1391
	   printf("<td class=\"selltgray\" align=\"right\"><b>%s<br>%s</b></td>", FormatNum($sumparr[$z], 3),
1392
	      		FormatNum($sumiarr[$z], 3));
1392
	      		FormatNum($sumiarr[$z], 3));
1393
	   $sumptot += $sumparr[$z];
1393
	   $sumptot += $sumparr[$z];
1394
	   $sumitot += $sumiarr[$z];
1394
	   $sumitot += $sumiarr[$z];
1395
	   $z++;
1395
	   $z++;
1396
	}
1396
	}
1397
 
1397
 
1398
	printf("<td class=\"selgray\" align=\"right\"><b>%s</b></td>", FormatNum($sumptot, 3));
1398
	printf("<td class=\"selgray\" align=\"right\"><b>%s</b></td>", FormatNum($sumptot, 3));
1399
	printf("<td class=\"selgray\" align=\"right\"><b>%s</b></td>", FormatNum($sumitot, 3));
1399
	printf("<td class=\"selgray\" align=\"right\"><b>%s</b></td>", FormatNum($sumitot, 3));
1400
	echo "<td class=\"sel\" colspan=2>&nbsp;</td>";
1400
	echo "<td class=\"sel\" colspan=2>&nbsp;</td>";
1401
 
1401
 
1402
	if ($ist_erledigung)
1402
	if ($ist_erledigung)
1403
	   echo "<td class=\"sel\">&nbsp;</td>\n";
1403
	   echo "<td class=\"sel\">&nbsp;</td>\n";
1404
 
1404
 
1405
	echo "</tr>\n";
1405
	echo "</tr>\n";
1406
	echo "</table></form>\n";
1406
	echo "</table></form>\n";
1407
	closeDB($db);
1407
	closeDB($db);
1408
}
1408
}
1409
 
1409
 
1410
# Folgende Funktion prueft die uebergebenen Parameter und speichert die
1410
# Folgende Funktion prueft die uebergebenen Parameter und speichert die
1411
# neuen oder veraenderten IST-Zeiten in die Datenbank.
1411
# neuen oder veraenderten IST-Zeiten in die Datenbank.
1412
#
1412
#
1413
function SaveIST() {
1413
function SaveIST() {
1414
	global $unum;
1414
	global $unum;
1415
	global $leneinheit;
1415
	global $leneinheit;
1416
	global $verrmodul;
1416
	global $verrmodul;
1417
	global $stdwhg;
1417
	global $stdwhg;
1418
 
1418
 
1419
	$kill = false;
1419
	$kill = false;
1420
	$db = OpenDB();
1420
	$db = OpenDB();
1421
 
1421
 
1422
	if (!($result = QueryDB($db, "select co_wdone, co_dration from counter"))) {
1422
	if (!($result = QueryDB($db, "select co_wdone, co_dration from counter"))) {
1423
	   closeDB($db);
1423
	   closeDB($db);
1424
	   return false;
1424
	   return false;
1425
	}
1425
	}
1426
 
1426
 
1427
	$data = fetchDB($result, 0);
1427
	$data = fetchDB($result, 0);
1428
	$co_wdone = $data[0];
1428
	$co_wdone = $data[0];
1429
	$co_dration = $data[1];
1429
	$co_dration = $data[1];
1430
 
1430
 
1431
	foreach ($_REQUEST as $key => $hours) {
1431
	foreach ($_REQUEST as $key => $hours) {
1432
	   $fr = substr($key, 0, 3);
1432
	   $fr = substr($key, 0, 3);
1433
 
1433
 
1434
	   if ($verrmodul) {
1434
	   if ($verrmodul) {
1435
	      if ($fr != "dt_" && $fr != "vr_" && $fr != "rk_" && $fr != "am_" &&
1435
	      if ($fr != "dt_" && $fr != "vr_" && $fr != "rk_" && $fr != "am_" &&
1436
	          $fr != "nu_" && $fr != "wh_" && $fr != "tx_" && $fr != "ds_" &&
1436
	          $fr != "nu_" && $fr != "wh_" && $fr != "tx_" && $fr != "ds_" &&
1437
		  $fr != "de_" && $fr != "ts_" && $fr != "te_" && $fr != "ta_" &&
1437
		  $fr != "de_" && $fr != "ts_" && $fr != "te_" && $fr != "ta_" &&
1438
		  $fr != "pu_" && $fr != "pn_" && $fr != "ni_" && $fr != "mc_" &&
1438
		  $fr != "pu_" && $fr != "pn_" && $fr != "ni_" && $fr != "mc_" &&
1439
		  $fr != "kf_" && $fr != "md_" && $fr != "pp_" && $fr != "mp_" &&
1439
		  $fr != "kf_" && $fr != "md_" && $fr != "pp_" && $fr != "mp_" &&
1440
		  $fr != "cl_" && $fr != "rm_")
1440
		  $fr != "cl_" && $fr != "rm_")
1441
	         continue;
1441
	         continue;
1442
	   } else {
1442
	   } else {
1443
	      if ($fr != "dt_")
1443
	      if ($fr != "dt_")
1444
	         continue;
1444
	         continue;
1445
	   }
1445
	   }
1446
 
1446
 
1447
	   $pars = explode("_", $key);
1447
	   $pars = explode("_", $key);
1448
	   $minum = $pars[1];
1448
	   $minum = $pars[1];
1449
	   $pr_num = $pars[2];
1449
	   $pr_num = $pars[2];
1450
	   $wd_task = $pars[3];
1450
	   $wd_task = $pars[3];
1451
	   $dt = $pars[4];
1451
	   $dt = $pars[4];
1452
 
1452
 
1453
	   if ($verrmodul) {
1453
	   if ($verrmodul) {
1454
	      $name = "vr_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1454
	      $name = "vr_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1455
	      $wd_verr = $_REQUEST[$name];
1455
	      $wd_verr = $_REQUEST[$name];
1456
	      $name = "rk_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1456
	      $name = "rk_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1457
	      $wd_rk = $_REQUEST[$name];
1457
	      $wd_rk = $_REQUEST[$name];
1458
	      $name = "am_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1458
	      $name = "am_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1459
	      $dr_amount = $_REQUEST[$name];
1459
	      $dr_amount = $_REQUEST[$name];
1460
	      $name = "nu_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1460
	      $name = "nu_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1461
	      $dr_num = $_REQUEST[$name];
1461
	      $dr_num = $_REQUEST[$name];
1462
	      $name = "wh_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1462
	      $name = "wh_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1463
	      $dr_whg = $_REQUEST[$name];
1463
	      $dr_whg = $_REQUEST[$name];
1464
	      $name = "tx_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1464
	      $name = "tx_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1465
	      $wd_text = $_REQUEST[$name];
1465
	      $wd_text = $_REQUEST[$name];
1466
	      $name = "ds_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1466
	      $name = "ds_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1467
	      $dr_date_start = $_REQUEST[$name];
1467
	      $dr_date_start = $_REQUEST[$name];
1468
	      $name = "de_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1468
	      $name = "de_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1469
	      $dr_date_end = $_REQUEST[$name];
1469
	      $dr_date_end = $_REQUEST[$name];
1470
	      $name = "ts_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1470
	      $name = "ts_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1471
	      $dr_time_start = $_REQUEST[$name];
1471
	      $dr_time_start = $_REQUEST[$name];
1472
	      $name = "te_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1472
	      $name = "te_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1473
	      $dr_time_end = $_REQUEST[$name];
1473
	      $dr_time_end = $_REQUEST[$name];
1474
	      $name = "ta_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1474
	      $name = "ta_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1475
	      $dr_target = $_REQUEST[$name];
1475
	      $dr_target = $_REQUEST[$name];
1476
	      $name = "pu_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1476
	      $name = "pu_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1477
	      $dr_purpose = $_REQUEST[$name];
1477
	      $dr_purpose = $_REQUEST[$name];
1478
	      $name = "pn_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1478
	      $name = "pn_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1479
	      $dr_pnightr = $_REQUEST[$name];
1479
	      $dr_pnightr = $_REQUEST[$name];
1480
	      $name = "ni_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1480
	      $name = "ni_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1481
	      $dr_nightr = $_REQUEST[$name];
1481
	      $dr_nightr = $_REQUEST[$name];
1482
	      $name = "mc_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1482
	      $name = "mc_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1483
	      $dr_kmcar = $_REQUEST[$name];
1483
	      $dr_kmcar = $_REQUEST[$name];
1484
	      $name = "kf_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1484
	      $name = "kf_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1485
	      $dr_kfzkenn = $_REQUEST[$name];
1485
	      $dr_kfzkenn = $_REQUEST[$name];
1486
	      $name = "md_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1486
	      $name = "md_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1487
	      $dr_kmdrain = $_REQUEST[$name];
1487
	      $dr_kmdrain = $_REQUEST[$name];
1488
	      $name = "pp_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1488
	      $name = "pp_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1489
	      $dr_pkmplain = $_REQUEST[$name];
1489
	      $dr_pkmplain = $_REQUEST[$name];
1490
	      $name = "mp_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1490
	      $name = "mp_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1491
	      $dr_kmplain = $_REQUEST[$name];
1491
	      $dr_kmplain = $_REQUEST[$name];
1492
	      $name = "cl_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1492
	      $name = "cl_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1493
	      $dr_costloc = $_REQUEST[$name];
1493
	      $dr_costloc = $_REQUEST[$name];
1494
	      $name = "rm_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1494
	      $name = "rm_" . $minum . "_" . $pr_num . "_" . $wd_task . "_" . $dt;
1495
	      $dr_remark = $_REQUEST[$name];
1495
	      $dr_remark = $_REQUEST[$name];
1496
 
1496
 
1497
	      if (CheckTrue($wd_rk))
1497
	      if (CheckTrue($wd_rk))
1498
		 $wd_rk = 1;
1498
		 $wd_rk = 1;
1499
	      else
1499
	      else
1500
		 $wd_rk = 0;
1500
		 $wd_rk = 0;
1501
 
1501
 
1502
	      if (CheckTrue($wd_verr))
1502
	      if (CheckTrue($wd_verr))
1503
		 $wd_verr = "true";
1503
		 $wd_verr = "true";
1504
	      else
1504
	      else
1505
		 $wd_verr = "false";
1505
		 $wd_verr = "false";
1506
 
1506
 
1507
	      if (!isset($dr_amount))
1507
	      if (!isset($dr_amount))
1508
		 $dr_amount = 0.0;
1508
		 $dr_amount = 0.0;
1509
	      else
1509
	      else
1510
		 $dr_amount = str_replace(",", ".", $dr_amount);
1510
		 $dr_amount = str_replace(",", ".", $dr_amount);
1511
 
1511
 
1512
	      if (!isset($dr_whg) || $dr_whg <= 0)
1512
	      if (!isset($dr_whg) || $dr_whg <= 0)
1513
		 $dr_whg = $stdwhg;
1513
		 $dr_whg = $stdwhg;
1514
 
1514
 
1515
	      if (!isset($dr_nightr))
1515
	      if (!isset($dr_nightr))
1516
		 $dr_nightr = 0.0;
1516
		 $dr_nightr = 0.0;
1517
	      else
1517
	      else
1518
		 $dr_nightr = str_replace(",", ".", $dr_nightr);
1518
		 $dr_nightr = str_replace(",", ".", $dr_nightr);
1519
 
1519
 
1520
	      if (!isset($dr_kmdrain) || strlen($dr_kmdrain) == 0 || !ctype_digit($dr_kmdrain))
1520
	      if (!isset($dr_kmdrain) || strlen($dr_kmdrain) == 0 || !ctype_digit($dr_kmdrain))
1521
	         $dr_kmdrain = 0;
1521
	         $dr_kmdrain = 0;
1522
 
1522
 
1523
	      if (!isset($dr_kmplain))
1523
	      if (!isset($dr_kmplain))
1524
		 $dr_kmplain = 0.0;
1524
		 $dr_kmplain = 0.0;
1525
	      else
1525
	      else
1526
		 $dr_kmplain = str_replace(",", ".", $dr_kmplain);
1526
		 $dr_kmplain = str_replace(",", ".", $dr_kmplain);
1527
 
1527
 
1528
	      if (!isset($dr_kmcar) || strlen($dr_kmcar) == 0 || !ctype_digit($dr_kmcar))
1528
	      if (!isset($dr_kmcar) || strlen($dr_kmcar) == 0 || !ctype_digit($dr_kmcar))
1529
	         $dr_kmcar = 0;
1529
	         $dr_kmcar = 0;
1530
 
1530
 
1531
	      if (CheckTrue($dr_pnightr))
1531
	      if (CheckTrue($dr_pnightr))
1532
		 $dr_pnightr = "true";
1532
		 $dr_pnightr = "true";
1533
	      else
1533
	      else
1534
		 $dr_pnightr = "false";
1534
		 $dr_pnightr = "false";
1535
 
1535
 
1536
	      if (CheckTrue($dr_pkmplain))
1536
	      if (CheckTrue($dr_pkmplain))
1537
		 $dr_pkmplain = "true";
1537
		 $dr_pkmplain = "true";
1538
	      else
1538
	      else
1539
		 $dr_pkmplain = "false";
1539
		 $dr_pkmplain = "false";
1540
 
1540
 
1541
	      if (isset($dr_date_start) && strlen($dr_date_start) >= 6)
1541
	      if (isset($dr_date_start) && strlen($dr_date_start) >= 6)
1542
		 $dr_date_start = DateToDBDate($dr_date_start) . " " . $dr_time_start;
1542
		 $dr_date_start = DateToDBDate($dr_date_start) . " " . $dr_time_start;
1543
	      else
1543
	      else
1544
		 $dr_date_start = "";
1544
		 $dr_date_start = "";
1545
 
1545
 
1546
	      if (isset($dr_date_end) && strlen($dr_date_end) >= 6)
1546
	      if (isset($dr_date_end) && strlen($dr_date_end) >= 6)
1547
		 $dr_date_end = DateToDBDate($dr_date_end) . " " . $dr_time_end;
1547
		 $dr_date_end = DateToDBDate($dr_date_end) . " " . $dr_time_end;
1548
	      else
1548
	      else
1549
		 $dr_date_end = "";
1549
		 $dr_date_end = "";
1550
 
1550
 
1551
	      if (!isset($dr_costloc) || $dr_costloc <= 0)
1551
	      if (!isset($dr_costloc) || $dr_costloc <= 0)
1552
		 $dr_costloc = "NULL";
1552
		 $dr_costloc = "NULL";
1553
	   }
1553
	   }
1554
 
1554
 
1555
	   if ($fr != "dt_")
1555
	   if ($fr != "dt_")
1556
	      continue;
1556
	      continue;
1557
 
1557
 
1558
	   if (!isset($hours) || $hours == "")
1558
	   if (!isset($hours) || $hours == "")
1559
	      $hours = 0.0;
1559
	      $hours = 0.0;
1560
	   else
1560
	   else
1561
	      $hours = str_replace(",", ".", $hours);
1561
	      $hours = str_replace(",", ".", $hours);
1562
 
1562
 
1563
	   if ($minum <= 0 || $pr_num <= 0 || $wd_task <= 0 || $dt <= 0) {
1563
	   if ($minum <= 0 || $pr_num <= 0 || $wd_task <= 0 || $dt <= 0) {
1564
	      Error(GetMessage(-1, 265, "Interner Fehler: Fehlender Parameter!"));
1564
	      Error(GetMessage(-1, 265, "Interner Fehler: Fehlender Parameter!"));
1565
	      closeDB($db);
1565
	      closeDB($db);
1566
	      return false;
1566
	      return false;
1567
	   }
1567
	   }
1568
 
1568
 
1569
	   $query = "select ta_phase, ta_hash from task where ta_num = $wd_task";
1569
	   $query = "select ta_phase, ta_hash from task where ta_num = $wd_task";
1570
 
1570
 
1571
	   if (!($resta = QueryDB($db, $query))) {
1571
	   if (!($resta = QueryDB($db, $query))) {
1572
	      closeDB($db);
1572
	      closeDB($db);
1573
	      return false;
1573
	      return false;
1574
	   }
1574
	   }
1575
 
1575
 
1576
	   $data = fetchDB($resta, 0);
1576
	   $data = fetchDB($resta, 0);
1577
	   $ta_phase = $data[0];
1577
	   $ta_phase = $data[0];
1578
	   $ta_hash = $data[1];
1578
	   $ta_hash = $data[1];
1579
 
1579
 
1580
	   if (!isset($ta_phase))	// Task eines Kontos?
1580
	   if (!isset($ta_phase))	// Task eines Kontos?
1581
	      $ta_phase = 0;
1581
	      $ta_phase = 0;
1582
 
1582
 
1583
	   $query = "select wd_num from wdone, task where ";
1583
	   $query = "select wd_num from wdone, task where ";
1584
	   $query .= "wd_minum = $minum and wd_task = ta_num and ";
1584
	   $query .= "wd_minum = $minum and wd_task = ta_num and ";
1585
	   $query .= "ta_hash = '$ta_hash' and ";
1585
	   $query .= "ta_hash = '$ta_hash' and ";
1586
 
1586
 
1587
	   $day = 1;
1587
	   $day = 1;
1588
	   $mon = gmdate("n", $dt);
1588
	   $mon = gmdate("n", $dt);
1589
	   $year = gmdate("Y", $dt);
1589
	   $year = gmdate("Y", $dt);
1590
	   $fdate = gmmktime(0, 0, 0, $mon, 1, $year);
1590
	   $fdate = gmmktime(0, 0, 0, $mon, 1, $year);
1591
	   $ldate = gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year);
1591
	   $ldate = gmmktime(0, 0, 0, $mon, daysinmonth($mon, $year), $year);
1592
	   $query .= "wd_datum between $fdate and $ldate ";
1592
	   $query .= "wd_datum between $fdate and $ldate ";
1593
 
1593
 
1594
	   if (!($reswd = QueryDB($db, $query))) {
1594
	   if (!($reswd = QueryDB($db, $query))) {
1595
	      closeDB($db);
1595
	      closeDB($db);
1596
	      return false;
1596
	      return false;
1597
	   }
1597
	   }
1598
 
1598
 
1599
	   $anz = numrowsDB($reswd);
1599
	   $anz = numrowsDB($reswd);
1600
 
1600
 
1601
	   if (!QueryDB($db, "begin")) {
1601
	   if (!QueryDB($db, "begin")) {
1602
	      closeDB($db);
1602
	      closeDB($db);
1603
	      return false;
1603
	      return false;
1604
	   }
1604
	   }
1605
 
1605
 
1606
	   if ($anz > 0) {
1606
	   if ($anz > 0) {
1607
	      # Bevor wir IST-Daten loeschen koennen, muessen wir eventuell
1607
	      # Bevor wir IST-Daten loeschen koennen, muessen wir eventuell
1608
	      # vorhandene Resekosten und/oder Spesen loeschen.
1608
	      # vorhandene Resekosten und/oder Spesen loeschen.
1609
	      $query = "select wd_num from wdone where wd_minum = $minum and ";
1609
	      $query = "select wd_num from wdone where wd_minum = $minum and ";
1610
	      $query .= "wd_datum between $fdate and $ldate and ";
1610
	      $query .= "wd_datum between $fdate and $ldate and ";
1611
	      $query .= "wd_task in (select ta_num from task where ";
1611
	      $query .= "wd_task in (select ta_num from task where ";
1612
	      $query .= "ta_hash = '$ta_hash')";
1612
	      $query .= "ta_hash = '$ta_hash')";
1613
 
1613
 
1614
	      if (!($result = QueryDB($db, $query))) {
1614
	      if (!($result = QueryDB($db, $query))) {
1615
		 QueryDB($db, "rollback");
1615
		 QueryDB($db, "rollback");
1616
		 closeDB($db);
1616
		 closeDB($db);
1617
		 return false;
1617
		 return false;
1618
	      }
1618
	      }
1619
 
1619
 
1620
	      $rows = numrowsDB($result);
1620
	      $rows = numrowsDB($result);
1621
	      $j = 0;
1621
	      $j = 0;
1622
 
1622
 
1623
	      while ($j < $rows) {
1623
	      while ($j < $rows) {
1624
		 $data = fetchDB($result, $j);
1624
		 $data = fetchDB($result, $j);
1625
		 $num = $data[0];
1625
		 $num = $data[0];
1626
 
1626
 
1627
		 $query = "delete from dration where dr_wdnum = $num";
1627
		 $query = "delete from dration where dr_wdnum = $num";
1628
 
1628
 
1629
		 if (!QueryDB($db, $query)) {
1629
		 if (!QueryDB($db, $query)) {
1630
		    QueryDB($db, "rollback");
1630
		    QueryDB($db, "rollback");
1631
		    closeDB($db);
1631
		    closeDB($db);
1632
		    return false;
1632
		    return false;
1633
		 }
1633
		 }
1634
 
1634
 
1635
		 $j++;
1635
		 $j++;
1636
	      }
1636
	      }
1637
 
1637
 
1638
	      $query = "delete from wdone where wd_minum = $minum and ";
1638
	      $query = "delete from wdone where wd_minum = $minum and ";
1639
	      $query .= "wd_datum between $fdate and $ldate and ";
1639
	      $query .= "wd_datum between $fdate and $ldate and ";
1640
	      $query .= "wd_task in (select ta_num from task where ";
1640
	      $query .= "wd_task in (select ta_num from task where ";
1641
	      $query .= "ta_hash = '$ta_hash')";
1641
	      $query .= "ta_hash = '$ta_hash')";
1642
 
1642
 
1643
	      if (!QueryDB($db, $query)) {
1643
	      if (!QueryDB($db, $query)) {
1644
		 QueryDB($db, "rollback");
1644
		 QueryDB($db, "rollback");
1645
		 closeDB($db);
1645
		 closeDB($db);
1646
		 return false;
1646
		 return false;
1647
	      }
1647
	      }
1648
	   }
1648
	   }
1649
 
1649
 
1650
	   $j = 0;
1650
	   $j = 0;
1651
	   $h = $hours * $leneinheit;
1651
	   $h = $hours * $leneinheit;
1652
	   $days = daysinmonth($mon, $year);
1652
	   $days = daysinmonth($mon, $year);
1653
 
1653
 
1654
	   while ($j < $h) {
1654
	   while ($j < $h) {
1655
	      $datum = gmmktime(0, 0, 0, $mon, $day, $year);
1655
	      $datum = gmmktime(0, 0, 0, $mon, $day, $year);
1656
	      $co_wdone++;
1656
	      $co_wdone++;
1657
 
1657
 
1658
	      if (($h - $j) < $leneinheit)
1658
	      if (($h - $j) < $leneinheit)
1659
		    $ho = $h - $j;
1659
		    $ho = $h - $j;
1660
	      else
1660
	      else
1661
		 $ho = $leneinheit;
1661
		 $ho = $leneinheit;
1662
 
1662
 
1663
	      if (!$verrmodul) {
1663
	      if (!$verrmodul) {
1664
		 $wd_rk = 0;
1664
		 $wd_rk = 0;
1665
		 $wd_verr = "true";
1665
		 $wd_verr = "true";
1666
	      }
1666
	      }
1667
 
1667
 
1668
	      $wd_text = addslashes($wd_text);
1668
	      $wd_text = addslashes($wd_text);
1669
	      $query = "insert into wdone (wd_num, wd_prnum, wd_minum, ";
1669
	      $query = "insert into wdone (wd_num, wd_prnum, wd_minum, ";
1670
	      $query .= "wd_datum, wd_hours, wd_task, wd_rk, wd_phase, ";
1670
	      $query .= "wd_datum, wd_hours, wd_task, wd_rk, wd_phase, ";
1671
	      $query .= "wd_edit, wd_verr, wd_text) values ($co_wdone, $pr_num, ";
1671
	      $query .= "wd_edit, wd_verr, wd_text) values ($co_wdone, $pr_num, ";
1672
	      $query .= "$minum, $datum, $ho, $wd_task, $wd_rk, $ta_phase,";
1672
	      $query .= "$minum, $datum, $ho, $wd_task, $wd_rk, $ta_phase,";
1673
	      $query .= "true, $wd_verr, '$wd_text')";
1673
	      $query .= "true, $wd_verr, '$wd_text')";
1674
 
1674
 
1675
	      if (!QueryDB($db, $query)) {
1675
	      if (!QueryDB($db, $query)) {
1676
		 QueryDB($db, "rollback");
1676
		 QueryDB($db, "rollback");
1677
		 closeDB($db);
1677
		 closeDB($db);
1678
		 return false;
1678
		 return false;
1679
	      }
1679
	      }
1680
 
1680
 
1681
	      if ($verrmodul && $j == 0) {
1681
	      if ($verrmodul && $j == 0) {
1682
	         $co_dration++;
1682
	         $co_dration++;
1683
 
1683
 
1684
		 if ($wd_rk == false) {
1684
		 if ($wd_rk == false) {
1685
		    $query = "insert into dration (dr_num, dr_nightr, ";
1685
		    $query = "insert into dration (dr_num, dr_nightr, ";
1686
		    $query .= "dr_amount, dr_kmcar, dr_kmdrain, ";
1686
		    $query .= "dr_amount, dr_kmcar, dr_kmdrain, ";
1687
		    $query .= "dr_kmplain, dr_wdnum, dr_whg, dr_costloc) ";
1687
		    $query .= "dr_kmplain, dr_wdnum, dr_whg, dr_costloc) ";
1688
		    $query .= "values ($co_dration, 0, $dr_amount, 0, 0, 0,";
1688
		    $query .= "values ($co_dration, 0, $dr_amount, 0, 0, 0,";
1689
		    $query .= "$co_wdone, $dr_whg, $dr_costloc)";
1689
		    $query .= "$co_wdone, $dr_whg, $dr_costloc)";
1690
		 } else {
1690
		 } else {
1691
		    $dr_purpose = addslashes($dr_purpose);
1691
		    $dr_purpose = addslashes($dr_purpose);
1692
		    $dr_target = addslashes($dr_target);
1692
		    $dr_target = addslashes($dr_target);
1693
		    $dr_remark = addslashes($dr_remark);
1693
		    $dr_remark = addslashes($dr_remark);
1694
		    $query = "insert into dration (dr_num, dr_date_start, ";
1694
		    $query = "insert into dration (dr_num, dr_date_start, ";
1695
		    $query .= "dr_date_end, dr_target, dr_purpose, dr_pnightr,";
1695
		    $query .= "dr_date_end, dr_target, dr_purpose, dr_pnightr,";
1696
		    $query .= "dr_nightr, dr_amount, dr_kmcar, dr_kfzkenn, ";
1696
		    $query .= "dr_nightr, dr_amount, dr_kmcar, dr_kfzkenn, ";
1697
		    $query .= "dr_kmdrain, dr_pkmplain, dr_kmplain, dr_wdnum,";
1697
		    $query .= "dr_kmdrain, dr_pkmplain, dr_kmplain, dr_wdnum,";
1698
		    $query .= "dr_whg, dr_costloc, dr_remark) values ($co_dration, '$dr_date_start',";
1698
		    $query .= "dr_whg, dr_costloc, dr_remark) values ($co_dration, '$dr_date_start',";
1699
		    $query .= "'$dr_date_end', '$dr_target', '$dr_purpose',";
1699
		    $query .= "'$dr_date_end', '$dr_target', '$dr_purpose',";
1700
		    $query .= "$dr_pnightr, $dr_nightr, $dr_amount, $dr_kmcar,";
1700
		    $query .= "$dr_pnightr, $dr_nightr, $dr_amount, $dr_kmcar,";
1701
		    $query .= "'$dr_kfzkenn', $dr_kmdrain, $dr_pkmplain, ";
1701
		    $query .= "'$dr_kfzkenn', $dr_kmdrain, $dr_pkmplain, ";
1702
		    $query .= "$dr_kmplain, $co_wdone, $dr_whg, $dr_costloc, '$dr_remark')";
1702
		    $query .= "$dr_kmplain, $co_wdone, $dr_whg, $dr_costloc, '$dr_remark')";
1703
		 }
1703
		 }
1704
 
1704
 
1705
		 if (!QueryDB($db, $query)) {
1705
		 if (!QueryDB($db, $query)) {
1706
		    QueryDB($db, "rollback");
1706
		    QueryDB($db, "rollback");
1707
		    closeDB($db);
1707
		    closeDB($db);
1708
		    return false;
1708
		    return false;
1709
		 }
1709
		 }
1710
	      }
1710
	      }
1711
 
1711
 
1712
	      $j += $leneinheit;
1712
	      $j += $leneinheit;
1713
	      $day++;
1713
	      $day++;
1714
 
1714
 
1715
	      if ($day > $days)
1715
	      if ($day > $days)
1716
		 $day = 1;
1716
		 $day = 1;
1717
	   }
1717
	   }
1718
 
1718
 
1719
	   if ($verrmodul)
1719
	   if ($verrmodul)
1720
	      $query = "update counter set co_wdone = $co_wdone, co_dration = $co_dration";
1720
	      $query = "update counter set co_wdone = $co_wdone, co_dration = $co_dration";
1721
	   else
1721
	   else
1722
	      $query = "update counter set co_wdone = $co_wdone";
1722
	      $query = "update counter set co_wdone = $co_wdone";
1723
 
1723
 
1724
	   if (!QueryDB($db, $query)) {
1724
	   if (!QueryDB($db, $query)) {
1725
	      QueryDB($db, "rollback");
1725
	      QueryDB($db, "rollback");
1726
	      closeDB($db);
1726
	      closeDB($db);
1727
	      return false;
1727
	      return false;
1728
	   }
1728
	   }
1729
 
1729
 
1730
	   QueryDB($db, "commit");
1730
	   QueryDB($db, "commit");
1731
	}
1731
	}
1732
 
1732
 
1733
	Journal(302, "istpm.php: SaveIST: Projekt: $pr_num, Mitarbeiter: $minum", $db);
1733
	Journal(302, "istpm.php: SaveIST: Projekt: $pr_num, Mitarbeiter: $minum", $db);
1734
	closeDB($db);
1734
	closeDB($db);
1735
	return true;
1735
	return true;
1736
}
1736
}
1737
 
1737
 
1738
if (!$pmlight) {
1738
if (!$pmlight) {
1739
   Error(GetMessage(-1, 266, "Periodensicht ist nicht aktiviert!"));
1739
   Error(GetMessage(-1, 266, "Periodensicht ist nicht aktiviert!"));
1740
   require_once('footer.inc');
1740
   require_once('footer.inc');
1741
   return;
1741
   return;
1742
}
1742
}
1743
 
1743
 
1744
if ($func == "save")
1744
if ($func == "save")
1745
   SaveIST();
1745
   SaveIST();
1746
 
1746
 
1747
ManageTime();
1747
ManageTime();
1748
 
1748
 
1749
require_once('footer.inc');
1749
require_once('footer.inc');
1750
?>
1750
?>
1751
 
1751