Index: trunk/www/db_po/get_date.php
===================================================================
--- trunk/www/db_po/get_date.php	(revision 11502)
+++ trunk/www/db_po/get_date.php	(revision 11502)
@@ -0,0 +1,126 @@
+<?php
+{
+    ini_set("display_errors", "On");
+    ini_set("mysql.trace_mode", "On");
+
+    if (empty($_GET["fDateValue"]))
+    {
+        echo "Please give the date value.<br>";
+        return;
+    }
+    if (empty($_GET["fDateName"]))
+    {
+        echo "Please give the date name.<br>";
+        return;
+    }
+    if (empty($_GET["fIdx"]))
+    {
+        echo "Please give the idx.<br>";
+        return;
+    }
+    if (empty($_GET["fDateValuePrev"]))
+        $_GET["fDateValuePrev"]="";
+
+    include("db.php");
+    $db_id = mysql_pconnect($host, $user, $pw);
+    if ($db_id==FALSE)
+    {
+        printf("mysql_connect returned the following error: %s\n", mysql_error());
+        die("");
+    }
+    mysql_select_db($db);
+
+    if (strcmp("year",$_GET["fDateName"])==0)
+    {
+        $identifier1="";
+        $identifier2="Y";
+        $newdatename="month";
+        if (strcmp($_GET["fDateValue"],"empty")==0)
+            $_GET["fDateValue"]="all";
+        if (strcmp($_GET["fDateValuePrev"],"empty")==0)
+            $_GET["fDateValuePrev"]="all";
+    }
+    if (strcmp("month",$_GET["fDateName"])==0)
+    {
+        $identifier1="Y";
+        $identifier2="m";
+        $newdatename="day";
+    }
+    if (strcmp("day",$_GET["fDateName"])==0)
+    {
+        $identifier1="m";
+        $identifier2="d";
+        $newdatename="hour";
+    }
+    if (strcmp("hour",$_GET["fDateName"])==0)
+    {
+        $identifier1="d";
+        $identifier2="H";
+        $newdatename="min";
+    }
+    if (strcmp("min",$_GET["fDateName"])==0)
+    {
+        $identifier1="H";
+        $identifier2="i";
+        $newdatename="sec";
+    }
+    if (strcmp("sec",$_GET["fDateName"])==0)
+    {
+        $identifier1="i";
+        $identifier2="s";
+        $newdatename="";
+    }
+
+    if (strcmp($_GET["fDateValuePrev"],"empty")!=0)
+    {
+        $query0 ="SELECT ";
+        $query0.=" Date_Format(fValidFrom, '%". $identifier2."') as valid ";
+        $query0.=" FROM History ";
+        if (empty($identifier1))
+            $query0.=" WHERE NOT fValidFrom='0000-00-00 00:00:00' ";
+        else
+            $query0.=" WHERE Date_Format(fValidFrom, '%". $identifier1."')=".$_GET["fDateValuePrev"];
+        $query0.=" GROUP BY valid";
+        $result0=mysql_query($query0, $db_id);
+    }
+    //echo $_GET["fDateValuePrev"];
+
+    //echo $query0;
+    if (empty($newdatename))
+        printf("<select id='%s%d'>\n", $_GET["fDateName"], $_GET["fIdx"]);
+    else
+    {
+        //if (empty($identifier1))
+        //{
+            printf("<select id='%s%d' onchange=\"get_dates('%s', this.value, this.value, %d, 'yes')\">\n",
+                   $_GET["fDateName"], $_GET["fIdx"], $newdatename, $_GET["fIdx"]);
+        //}
+        //else
+        //{
+        //    printf("<select id='%s%d' onchange=\"get_dates('%s', this.value, '%s', %d, 'yes')\">\n",
+        //           $_GET["fDateName"], $_GET["fIdx"], $newdatename, $_GET["fDateValuePrev"], $_GET["fIdx"]);
+        //}
+    }
+    if (strcmp($_GET["fDateValue"],"empty")!=0)
+        printf("<option value='empty'>%s</option>\n", $_GET["fDateName"]);
+    else
+        printf("<option value='empty'>-</option>\n");
+    if (strcmp($_GET["fDateValuePreV"],"empty")!=0)
+    {
+        while ($row0 = mysql_fetch_row($result0))
+        {
+            if (strcmp($row0[0],$_GET["fDateValue"])==0)
+                printf("<option value='%s' selected>%s </option>\n", $row0[0], $row0[0]);
+            else
+                printf("<option value='%s'>%s </option>\n", $row0[0], $row0[0]);
+        }
+        mysql_free_result($result0);
+    }
+    printf("</select>\n");
+
+    mysql_close($db_id);
+
+    ini_set("display_errors", "Off");
+    ini_set("mysql.trace_mode", "Off");
+}
+?>
