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 FROM ProgramOption WHERE Concat(fKey1,fKey2)='".$_GET["fKey"]."'";
|
---|
48 | $result2=mysql_query($query2, $db_id);
|
---|
49 | $row2 = mysql_fetch_row($result2);
|
---|
50 | $key1=$row2[0];
|
---|
51 | $key2=$row2[1];
|
---|
52 | $type=$row2[2];
|
---|
53 | $min=$row2[3];
|
---|
54 | $max=$row2[4];
|
---|
55 | mysql_free_result($result2);
|
---|
56 |
|
---|
57 | $query0 ="SELECT fIndex, fValidFrom, fProgram, Concat(fKey1,fKey2), fValue, ";
|
---|
58 | $query0.="fDescription, fCounter, fType, fMin, fMax, fKey1, SUBSTRING(fKey2,2), ";
|
---|
59 | $query0.="if(fOriginalIndex=0, fIndex, fOriginalIndex), fUser FROM ProgramOption ";
|
---|
60 | $query0.="WHERE 1=1 ";
|
---|
61 | if (strcmp($_GET["fKey"],"all")!=0)
|
---|
62 | $query0.="AND Concat(fKey1,fKey2)='".$_GET["fKey"]."' ";
|
---|
63 | if (strcmp($_GET["fProgram"],"all")!=0)
|
---|
64 | $query0.="AND fProgram='".$_GET["fProgram"]."' ";
|
---|
65 | if ($_GET["fGetValCase"]!=1)
|
---|
66 | {
|
---|
67 | $query0.="AND NOT isnull(fValue) ";
|
---|
68 | $query0.="AND fCounter>=".$counter;
|
---|
69 | if ($_GET["fStatusDate"]!="")
|
---|
70 | $query0.=" AND (fValidFrom < '".$_GET["fStatusDate"]."' OR fValidFrom like '".$_GET["fStatusDate"]."%') ";
|
---|
71 | }
|
---|
72 | $query0.=" ORDER BY fOriginalIndex, fIndex";
|
---|
73 |
|
---|
74 | $result0=mysql_query($query0, $db_id);
|
---|
75 |
|
---|
76 | if ($_GET["fGetValCase"]==1)
|
---|
77 | {
|
---|
78 | printf("<button onClick='ShowCurrent();' id='showcurrent' style='display:none'>Show Current</button>\n");
|
---|
79 | printf("<button onClick='ShowAll();' id='showall' style='display:inline'>Show History</button>\n");
|
---|
80 | printf("<button onClick='addRow(3, \"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals' style='display:inline'>Add Value</button>\n",
|
---|
81 | $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max);
|
---|
82 | }
|
---|
83 |
|
---|
84 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
85 | $generalshowhide='';
|
---|
86 | else
|
---|
87 | $generalshowhide='none';
|
---|
88 |
|
---|
89 | printf("<table font-size='-1' border='0' cellspacing='5px' width='100%%'><tbody id='valtable%s'>\n", $_GET["fGetValCase"]);
|
---|
90 | printf("<tr>");
|
---|
91 | printf("<th class='indices%d' style='display:%s'>Idx/Orig/Ctr</th>\n",$_GET["fGetValCase"], $generalshowhide);
|
---|
92 | printf("<th class='validsince%d' style='display:%s'>Valid since</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
93 | printf("<th>Program</th>\n");
|
---|
94 | //printf("<th>Key</th>\n");
|
---|
95 | printf("<th>Key1</th>\n");
|
---|
96 | printf("<th>Key2</th>\n");
|
---|
97 | printf("<th>Value</th>\n");
|
---|
98 | printf("<th>Type</th>\n");
|
---|
99 | printf("<th class='minimum%d' style='display:%s'>Min</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
100 | printf("<th class='maximum%d' style='display:%s'>Max</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
101 | printf("<th class='description%d' style='display:%s'>Description</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
102 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
103 | printf("<th>Action</th>\n");
|
---|
104 | printf("<th class='user%d' style='display:%s'>User</th>\n", $_GET["fGetValCase"], $generalshowhide);
|
---|
105 | printf("</tr>\n");
|
---|
106 | $maxindex=0;
|
---|
107 | if ($result0)
|
---|
108 | while ($row0 = mysql_fetch_row($result0))
|
---|
109 | {
|
---|
110 | if ($_GET["fGetValCase"]==1)
|
---|
111 | {
|
---|
112 | if ($row0[6]==$counter)
|
---|
113 | printf("<tr id='new%s' style='display:' bgcolor='#E2E2E2'>\n", $row0[0]);
|
---|
114 | else
|
---|
115 | printf("<tr id='old%s' style='display:none' bgcolor='#EBEBEB'>\n", $row0[0]);
|
---|
116 | }
|
---|
117 | else
|
---|
118 | printf("<tr id='%scompare%s' style='display:' bgcolor='white'>\n", $_GET["fGetValCase"], $row0[12]);
|
---|
119 |
|
---|
120 | printf("<td class='indices%d' style='display:%s'> %s / %s / %s <div id='%dorigindex%s' style='display:none'>%s</div> </td>\n",
|
---|
121 | $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[12], $row0[6], $_GET["fGetValCase"], $row0[0], $row0[12]);
|
---|
122 | //valid from
|
---|
123 | if (strcmp('0000-00-00 00:00:00', $row0[1])==0)
|
---|
124 | printf("<td class='validsince%d' style='display:%s' id='notyetvalid%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[1]);
|
---|
125 | else
|
---|
126 | printf("<td class='validsince%d' style='display:%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[1]);
|
---|
127 | //program
|
---|
128 | printf("<td id='prog%s'>%s</td>\n", $row0[0], $row0[2]);
|
---|
129 | //keys
|
---|
130 | //printf("<td id='key%s'>%s</td>\n", $row0[0], $row0[3]);
|
---|
131 | printf("<td id='1key%s'>%s</td>\n", $row0[0], $row0[10]);
|
---|
132 | printf("<td id='2key%s'>%s</td>\n", $row0[0], $row0[11]);
|
---|
133 | //value
|
---|
134 | printf("<td align='right' id='val%s'>%s</td>\n", $row0[0], $row0[4]);
|
---|
135 | //type
|
---|
136 | printf("<td id='type%s'>%s</td>\n", $row0[0], $row0[7]);
|
---|
137 | //min
|
---|
138 | printf("<td class='minimum%d' style='display:%s' id='min%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[8]);
|
---|
139 | //max
|
---|
140 | printf("<td class='maximum%d' style='display:%s' id='max%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[9]);
|
---|
141 | //descripton
|
---|
142 | printf("<td class='description%d' style='display:%s' id='descr%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[5]);
|
---|
143 | //action
|
---|
144 | if ($_GET["fGetValCase"]==1)//show only in edit mode
|
---|
145 | {
|
---|
146 | if ($row0[6]==$counter)
|
---|
147 | printf("<td id='action%s'><input type='button' value='Edit' onclick='EditRow(\"%s\")'></td>\n", $row0[0], $row0[0]);
|
---|
148 | else
|
---|
149 | printf("<td id='action%s'></td>\n", $row0[0]);
|
---|
150 | }
|
---|
151 | //user
|
---|
152 | printf("<td class='user%d' style='display:%s' id='user%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[13]);
|
---|
153 | printf("</tr>\n");
|
---|
154 | if ($row0[0]>$maxindex)
|
---|
155 | $maxindex=$row0[0];
|
---|
156 | }
|
---|
157 | printf("</tbody></table>\n");
|
---|
158 | if ($_GET["fGetValCase"]==1)
|
---|
159 | {
|
---|
160 | printf("<button onClick='ShowCurrent();' id='showcurrent2' style='display:none'>Show Current</button>\n");
|
---|
161 | printf("<button onClick='ShowAll();' id='showall2' style='display:inline'>Show History</button>\n");
|
---|
162 | printf("<button onClick='addRow(3,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals2' style='display:inline'>Add Value</button>\n",
|
---|
163 | $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max);
|
---|
164 | }
|
---|
165 | /*
|
---|
166 | else
|
---|
167 | {
|
---|
168 | printf("Show:\n");
|
---|
169 | printf("<input type='checkbox' id='sh_indices%d' onclick='ShowHide(\"indices\", \"sh_indices\", %d);'>indices\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
170 | printf("<input type='checkbox' id='sh_validsince%d' onclick='ShowHide(\"validsince\", \"sh_validsince\", %d);'>validsince\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
171 | printf("<input type='checkbox' id='sh_descr%d' onclick='ShowHide(\"description\", \"sh_descr\", %d);'>description\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
172 | printf("<input type='checkbox' id='sh_min%d' onclick='ShowHide(\"minimum\", \"sh_min\", %d);'>min\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
173 | printf("<input type='checkbox' id='sh_max%d' onclick='ShowHide(\"maximum\", \"sh_max\", %d);'>max\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
|
---|
174 | }
|
---|
175 | */
|
---|
176 |
|
---|
177 | if ($_GET["fGetValCase"]==3)
|
---|
178 | printf("<div id='maxindex3' style='display:none'>%s</div>\n", $maxindex);
|
---|
179 | else
|
---|
180 | printf("<div id='maxindex' style='display:none'>%s</div>\n", $maxindex);
|
---|
181 |
|
---|
182 | if ($result0)
|
---|
183 | mysql_free_result($result0);
|
---|
184 |
|
---|
185 | mysql_close($db_id);
|
---|
186 |
|
---|
187 | ini_set("display_errors", "Off");
|
---|
188 | ini_set("mysql.trace_mode", "Off");
|
---|
189 | }
|
---|
190 | ?>
|
---|