source: trunk/www/db_po/get_date.php@ 14552

Last change on this file since 14552 was 13322, checked in by Daniela Dorner, 13 years ago
bugfix for date pulldowns
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1<?php
2{
3 ini_set("display_errors", "On");
4 ini_set("mysql.trace_mode", "On");
5
6 if (empty($_GET["fDateValue"]))
7 {
8 echo "Please give the date value.<br>";
9 return;
10 }
11 if (empty($_GET["fDateName"]))
12 {
13 echo "Please give the date name.<br>";
14 return;
15 }
16 if (empty($_GET["fIdx"]))
17 {
18 echo "Please give the idx.<br>";
19 return;
20 }
21 if (empty($_GET["fDateValuePrev"]))
22 $_GET["fDateValuePrev"]="";
23 if (empty($_GET["fStatusDate"]))
24 $_GET["fStatusDate"]="";
25
26 include("db.php");
27 $db_id = mysql_pconnect($host, $user, $pw);
28 if ($db_id==FALSE)
29 {
30 printf("mysql_connect returned the following error: %s\n", mysql_error());
31 die("");
32 }
33 mysql_select_db($db);
34
35 if (strcmp("year",$_GET["fDateName"])==0)
36 {
37 $identifier1="";
38 $identifier2="Y";
39 $datename="YYYY";
40 $newdatename="month";
41 if (strcmp($_GET["fDateValue"],"empty")==0)
42 $_GET["fDateValue"]="all";
43 if (strcmp($_GET["fDateValuePrev"],"empty")==0)
44 $_GET["fDateValuePrev"]="all";
45 }
46 if (strcmp("month",$_GET["fDateName"])==0)
47 {
48 $identifier1="%Y";
49 $identifier2="m";
50 $datename="MM";
51 $newdatename="day";
52 }
53 if (strcmp("day",$_GET["fDateName"])==0)
54 {
55 $identifier1="%Y-%m";
56 $identifier2="d";
57 $datename="DD";
58 $newdatename="hour";
59 }
60 if (strcmp("hour",$_GET["fDateName"])==0)
61 {
62 $identifier1="%Y-%m-%d";
63 $identifier2="H";
64 $datename="hh";
65 $newdatename="min";
66 }
67 if (strcmp("min",$_GET["fDateName"])==0)
68 {
69 $identifier1="%Y-%m-%d %H";
70 $identifier2="i";
71 $datename="mm";
72 $newdatename="sec";
73 }
74 if (strcmp("sec",$_GET["fDateName"])==0)
75 {
76 $identifier1="%Y-%m-%d %H:%i";
77 $identifier2="s";
78 $datename="ss";
79 $newdatename="";
80 }
81
82 if (strcmp($_GET["fDateValuePrev"],"empty")!=0)
83 {
84 $query0 ="SELECT ";
85 $query0.=" Date_Format(fValidFrom, '%". $identifier2."') as valid ";
86 $query0.=" FROM History ";
87 if (empty($identifier1))
88 $query0.=" WHERE NOT fValidFrom='0000-00-00 00:00:00' ";
89 else
90 $query0.=" WHERE Date_Format(fValidFrom, '". $identifier1."')='".$_GET["fStatusDate"]."'";
91 //$query0.=" WHERE Date_Format(fValidFrom, '%". $identifier1."')=".$_GET["fDateValuePrev"];
92 $query0.=" GROUP BY valid";
93 $result0=mysql_query($query0, $db_id);
94 }
95 //echo $query0;
96
97 if (empty($newdatename))
98 printf("<select id='%s%d'>\n", $_GET["fDateName"], $_GET["fIdx"]);
99 else
100 //printf("<select id='%s%d' onchange=\"get_dates('%s', this.value, this.value, %d, 'yes')\">\n",
101 // fill dummy for first value, as else the value for the next pulldown might be set to a value by chance
102 printf("<select id='%s%d' onchange=\"get_dates('%s', 'dummy', this.value, %d, 'yes')\">\n",
103 $_GET["fDateName"], $_GET["fIdx"], $newdatename, $_GET["fIdx"]);
104
105 if (strcmp($_GET["fDateValue"],"empty")!=0)
106 printf("<option value='empty'>%s</option>\n", $datename);
107 else
108 printf("<option value='empty'>-</option>\n");
109 if (strcmp($_GET["fDateValuePreV"],"empty")!=0)
110 {
111 while ($row0 = mysql_fetch_row($result0))
112 {
113 if (strcmp($row0[0],$_GET["fDateValue"])==0)
114 printf("<option value='%s' selected>%s </option>\n", $row0[0], $row0[0]);
115 else
116 printf("<option value='%s'>%s </option>\n", $row0[0], $row0[0]);
117 }
118 mysql_free_result($result0);
119 }
120 printf("</select>\n");
121
122 mysql_close($db_id);
123
124 ini_set("display_errors", "Off");
125 ini_set("mysql.trace_mode", "Off");
126}
127?>
Note: See TracBrowser for help on using the repository browser.