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 |
|
---|
87 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
88 | $generalshowhide='';
|
---|
89 | else
|
---|
90 | $generalshowhide='none';
|
---|
91 |
|
---|
92 | printf("<table font-size='-1' border='0' cellspacing='5px' width='100%%'><tbody id='valtable%s'>\n", $_GET["fGetValCase"]);
|
---|
93 | printf("<tr>");
|
---|
94 | printf("<th class='indices%d' style='display:%s'>Idx/Orig/Ctr</th>\n",$_GET["fGetValCase"], $generalshowhide);
|
---|
95 | printf("<th class='validsince%d' style='display:%s'>Valid since</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
96 | printf("<th>Program</th>\n");
|
---|
97 | //printf("<th>Key</th>\n");
|
---|
98 | printf("<th>Key1</th>\n");
|
---|
99 | printf("<th>Key2</th>\n");
|
---|
100 | printf("<th>Value</th>\n");
|
---|
101 | printf("<th>Type</th>\n");
|
---|
102 | printf("<th class='minimum%d' style='display:%s'>Min</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
103 | printf("<th class='maximum%d' style='display:%s'>Max</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
104 | printf("<th class='description%d' style='display:%s'>Description</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
105 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
106 | printf("<th>Action</th>\n");
|
---|
107 | printf("<th class='user%d' style='display:%s'>User</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
108 | printf("</tr>\n");
|
---|
109 | $maxindex=0;
|
---|
110 | if ($result0)
|
---|
111 | while ($row0 = mysql_fetch_row($result0))
|
---|
112 | {
|
---|
113 | if ($_GET["fGetValCase"]==1)
|
---|
114 | {
|
---|
115 | if ($row0[6]==$counter)
|
---|
116 | printf("<tr id='new%s' style='display:' bgcolor='#E2E2E2'>\n", $row0[0]);
|
---|
117 | else
|
---|
118 | printf("<tr id='old%s' style='display:none' bgcolor='#EBEBEB'>\n", $row0[0]);
|
---|
119 | }
|
---|
120 | else
|
---|
121 | printf("<tr id='%scompare%s' style='display:' bgcolor='white'>\n", $_GET["fGetValCase"], $row0[12]);
|
---|
122 |
|
---|
123 | printf("<td class='indices%d' style='display:%s'> %s / %s / %s <div id='%dorigindex%s' style='display:none'>%s</div> </td>\n",
|
---|
124 | $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[12], $row0[6], $_GET["fGetValCase"], $row0[0], $row0[12]);
|
---|
125 | //valid from
|
---|
126 | if (strcmp('0000-00-00 00:00:00', $row0[1])==0)
|
---|
127 | printf("<td class='validsince%d' style='display:%s' id='notyetvalid%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[1]);
|
---|
128 | else
|
---|
129 | printf("<td class='validsince%d' style='display:%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[1]);
|
---|
130 | //program
|
---|
131 | printf("<td id='prog%s'>%s</td>\n", $row0[0], $row0[2]);
|
---|
132 | //keys
|
---|
133 | //printf("<td id='key%s'>%s</td>\n", $row0[0], $row0[3]);
|
---|
134 | printf("<td id='1key%s'>%s</td>\n", $row0[0], $row0[10]);
|
---|
135 | printf("<td id='2key%s'>%s</td>\n", $row0[0], $row0[11]);
|
---|
136 | //value
|
---|
137 | printf("<td align='right' id='val%s'>%s</td>\n", $row0[0], $row0[4]);
|
---|
138 | //type
|
---|
139 | printf("<td id='type%s'>%s</td>\n", $row0[0], $row0[7]);
|
---|
140 | //min
|
---|
141 | printf("<td class='minimum%d' style='display:%s' id='min%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[8]);
|
---|
142 | //max
|
---|
143 | printf("<td class='maximum%d' style='display:%s' id='max%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[9]);
|
---|
144 | //descripton
|
---|
145 | printf("<td class='description%d' style='display:%s' id='descr%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[5]);
|
---|
146 | //action
|
---|
147 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
148 | {
|
---|
149 | if ($row0[6]==$counter)
|
---|
150 | {
|
---|
151 | printf("<td id='action%s'>\n", $row0[0]);
|
---|
152 | printf("<input type='button' value='Edit' onclick='EditRow(\"%s\")'>\n", $row0[0]);
|
---|
153 | printf("<input type='button' value='Copy Key' onclick='addRow(2,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='copyval' style='display:inline'>\n",
|
---|
154 | $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max, $descr);
|
---|
155 | //missing here descr(, key1, key2, val?)
|
---|
156 | // in po.js: add descr, key1, key2, min, max in AddRow
|
---|
157 | printf("</td>\n");
|
---|
158 | }
|
---|
159 | else
|
---|
160 | printf("<td id='action%s'></td>\n", $row0[0]);
|
---|
161 | }
|
---|
162 | //user
|
---|
163 | printf("<td class='user%d' style='display:%s' id='user%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[13]);
|
---|
164 | printf("</tr>\n");
|
---|
165 | if ($row0[0]>$maxindex)
|
---|
166 | $maxindex=$row0[0];
|
---|
167 | }
|
---|
168 | printf("</tbody></table>\n");
|
---|
169 | if ($_GET["fGetValCase"]==1)
|
---|
170 | {
|
---|
171 | printf("<button onClick='ShowCurrent();' id='showcurrent2' style='display:none'>Show Current</button>\n");
|
---|
172 | printf("<button onClick='ShowAll();' id='showall2' style='display:inline'>Show History</button>\n");
|
---|
173 | printf("<button onClick='addRow(3,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals2' style='display:inline'>Add Value</button>\n",
|
---|
174 | $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max, $descr);
|
---|
175 | }
|
---|
176 | /*
|
---|
177 | else
|
---|
178 | {
|
---|
179 | printf("Show:\n");
|
---|
180 | printf("<input type='checkbox' id='sh_indices%d' onclick='ShowHide(\"indices\", \"sh_indices\", %d);'>indices\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
181 | printf("<input type='checkbox' id='sh_validsince%d' onclick='ShowHide(\"validsince\", \"sh_validsince\", %d);'>validsince\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
182 | printf("<input type='checkbox' id='sh_descr%d' onclick='ShowHide(\"description\", \"sh_descr\", %d);'>description\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
183 | printf("<input type='checkbox' id='sh_min%d' onclick='ShowHide(\"minimum\", \"sh_min\", %d);'>min\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
184 | printf("<input type='checkbox' id='sh_max%d' onclick='ShowHide(\"maximum\", \"sh_max\", %d);'>max\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
185 | }
|
---|
186 | */
|
---|
187 |
|
---|
188 | if ($_GET["fGetValCase"]==3)
|
---|
189 | printf("<div id='maxindex3' style='display:none'>%s</div>\n", $maxindex);
|
---|
190 | else
|
---|
191 | printf("<div id='maxindex' style='display:none'>%s</div>\n", $maxindex);
|
---|
192 |
|
---|
193 | if ($result0)
|
---|
194 | mysql_free_result($result0);
|
---|
195 |
|
---|
196 | mysql_close($db_id);
|
---|
197 |
|
---|
198 | ini_set("display_errors", "Off");
|
---|
199 | ini_set("mysql.trace_mode", "Off");
|
---|
200 | }
|
---|
201 | ?>
|
---|