Changeset 11505 for trunk/www/db_po/get_values.php
- Timestamp:
- 07/21/11 11:24:15 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/db_po/get_values.php
r11353 r11505 4 4 ini_set("mysql.trace_mode", "On"); 5 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 } 6 14 if (empty($_GET["fKey"])) 7 15 { 8 echo "Please select a key. <br>";16 echo "Please select a key."; 9 17 return; 10 18 } 11 19 if (empty($_GET["fProgram"])) 12 20 { 13 echo "Please select a program. <br>";21 echo "Please select a program."; 14 22 return; 15 23 } 16 24 if (empty($_GET["fStatusDate"])) 25 $_GET["fStatusDate"]=""; 17 26 18 27 include("db.php"); … … 26 35 27 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 28 41 $result1=mysql_query($query1, $db_id); 29 42 $row1 = mysql_fetch_row($result1); 30 $ maxcount=$row1[0];31 //echo $maxcount;43 $counter=$row1[0]; 44 mysql_free_result($result1); 32 45 33 $query0 ="SELECT fIndex, fProgram, fKey, fValue, fDescription, fCounter FROM ProgramOption "; 34 $query0.="WHERE fKey='".$_GET["fKey"]."'"; 35 if ($_GET["fProgram"]!="all") 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) 36 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"; 37 69 38 70 $result0=mysql_query($query0, $db_id); 39 71 40 printf("<td valign='top'>Please edit:</td>\n"); 41 printf("<td>\n"); 42 printf("<button onClick='ShowCurrent();' id='showcurrent' style='display:none'>Show Current</button>\n"); 43 printf("<button onClick='ShowAll();' id='showall' style='display:inline'>Show All</button>\n"); 44 printf("<button onClick='addRow(\"%s\",\"%s\");' id='addrow' style='display:inline'>Add Row</button>\n", $_GET["fProgram"], $_GET["fKey"]); 45 printf("<table border='1' width='100px' height='100px'><tbody id='valtable'>\n"); 46 printf("<tr><th>Index / Counter</th><th>Program</th><th>Key</th><th>Value</th><th>Description</th>"); 47 printf("<th>Action</th></tr>\n"); 48 while ($row0 = mysql_fetch_row($result0)) 72 if ($_GET["fGetValCase"]==1) 49 73 { 50 if ($row0[5]==$maxcount) 51 printf("<tr id='new%s' style='display:'>\n", $row0[0]); 52 else 53 printf("<tr id='old%s' style='display:none'>\n", $row0[0]); 54 printf("<td> %s / %s</td>\n", $row0[0], $row0[5]); 55 printf("<td id='prog%s'>%s</td>\n", $row0[0], $row0[1]); 56 printf("<td id='key%s'>%s</td>\n", $row0[0], $row0[2]); 57 printf("<td align='right' id='val%s'>%s</td>\n", $row0[0], $row0[3]); 58 printf("<td id='descr%s'>%s</td>\n", $row0[0], $row0[4]); 59 if ($row0[5]==$maxcount) 60 printf("<td id='action%s'><input type='button' value='Edit' onclick='EditRow(\"%s\")'></td>\n</tr>\n", $row0[0], $row0[0]); 61 else 62 printf("<td id='action%s'></td>\n</tr>\n", $row0[0]); 63 $maxindex=$row0[0]; 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); 64 78 } 65 printf("<div id='addline'></div>"); 66 printf("</tbody></table>\n<br>\n"); 67 printf("<div id='maxindex' style='display:none'>%s</div>\n", $maxindex); 68 printf("</td>\n"); 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]); 69 111 70 mysql_free_result($result0); 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); 71 162 72 163 mysql_close($db_id);
Note:
See TracChangeset
for help on using the changeset viewer.