source: trunk/www/db_po/get_values.php@ 12445

Last change on this file since 12445 was 12445, checked in by Daniela Dorner, 13 years ago
changed sorting of po list to fix bug in compare
  • Property svn:executable set to *
File size: 11.5 KB
Line 
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) as MyIndex, 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 MyIndex ";
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 if ($_GET["fGetValCase"]==1)//show only in edit mode
88 {
89 printf("Show:\n");
90 printf("<input type='checkbox' id='sh_indices1' onclick='ShowHide(\"indices\", \"sh_indices\", 1);'>indices\n");
91 printf("<input type='checkbox' id='sh_validsince1' onclick='ShowHide(\"validsince\", \"sh_validsince\", 1);'>validsince\n");
92 printf("<input type='checkbox' id='sh_user1' onclick='ShowHide(\"user\", \"sh_user\", 1);'>user\n");
93 }
94
95 if ($_GET["fGetValCase"]==1)//show only in edit mode
96 $generalshowhide='';
97 else
98 $generalshowhide='none';
99
100 printf("<table font-size='-1' border='0' cellspacing='3px' width='100%%'><tbody id='valtable%s'>\n", $_GET["fGetValCase"]);
101 printf("<tr>");
102 //printf("<th class='indices%d' style='display:%s'>Idx/Orig/Ctr</th>\n",$_GET["fGetValCase"], $generalshowhide);
103 //printf("<th class='validsince%d' style='display:%s'>Valid since</th>\n", $_GET["fGetValCase"], $generalshowhide);
104 printf("<th class='indices%d' style='display:none'>Idx/Orig/Ctr</th>\n",$_GET["fGetValCase"]);
105 printf("<th class='validsince%d' style='display:none'>Valid since</th>\n", $_GET["fGetValCase"]);
106 printf("<th>Program</th>\n");
107 //printf("<th>Key</th>\n");
108 printf("<th>Key1</th>\n");
109 printf("<th>Key2</th>\n");
110 printf("<th>Value</th>\n");
111 printf("<th>Type</th>\n");
112 printf("<th class='minimum%d' style='display:%s'>Min</th>\n", $_GET["fGetValCase"], $generalshowhide);
113 printf("<th class='maximum%d' style='display:%s'>Max</th>\n", $_GET["fGetValCase"], $generalshowhide);
114 printf("<th class='description%d' style='display:%s'>Description</th>\n", $_GET["fGetValCase"], $generalshowhide);
115 if ($_GET["fGetValCase"]==1)//show only in edit mode
116 printf("<th>Action</th>\n");
117 //printf("<th class='user%d' style='display:%s'>User</th>\n", $_GET["fGetValCase"], $generalshowhide);
118 printf("<th class='user%d' style='display:none'>User</th>\n", $_GET["fGetValCase"], $generalshowhide);
119 printf("</tr>\n");
120 $maxindex=0;
121 if ($result0)
122 while ($row0 = mysql_fetch_row($result0))
123 {
124 if ($_GET["fGetValCase"]==1)
125 {
126 if ($row0[6]==$counter)
127 printf("<tr id='new%s' style='display:' bgcolor='#E2E2E2'>\n", $row0[0]);
128 else
129 printf("<tr id='old%s' style='display:none' bgcolor='#EBEBEB'>\n", $row0[0]);
130 }
131 else
132 {
133 if ($_GET["fGetValCase"]==2)
134 printf("<tr id='%scompare%s' style='display:' bgcolor='FAFFFA'>\n", $_GET["fGetValCase"], $row0[12]);
135 if ($_GET["fGetValCase"]==3)
136 printf("<tr id='%scompare%s' style='display:' bgcolor='FAFAFF'>\n", $_GET["fGetValCase"], $row0[12]);
137 }
138
139 //printf("<td class='indices%d' style='display:%s'> %s / %s / %s <div id='%dorigindex%s' style='display:none'>%s</div> </td>\n",
140 // $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[12], $row0[6], $_GET["fGetValCase"], $row0[0], $row0[12]);
141 printf("<td class='indices%d' style='display:none'> %s / %s / %s <div id='%dorigindex%s' style='display:none'>%s</div> </td>\n",
142 $_GET["fGetValCase"], $row0[0], $row0[12], $row0[6], $_GET["fGetValCase"], $row0[0], $row0[12]);
143 //valid from
144 //if (strcmp('0000-00-00 00:00:00', $row0[1])==0)
145 // printf("<td class='validsince%d' style='display:%s' id='notyetvalid%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[1]);
146 //else
147 // printf("<td class='validsince%d' style='display:%s'> %s </td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[1]);
148 if (strcmp('0000-00-00 00:00:00', $row0[1])==0)
149 printf("<td class='validsince%d' style='display:none' id='notyetvalid%s'> %s </td>\n", $_GET["fGetValCase"], $row0[0], $row0[1]);
150 else
151 printf("<td class='validsince%d' style='display:none'> %s </td>\n", $_GET["fGetValCase"], $row0[1]);
152 //program
153 printf("<td id='prog%s'>%s</td>\n", $row0[0], $row0[2]);
154 //keys
155 //printf("<td id='key%s'>%s</td>\n", $row0[0], $row0[3]);
156 printf("<td id='1key%s'>%s</td>\n", $row0[0], $row0[10]);
157 printf("<td id='2key%s'>%s</td>\n", $row0[0], $row0[11]);
158 //value
159 // string -> align left
160 // rest -> align right
161 if (strcmp('string', $row0[7])==0)
162 printf("<td align='left' id='val%s' align='right'>%s</td>\n", $row0[0], $row0[4]);
163 else
164 printf("<td align='right' id='val%s' align='right'>%s</td>\n", $row0[0], $row0[4]);
165 //type
166 printf("<td id='type%s'>%s</td>\n", $row0[0], $row0[7]);
167 //min
168 printf("<td class='minimum%d' style='display:%s' id='min%s' align='right'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[8]);
169 //max
170 printf("<td class='maximum%d' style='display:%s' id='max%s' align='right'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[9]);
171 //descripton
172 printf("<td class='description%d' style='display:%s' id='descr%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[5]);
173 //action
174 if ($_GET["fGetValCase"]==1)//show only in edit mode
175 {
176 if ($row0[6]==$counter)
177 {
178 printf("<td id='action%s'>\n", $row0[0]);
179 printf("<input type='button' value='Edit' onclick='EditRow(\"%s\")'>\n", $row0[0]);
180 printf("<input type='button' value='Copy Key' onclick='addRow(2,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='copyval' style='display:inline'>\n",
181 $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max, $descr);
182 //missing here descr(, key1, key2, val?)
183 // in po.js: add descr, key1, key2, min, max in AddRow
184 printf("</td>\n");
185 }
186 else
187 printf("<td id='action%s'></td>\n", $row0[0]);
188 }
189 //user
190 //printf("<td class='user%d' style='display:%s' id='user%s'>%s</td>\n", $_GET["fGetValCase"], $generalshowhide, $row0[0], $row0[13]);
191 printf("<td class='user%d' style='display:none' id='user%s'>%s</td>\n", $_GET["fGetValCase"], $row0[0], $row0[13]);
192 printf("</tr>\n");
193 if ($row0[0]>$maxindex)
194 $maxindex=$row0[0];
195 }
196 printf("</tbody></table>\n");
197 if ($_GET["fGetValCase"]==1)
198 {
199 printf("<button onClick='ShowCurrent();' id='showcurrent2' style='display:none'>Show Current</button>\n");
200 printf("<button onClick='ShowAll();' id='showall2' style='display:inline'>Show History</button>\n");
201 printf("<button onClick='addRow(3,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals2' style='display:inline'>Add Value</button>\n",
202 $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type, $min, $max, $descr);
203 }
204 /*
205 else
206 {
207 printf("Show:\n");
208 printf("<input type='checkbox' id='sh_indices%d' onclick='ShowHide(\"indices\", \"sh_indices\", %d);'>indices\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
209 printf("<input type='checkbox' id='sh_validsince%d' onclick='ShowHide(\"validsince\", \"sh_validsince\", %d);'>validsince\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
210 printf("<input type='checkbox' id='sh_descr%d' onclick='ShowHide(\"description\", \"sh_descr\", %d);'>description\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
211 printf("<input type='checkbox' id='sh_min%d' onclick='ShowHide(\"minimum\", \"sh_min\", %d);'>min\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
212 printf("<input type='checkbox' id='sh_max%d' onclick='ShowHide(\"maximum\", \"sh_max\", %d);'>max\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
213 }
214 */
215
216 if ($_GET["fGetValCase"]==3)
217 printf("<div id='maxindex3' style='display:none'>%s</div>\n", $maxindex);
218 else
219 printf("<div id='maxindex' style='display:none'>%s</div>\n", $maxindex);
220
221 if ($result0)
222 mysql_free_result($result0);
223
224 mysql_close($db_id);
225
226 ini_set("display_errors", "Off");
227 ini_set("mysql.trace_mode", "Off");
228}
229?>
Note: See TracBrowser for help on using the repository browser.