1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Compute completion percentage for a dll.
|
---|
5 | * @returns Completion percentage. Range 0-100.
|
---|
6 | * On error -1 or -2 is returned.
|
---|
7 | * @param $ulDll Dll reference code.
|
---|
8 | * @param $db Database connection variable.
|
---|
9 | * @sketch Get total number of function in the dll.
|
---|
10 | * Get number of completed functions in the dll.
|
---|
11 | * return complete*100 / total
|
---|
12 | * @status Completely implemented
|
---|
13 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
14 | * @remark
|
---|
15 | */
|
---|
16 | function Odin32DBComputeCompletion($ulDll, $db)
|
---|
17 | {
|
---|
18 | /*
|
---|
19 | * Count the total number of functions in the DLL.
|
---|
20 | */
|
---|
21 | $sql = sprintf("SELECT SUM(s.weight)/COUNT(f.state)
|
---|
22 | FROM
|
---|
23 | function f,
|
---|
24 | state s
|
---|
25 | WHERE
|
---|
26 | f.state = s.refcode
|
---|
27 | AND dll = %d",
|
---|
28 | $ulDll);
|
---|
29 | $result = mysql_query($sql, $db);
|
---|
30 | if (mysql_num_rows($result) < 1)
|
---|
31 | {
|
---|
32 | echo "<br>Odin32DBComputeCompletion: IPE no. 1 <br>";
|
---|
33 | return -1;
|
---|
34 | }
|
---|
35 | $row = mysql_fetch_row($result);
|
---|
36 | $iComplete = $row[0];
|
---|
37 | mysql_free_result($result);
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Draws a completion bar.
|
---|
44 | * @param $ulDll Dll reference code.
|
---|
45 | * @param $db Database connection variable.
|
---|
46 | * @sketch Get total number of function in the dll.
|
---|
47 | * Get the number of function per status. (+state color)
|
---|
48 | * Draw bar.
|
---|
49 | * @status Completely implemented
|
---|
50 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
51 | */
|
---|
52 | function Odin32DBCompletionBar($ulDll, $sDllName, $db)
|
---|
53 | {
|
---|
54 | /*
|
---|
55 | * Count the total number of functions in the DLL.
|
---|
56 | */
|
---|
57 | $sql = sprintf("SELECT COUNT(*) FROM function f WHERE dll = %d",
|
---|
58 | $ulDll);
|
---|
59 | $result = mysql_query($sql, $db);
|
---|
60 | if (mysql_num_rows($result) < 1)
|
---|
61 | {
|
---|
62 | printf("\n\n<br>Odin32DBCompletionBar: IPE(1).<br>\n\n");
|
---|
63 | return -1;
|
---|
64 | }
|
---|
65 | $row = mysql_fetch_row($result);
|
---|
66 | $cFunctions = $row[0];
|
---|
67 | mysql_free_result($result);
|
---|
68 |
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * Make
|
---|
72 | */
|
---|
73 | echo "
|
---|
74 | <table width=100% border=0 cellspacing=0 cellpadding=0>
|
---|
75 | <tr>
|
---|
76 | <td width=90%>
|
---|
77 | <font size=-1 color=000099>
|
---|
78 | <tt>".$sDllName."</tt>
|
---|
79 | </font>
|
---|
80 | </td>
|
---|
81 | <td width=10%></td>
|
---|
82 | </tr>
|
---|
83 | <tr>
|
---|
84 | <td width=90%>
|
---|
85 | <table width=100% border=0 cellspacing=0 cellpadding=0>
|
---|
86 | <tr>
|
---|
87 | ";
|
---|
88 |
|
---|
89 |
|
---|
90 | /*
|
---|
91 | * Get states and make bar.
|
---|
92 | */
|
---|
93 | $sql = sprintf("SELECT COUNT(f.refcode) AS count,
|
---|
94 | f.state AS state,
|
---|
95 | s.color AS color,
|
---|
96 | s.weight AS weight
|
---|
97 | FROM
|
---|
98 | function f,
|
---|
99 | state s
|
---|
100 | WHERE
|
---|
101 | dll = %d
|
---|
102 | AND s.refcode = f.state
|
---|
103 | GROUP BY f.state
|
---|
104 | ORDER BY state",
|
---|
105 | $ulDll);
|
---|
106 | $result = mysql_query($sql, $db);
|
---|
107 | $rdCompletePercent = 0.0;
|
---|
108 | if (@mysql_num_rows($result) < 1)
|
---|
109 | {
|
---|
110 | echo "
|
---|
111 | <td colspan=2 bgcolor=dddddd>
|
---|
112 | <font size=-1>
|
---|
113 |
|
---|
114 | </font>
|
---|
115 | </td>
|
---|
116 | ";
|
---|
117 |
|
---|
118 | }
|
---|
119 | else
|
---|
120 | {
|
---|
121 | while ($row = mysql_fetch_row($result))
|
---|
122 | {
|
---|
123 | $iPercent = (int)($row[0] * 90 /* 10% is reserved to % */ / $cFunctions);
|
---|
124 | if ($iPercent == 0)
|
---|
125 | $iPercent = 1;
|
---|
126 | echo "
|
---|
127 | <td width=".$iPercent." bgcolor=".$row[2].">
|
---|
128 | <font size=-1>
|
---|
129 |
|
---|
130 | </font>
|
---|
131 | </td>
|
---|
132 | ";
|
---|
133 |
|
---|
134 | $rdCompletePercent += ((double)$row[3] * (double)$row[0]) / $cFunctions;
|
---|
135 | }
|
---|
136 |
|
---|
137 | }
|
---|
138 | mysql_free_result($result);
|
---|
139 |
|
---|
140 | /*
|
---|
141 | * Complete bar with a total completion percent.
|
---|
142 | */
|
---|
143 | echo "
|
---|
144 | <td width=10% align=right>
|
---|
145 | <font size=-1 color=000099>
|
---|
146 | ".(int)$rdCompletePercent."%
|
---|
147 | </font>
|
---|
148 | </td>
|
---|
149 | </tr>
|
---|
150 | </table>
|
---|
151 | </td>
|
---|
152 | </tr>
|
---|
153 | </table>
|
---|
154 | ";
|
---|
155 | }
|
---|
156 |
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Draws a legend for status colors.
|
---|
160 | * @param $db Database connection variable.
|
---|
161 | * @sketch Get status codes; fetch name and color.
|
---|
162 | *
|
---|
163 | *
|
---|
164 | * @status Completely implemented
|
---|
165 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
166 | */
|
---|
167 | function Odin32DBStateLegend($db)
|
---|
168 | {
|
---|
169 | /*
|
---|
170 | * Count the total number of functions in the DLL.
|
---|
171 | */
|
---|
172 | $sql = "SELECT
|
---|
173 | name,
|
---|
174 | color
|
---|
175 | FROM
|
---|
176 | state
|
---|
177 | ORDER BY refcode";
|
---|
178 |
|
---|
179 | $result = mysql_query($sql, $db);
|
---|
180 | if (mysql_num_rows($result) < 1)
|
---|
181 | {
|
---|
182 | printf("\n\n<br>Odin32DBCompletionBar: IPE(1).<br>\n\n");
|
---|
183 | return -1;
|
---|
184 | }
|
---|
185 | else
|
---|
186 | {
|
---|
187 | echo "
|
---|
188 | <tr><td></td></tr>
|
---|
189 | <tr>
|
---|
190 | <td valign=center >
|
---|
191 | <center><B><font face=\"WarpSans, Arial\" color=\"#990000\">
|
---|
192 | Legend:
|
---|
193 | </font></b></center>
|
---|
194 | </td>
|
---|
195 | </tr>
|
---|
196 | <tr>
|
---|
197 | <table width=100% border=0 cellspacing=10 cellpadding=0 align=right>
|
---|
198 | ";
|
---|
199 | while ($row = mysql_fetch_row($result))
|
---|
200 | {
|
---|
201 | echo "
|
---|
202 | <tr>
|
---|
203 | <td width=90% align=right>
|
---|
204 | <font size=1 color=000099>
|
---|
205 | ".$row[0]."
|
---|
206 | </font>
|
---|
207 | </td>
|
---|
208 | <td width=1%>
|
---|
209 | <font size=1 color=000099>
|
---|
210 |
|
---|
211 | </font>
|
---|
212 | </td>
|
---|
213 | <td width=9% bgcolor=".$row[1].">
|
---|
214 | <font size=1 color=000099>
|
---|
215 |
|
---|
216 | </font>
|
---|
217 | </td>
|
---|
218 | </tr>
|
---|
219 | ";
|
---|
220 | }
|
---|
221 |
|
---|
222 | echo "
|
---|
223 | </table>
|
---|
224 | </p>
|
---|
225 | </tr>
|
---|
226 | ";
|
---|
227 | }
|
---|
228 |
|
---|
229 |
|
---|
230 | mysql_free_result($result);
|
---|
231 | }
|
---|
232 |
|
---|
233 |
|
---|
234 |
|
---|
235 | ?>
|
---|