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

Last change on this file since 11589 was 11505, checked in by Daniela Dorner, 13 years ago
added plenty of new features to view and edit the configuration database
  • Property svn:executable set to *
File size: 7.1 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 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 mysql_free_result($result2);
54
55 $query0 ="SELECT fIndex, fValidFrom, fProgram, Concat(fKey1,fKey2), fValue, fDescription, fCounter, fType, fMin, fMax, fKey1, SUBSTRING(fKey2,2), if(fOriginalIndex=0, fIndex, fOriginalIndex) FROM ProgramOption ";
56 $query0.="WHERE 1=1 ";
57 if (strcmp($_GET["fKey"],"all")!=0)
58 $query0.="AND Concat(fKey1,fKey2)='".$_GET["fKey"]."' ";
59 if (strcmp($_GET["fProgram"],"all")!=0)
60 $query0.="AND fProgram='".$_GET["fProgram"]."' ";
61 if ($_GET["fGetValCase"]!=1)
62 {
63 $query0.="AND NOT isnull(fValue) ";
64 $query0.="AND fCounter>=".$counter;
65 if ($_GET["fStatusDate"]!="")
66 $query0.=" AND (fValidFrom < '".$_GET["fStatusDate"]."' OR fValidFrom like '".$_GET["fStatusDate"]."%') ";
67 }
68 $query0.=" ORDER BY fOriginalIndex, fIndex";
69
70 $result0=mysql_query($query0, $db_id);
71
72 if ($_GET["fGetValCase"]==1)
73 {
74 printf("<button onClick='ShowCurrent();' id='showcurrent' style='display:none'>Show Current</button>\n");
75 printf("<button onClick='ShowAll();' id='showall' style='display:inline'>Show History</button>\n");
76 printf("<button onClick='addRow(3, \"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals' style='display:inline'>Add Value</button>\n",
77 $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type);
78 }
79 printf("<table font-size='-1' border='1' width='100px' height='100px'><tbody id='valtable%s'>\n", $_GET["fGetValCase"]);
80 printf("<tr>");
81 printf("<th>Index / Orig / Counter</th>\n");
82 printf("<th>Valid since</th>\n");
83 printf("<th>Program</th>\n");
84 //printf("<th>Key</th>\n");
85 printf("<th>Key1</th>\n");
86 printf("<th>Key2</th>\n");
87 printf("<th>Value</th>\n");
88 printf("<th>Type</th>\n");
89 if ($_GET["fGetValCase"]==1)//show only in edit mode
90 printf("<th class='description%d'>Description</th>\n", $_GET["fGetValCase"]);
91 else
92 printf("<th class='description%d' style='display:none'>Description</th>\n", $_GET["fGetValCase"]);
93 if ($_GET["fGetValCase"]==1)//show only in edit mode
94 printf("<th>Action</th>\n");
95 printf("<th>Min</th>\n");
96 printf("<th>Max</th>\n");
97 printf("</tr>\n");
98 $maxindex=0;
99 if ($result0)
100 while ($row0 = mysql_fetch_row($result0))
101 {
102 if ($_GET["fGetValCase"]==1)
103 {
104 if ($row0[6]==$counter)
105 printf("<tr id='new%s' style='display:'>\n", $row0[0]);
106 else
107 printf("<tr id='old%s' style='display:none'>\n", $row0[0]);
108 }
109 else
110 printf("<tr id='%scompare%s' style='display:'>\n", $_GET["fGetValCase"], $row0[12]);
111
112 printf("<td> %s / %s / %s <div id='%dorigindex%s' style='display:none'>%s</div> </td>\n",
113 $row0[0], $row0[12], $row0[6], $_GET["fGetValCase"], $row0[0], $row0[12]);
114 if (strcmp('0000-00-00 00:00:00', $row0[1])==0)
115 printf("<td id='notyetvalid%s'> %s </td>\n", $row0[0], $row0[1]);
116 else
117 printf("<td> %s </td>\n", $row0[1]);
118 printf("<td id='prog%s'>%s</td>\n", $row0[0], $row0[2]);
119 //printf("<td id='key%s'>%s</td>\n", $row0[0], $row0[3]);
120 printf("<td id='1key%s'>%s</td>\n", $row0[0], $row0[10]);
121 printf("<td id='2key%s'>%s</td>\n", $row0[0], $row0[11]);
122 printf("<td align='right' id='val%s'>%s</td>\n", $row0[0], $row0[4]);
123 printf("<td id='type%s'>%s</td>\n", $row0[0], $row0[7]);
124 if ($_GET["fGetValCase"]==1)//show only in edit mode
125 printf("<td class='description%d' id='descr%s'>%s</td>\n", $_GET["fGetValCase"], $row0[0], $row0[5]);
126 else
127 printf("<td class='description%d' style='display:none' id='descr%s'>%s</td>\n", $_GET["fGetValCase"], $row0[0], $row0[5]);
128 if ($_GET["fGetValCase"]==1)//show only in edit mode
129 {
130 if ($row0[6]==$counter)
131 printf("<td id='action%s'><input type='button' value='Edit' onclick='EditRow(\"%s\")'></td>\n", $row0[0], $row0[0]);
132 else
133 printf("<td id='action%s'></td>\n", $row0[0]);
134 }
135 printf("<td id='min%s'>%s</td>\n", $row0[0], $row0[8]);
136 printf("<td id='max%s'>%s</td>\n", $row0[0], $row0[9]);
137 printf("</tr>\n");
138 if ($row0[0]>$maxindex)
139 $maxindex=$row0[0];
140 }
141 printf("</tbody></table>\n");
142 if ($_GET["fGetValCase"]==1)
143 {
144 printf("<button onClick='ShowCurrent();' id='showcurrent2' style='display:none'>Show Current</button>\n");
145 printf("<button onClick='ShowAll();' id='showall2' style='display:inline'>Show History</button>\n");
146 printf("<button onClick='addRow(3,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\");' id='addrowvals2' style='display:inline'>Add Value</button>\n",
147 $_GET["fProgram"], $_GET["fKey"], $key1, $key2, $type);
148 }
149 else
150 {
151 printf("<button onClick='HideDescription(%d);' id='hidedescr%d' style='display:none'>Hide Description</button>\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
152 printf("<button onClick='ShowDescription(%d);' id='showdescr%d' style='display:'>Show Description</button>\n", $_GET["fGetValCase"], $_GET["fGetValCase"]);
153 }
154
155 if ($_GET["fGetValCase"]==3)
156 printf("<div id='maxindex3' style='display:none'>%s</div>\n", $maxindex);
157 else
158 printf("<div id='maxindex' style='display:none'>%s</div>\n", $maxindex);
159
160 if ($result0)
161 mysql_free_result($result0);
162
163 mysql_close($db_id);
164
165 ini_set("display_errors", "Off");
166 ini_set("mysql.trace_mode", "Off");
167}
168?>
Note: See TracBrowser for help on using the repository browser.