1 | <?php
|
---|
2 | {
|
---|
3 | ini_set("display_errors", "On");
|
---|
4 | ini_set("mysql.trace_mode", "On");
|
---|
5 |
|
---|
6 | if (empty($_GET["fGetValCase"]))
|
---|
7 | {
|
---|
8 | echo "Please specify how you want to display the table (for view or for insert).";
|
---|
9 | //1: insert
|
---|
10 | //2: view
|
---|
11 | //3: view compare
|
---|
12 | return;
|
---|
13 | }
|
---|
14 | if (empty($_GET["fKey"]))
|
---|
15 | {
|
---|
16 | echo "Please select a key.";
|
---|
17 | return;
|
---|
18 | }
|
---|
19 | if (empty($_GET["fProgram"]))
|
---|
20 | {
|
---|
21 | echo "Please select a program.";
|
---|
22 | return;
|
---|
23 | }
|
---|
24 | if (empty($_GET["fStatusDate"]))
|
---|
25 | $_GET["fStatusDate"]="";
|
---|
26 |
|
---|
27 | include("db.php");
|
---|
28 | $db_id = mysql_pconnect($host, $user, $pw);
|
---|
29 | if ($db_id==FALSE)
|
---|
30 | {
|
---|
31 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
32 | die("");
|
---|
33 | }
|
---|
34 | mysql_select_db($db);
|
---|
35 |
|
---|
36 | $query1 = "SELECT Max(fCounter) FROM History";
|
---|
37 | // get counter of fStatusDate or current status
|
---|
38 | if ($_GET["fGetValCase"]!=1 && $_GET["fStatusDate"]!="")
|
---|
39 | $query1.=" WHERE (fValidFrom < '".$_GET["fStatusDate"]."' OR fValidFrom like '".$_GET["fStatusDate"]."%')";
|
---|
40 |
|
---|
41 | $result1=mysql_query($query1, $db_id);
|
---|
42 | $row1 = mysql_fetch_row($result1);
|
---|
43 | $counter=$row1[0];
|
---|
44 | mysql_free_result($result1);
|
---|
45 |
|
---|
46 | //get key1 and key2 separately from DB (for function AddRow())
|
---|
47 | $query2 = "SELECT fKey1, SUBSTRING(fKey2,2), fType, fMin, fMax, fDescription ";
|
---|
48 | $query2 .= "FROM ProgramOption WHERE Concat(fKey1,fKey2)='".$_GET["fKey"]."' ORDER BY fValidFrom DESC LIMIT 0,1";
|
---|
49 | $result2=mysql_query($query2, $db_id);
|
---|
50 | $row2 = mysql_fetch_row($result2);
|
---|
51 | //get values from result
|
---|
52 | $key1 =$row2[0];
|
---|
53 | $key2 = $row2[1];
|
---|
54 | $type = $row2[2];
|
---|
55 | $min = $row2[3];
|
---|
56 | $max = $row2[4];
|
---|
57 | $descr = $row2[5];
|
---|
58 | mysql_free_result($result2);
|
---|
59 |
|
---|
60 | $query0 ="SELECT fIndex, fValidFrom, fProgram, Concat(fKey1,fKey2), fValue, ";
|
---|
61 | $query0.="fDescription, fCounter, fType, fMin, fMax, fKey1, SUBSTRING(fKey2,2), ";
|
---|
62 | $query0.="if(fOriginalIndex=0, fIndex, fOriginalIndex), fUser FROM ProgramOption ";
|
---|
63 | $query0.="WHERE 1=1 ";
|
---|
64 | if (strcmp($_GET["fKey"],"all")!=0)
|
---|
65 | $query0.="AND Concat(fKey1,fKey2)='".$_GET["fKey"]."' ";
|
---|
66 | if (strcmp($_GET["fProgram"],"all")!=0)
|
---|
67 | $query0.="AND fProgram='".$_GET["fProgram"]."' ";
|
---|
68 | if ($_GET["fGetValCase"]!=1)
|
---|
69 | {
|
---|
70 | $query0.="AND NOT isnull(fValue) ";
|
---|
71 | $query0.="AND fCounter>=".$counter;
|
---|
72 | if ($_GET["fStatusDate"]!="")
|
---|
73 | $query0.=" AND (fValidFrom < '".$_GET["fStatusDate"]."' OR fValidFrom like '".$_GET["fStatusDate"]."%') ";
|
---|
74 | }
|
---|
75 | $query0.=" ORDER BY fOriginalIndex, fIndex";
|
---|
76 |
|
---|
77 | $result0=mysql_query($query0, $db_id);
|
---|
78 |
|
---|
79 | if ($_GET["fGetValCase"]==1)
|
---|
80 | {
|
---|
81 | printf("<button onClick='ShowCurrent();' id='showcurrent' style='display:none'>Show Current</button>\n");
|
---|
82 | printf("<button onClick='ShowAll();' id='showall' style='display:inline'>Show History</button>\n");
|
---|
83 | printf("<button onClick='addRow(3, \"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals' style='display:inline'>Add Value</button>\n",
|
---|
84 | $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max, $descr);
|
---|
85 | }
|
---|
86 | //checkboxes to show/hide part of the table
|
---|
87 | printf("Show:\n");
|
---|
88 | printf("<input type='checkbox' id='sh_indices1' onclick='ShowHide(\"indices\", \"sh_indices\", 1);'>indices\n");
|
---|
89 | printf("<input type='checkbox' id='sh_validsince1' onclick='ShowHide(\"validsince\", \"sh_validsince\", 1);'>validsince\n");
|
---|
90 | printf("<input type='checkbox' id='sh_user1' onclick='ShowHide(\"user\", \"sh_user\", 1);'>user\n");
|
---|
91 |
|
---|
92 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
93 | $generalshowhide='';
|
---|
94 | else
|
---|
95 | $generalshowhide='none';
|
---|
96 |
|
---|
97 | printf("<table font-size='-1' border='0' cellspacing='5px' width='100%%'><tbody id='valtable%s'>\n", $_GET["fGetValCase"]);
|
---|
98 | printf("<tr>");
|
---|
99 | //printf("<th class='indices%d' style='display:%s'>Idx/Orig/Ctr</th>\n",$_GET["fGetValCase"], $generalshowhide);
|
---|
100 | //printf("<th class='validsince%d' style='display:%s'>Valid since</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
101 | printf("<th class='indices%d' style='display:none'>Idx/Orig/Ctr</th>\n",$_GET["fGetValCase"]);
|
---|
102 | printf("<th class='validsince%d' style='display:none'>Valid since</th>\n", $_GET["fGetValCase"]);
|
---|
103 | printf("<th>Program</th>\n");
|
---|
104 | //printf("<th>Key</th>\n");
|
---|
105 | printf("<th>Key1</th>\n");
|
---|
106 | printf("<th>Key2</th>\n");
|
---|
107 | printf("<th>Value</th>\n");
|
---|
108 | printf("<th>Type</th>\n");
|
---|
109 | printf("<th class='minimum%d' style='display:%s'>Min</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
110 | printf("<th class='maximum%d' style='display:%s'>Max</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
111 | printf("<th class='description%d' style='display:%s'>Description</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
112 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
113 | printf("<th>Action</th>\n");
|
---|
114 | //printf("<th class='user%d' style='display:%s'>User</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
115 | printf("<th class='user%d' style='display:none'>User</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
116 | printf("</tr>\n");
|
---|
117 | $maxindex=0;
|
---|
118 | if ($result0)
|
---|
119 | while ($row0 = mysql_fetch_row($result0))
|
---|
120 | {
|
---|
121 | if ($_GET["fGetValCase"]==1)
|
---|
122 | {
|
---|
123 | if ($row0[6]==$counter)
|
---|
124 | printf("<tr id='new%s' style='display:' bgcolor='#E2E2E2'>\n", $row0[0]);
|
---|
125 | else
|
---|
126 | printf("<tr id='old%s' style='display:none' bgcolor='#EBEBEB'>\n", $row0[0]);
|
---|
127 | }
|
---|
128 | else
|
---|
129 | printf("<tr id='%scompare%s' style='display:' bgcolor='white'>\n", $_GET["fGetValCase"], $row0[12]);
|
---|
130 |
|
---|
131 | //printf("<td class='indices%d' style='display:%s'> %s / %s / %s <div id='%dorigindex%s' style='display:none'>%s</div> </td>\n",
|
---|
132 | // $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[12], $row0[6], $_GET["fGetValCase"], $row0[0], $row0[12]);
|
---|
133 | printf("<td class='indices%d' style='display:none'> %s / %s / %s <div id='%dorigindex%s' style='display:none'>%s</div> </td>\n",
|
---|
134 | $_GET["fGetValCase"], $row0[0], $row0[12], $row0[6], $_GET["fGetValCase"], $row0[0], $row0[12]);
|
---|
135 | //valid from
|
---|
136 | //if (strcmp('0000-00-00 00:00:00', $row0[1])==0)
|
---|
137 | // printf("<td class='validsince%d' style='display:%s' id='notyetvalid%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[1]);
|
---|
138 | //else
|
---|
139 | // printf("<td class='validsince%d' style='display:%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[1]);
|
---|
140 | if (strcmp('0000-00-00 00:00:00', $row0[1])==0)
|
---|
141 | printf("<td class='validsince%d' style='display:none' id='notyetvalid%s'> %s </td>\n", $_GET["fGetValCase"], $row0[0], $row0[1]);
|
---|
142 | else
|
---|
143 | printf("<td class='validsince%d' style='display:none'> %s </td>\n", $_GET["fGetValCase"], $row0[1]);
|
---|
144 | //program
|
---|
145 | printf("<td id='prog%s'>%s</td>\n", $row0[0], $row0[2]);
|
---|
146 | //keys
|
---|
147 | //printf("<td id='key%s'>%s</td>\n", $row0[0], $row0[3]);
|
---|
148 | printf("<td id='1key%s'>%s</td>\n", $row0[0], $row0[10]);
|
---|
149 | printf("<td id='2key%s'>%s</td>\n", $row0[0], $row0[11]);
|
---|
150 | //value
|
---|
151 | printf("<td align='right' id='val%s'>%s</td>\n", $row0[0], $row0[4]);
|
---|
152 | //type
|
---|
153 | printf("<td id='type%s'>%s</td>\n", $row0[0], $row0[7]);
|
---|
154 | //min
|
---|
155 | printf("<td class='minimum%d' style='display:%s' id='min%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[8]);
|
---|
156 | //max
|
---|
157 | printf("<td class='maximum%d' style='display:%s' id='max%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[9]);
|
---|
158 | //descripton
|
---|
159 | printf("<td class='description%d' style='display:%s' id='descr%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[5]);
|
---|
160 | //action
|
---|
161 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
162 | {
|
---|
163 | if ($row0[6]==$counter)
|
---|
164 | {
|
---|
165 | printf("<td id='action%s'>\n", $row0[0]);
|
---|
166 | printf("<input type='button' value='Edit' onclick='EditRow(\"%s\")'>\n", $row0[0]);
|
---|
167 | printf("<input type='button' value='Copy Key' onclick='addRow(2,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='copyval' style='display:inline'>\n",
|
---|
168 | $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max, $descr);
|
---|
169 | //missing here descr(, key1, key2, val?)
|
---|
170 | // in po.js: add descr, key1, key2, min, max in AddRow
|
---|
171 | printf("</td>\n");
|
---|
172 | }
|
---|
173 | else
|
---|
174 | printf("<td id='action%s'></td>\n", $row0[0]);
|
---|
175 | }
|
---|
176 | //user
|
---|
177 | //printf("<td class='user%d' style='display:%s' id='user%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[13]);
|
---|
178 | printf("<td class='user%d' style='display:none' id='user%s'>%s</td>\n", $_GET["fGetValCase"], $row0[0], $row0[13]);
|
---|
179 | printf("</tr>\n");
|
---|
180 | if ($row0[0]>$maxindex)
|
---|
181 | $maxindex=$row0[0];
|
---|
182 | }
|
---|
183 | printf("</tbody></table>\n");
|
---|
184 | if ($_GET["fGetValCase"]==1)
|
---|
185 | {
|
---|
186 | printf("<button onClick='ShowCurrent();' id='showcurrent2' style='display:none'>Show Current</button>\n");
|
---|
187 | printf("<button onClick='ShowAll();' id='showall2' style='display:inline'>Show History</button>\n");
|
---|
188 | printf("<button onClick='addRow(3,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals2' style='display:inline'>Add Value</button>\n",
|
---|
189 | $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max, $descr);
|
---|
190 | }
|
---|
191 | /*
|
---|
192 | else
|
---|
193 | {
|
---|
194 | printf("Show:\n");
|
---|
195 | printf("<input type='checkbox' id='sh_indices%d' onclick='ShowHide(\"indices\", \"sh_indices\", %d);'>indices\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
196 | printf("<input type='checkbox' id='sh_validsince%d' onclick='ShowHide(\"validsince\", \"sh_validsince\", %d);'>validsince\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
197 | printf("<input type='checkbox' id='sh_descr%d' onclick='ShowHide(\"description\", \"sh_descr\", %d);'>description\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
198 | printf("<input type='checkbox' id='sh_min%d' onclick='ShowHide(\"minimum\", \"sh_min\", %d);'>min\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
199 | printf("<input type='checkbox' id='sh_max%d' onclick='ShowHide(\"maximum\", \"sh_max\", %d);'>max\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
200 | }
|
---|
201 | */
|
---|
202 |
|
---|
203 | if ($_GET["fGetValCase"]==3)
|
---|
204 | printf("<div id='maxindex3' style='display:none'>%s</div>\n", $maxindex);
|
---|
205 | else
|
---|
206 | printf("<div id='maxindex' style='display:none'>%s</div>\n", $maxindex);
|
---|
207 |
|
---|
208 | if ($result0)
|
---|
209 | mysql_free_result($result0);
|
---|
210 |
|
---|
211 | mysql_close($db_id);
|
---|
212 |
|
---|
213 | ini_set("display_errors", "Off");
|
---|
214 | ini_set("mysql.trace_mode", "Off");
|
---|
215 | }
|
---|
216 | ?>
|
---|