Subversion Repositories public

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 andreas 1
<?php
2
class TaskNum {
3
	var $arr_snum;		// Laufende Nummerierung der Tasks in Punktnotation
4
	var $arr_tanum;		// Tasknummer
5
	var $arr_talevel;	// Level
6
	var $arr_taid;		// Interne laufende Nummer im Plan
7
	var $arr_type;		// Art des Tasks (Folder, ...)
8
	var $akt_plan;		// Aktuell gespeicherte Plannummer
9
	var $db;		// Datenbankhandle
10
	var $max;		// Maximale Anzahl im Array
11
 
12
	function kNumber_($snum, $level, $dir) {
13
	   $anz = str_wordcount($snum);
14
	   $kpnum = $snum;
15
 
16
	   # Haben wir weniger Einzelnummern im String, haengen wir ".1" so
17
	   # lange an, bis wir #level erreicht haben.
18
	   if ($anz < $level) {
19
	      while ($anz < $level) {
20
		 $kpnum .= ".0";
21
		 $anz++;
22
	      }
23
 
24
	      if ($dir == -3) {
25
		 return $kpnum;
26
	      }
27
	   }
28
 
29
	   $anz = $level;
30
	   $anum = explode(".", $kpnum);
31
 
32
	   switch ($dir) {
33
	      case 0:
34
	      case -1: $anum[$level-1]++; break;
35
	      case -2: $anum[$level-1]--; break;
36
	      case -3: break;
37
	      default: $anum[$level-1]--;
38
	   }
39
 
40
	   $num = "";
41
 
42
	   for ($i = 0; $i < $anz; $i++) {
43
	      if ($i > 0) {
44
		 $num .= "." . (string)$anum[$i];
45
	      } else {
46
		 $num = (string)$anum[$i];
47
	      }
48
	   }
49
 
50
	   return $num;
51
	}
52
 
53
	function TaskNum($pl_num, $db = -1) {
54
	   global $phase;
55
	   global $numphase;
56
 
57
	   if (!isset($pl_num) || $pl_num <= 0) {
58
	      Error("class TaskNum: Ung&uuml;ltige Plannummer wurde &uuml;bergeben!");
59
	      $this->db = -1;
60
	      return;
61
	   }
62
 
63
	   $this->akt_plan = $pl_num;
64
 
65
	   if ($db == -1)
66
	      $this->db = OpenDB();
67
	   else
68
	      $this->db = $db;
69
 
70
	   $query = "select ta_num, ta_level, ta_id, ta_meeting, ta_phase from task where ";
71
	   $query .= "ta_plnum = $pl_num order by ta_id";
72
 
73
	   if (!($result = QueryDB($this->db, $query))) {
74
	      $this->db = -1;
75
	      return;
76
	   }
77
 
78
	   $anz = numrowsDB($result);
79
	   $this->max = $anz;
80
	   $j = 0;
81
	   $pos = 0;
82
	   $snum = "1";
83
 
84
	   while ($j < $anz) {
85
	      $data = fetchDB($result, $j);
86
	      $ta_num = $data[0];
87
	      $ta_level = $data[1];
88
	      $ta_id = $data[2];
89
	      $ta_meeting = $data[3];
90
	      $ta_phase = $data[4];
91
 
92
	      $this->arr_tanum[$j] = $ta_num;
93
	      $this->arr_talevel[$j] = $ta_level;
94
	      $this->arr_taid[$j] = $ta_id;
95
 
96
	      if ($ta_level == 1) {
97
	         if (CheckTrue($phase) && CheckTrue($numphase)) {
98
		    $snum = (string)$ta_phase;
99
		    $pos = $ta_phase;
100
		 } else {
101
		    $pos++;
102
		    $snum = (string)$pos;
103
		 }
104
 
105
		 $this->arr_snum[$j] = $snum;
106
		 $this->arr_type[$j] = "f";
107
	      } else {
108
		 $snum = $this->kNumber_($snum, $ta_level, 0);
109
		 $this->arr_snum[$j] = $snum;
110
 
111
		 if (!$ta_meeting)
112
		    $this->arr_type[$j] = "t";
113
		 else
114
		    $this->arr_type[$j] = "m";
115
 
116
		 if ($j > 0 && $this->arr_type[$j-1] != "m" && $this->arr_talevel[$j-1] < $ta_level)
117
		    $this->arr_type[$j-1] = "f";
118
	      }
119
 
120
	      $j++;
121
	   }
122
	}
123
 
124
	function GetStatus() {
125
	   if ($this->db == -1)
126
	      return false;
127
	   else
128
	      return true;
129
	}
130
 
131
	function Get_tanum($x) {
132
	   if ($this->db == -1 || $this->max < $x)
133
	      return 0;
134
 
135
	   return $this->arr_tanum[$x];
136
	}
137
 
138
	function Get_talevel($x) {
139
	   if ($this->db == -1 || $this->max < $x)
140
	      return 0;
141
 
142
	   return $this->arr_tanum[$x];
143
	}
144
 
145
	function Get_snum($x) {
146
	   if ($this->db == -1 || $this->max < $x)
147
	      return "";
148
 
149
	   return $this->arr_snum[$x];
150
	}
151
 
152
	function Get_taid($x) {
153
	   if ($this->db == -1 || $this->max < $x)
154
	      return 0;
155
 
156
	   return $this->arr_taid[$x];
157
	}
158
 
159
	function Get_type($x) {
160
	   if ($this->db == -1 || $this->max < $x)
161
	      return "";
162
 
163
	   return $this->arr_type[$x];
164
	}
165
}