Use a <select> box for the year
authorJoey Schulze <joey@infodrom.org>
Sun, 11 Feb 2007 18:42:10 +0000 (18:42 +0000)
committerJoey Schulze <joey@infodrom.org>
Sun, 11 Feb 2007 18:42:10 +0000 (18:42 +0000)
src/InfoCon/buch/index.wml

index b2001e9..3282f8a 100644 (file)
@@ -2,15 +2,28 @@
 
 <page func=InfoCon title="Buchhaltung">
 
+<h3>Nicht bezahlte Rechnungen</h3>
+
+<?
+  $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
+        or die("Unable to connect to SQL server");
+?>
 <form method=POST action=list.php>
 <input type=hidden name=blzkto value="<? echo $blzkto; ?>">
-<b>Jahr</b>: <input name=year size=10 maxlength=4><br>
-<b>Kategorie:</b> <select name=category>
+<b>Jahr:</b> <select name=year>
 <option>
 <?
-  $dbh = pg_pconnect ("<dbhost>", "<dbport>", "<dbname>")
-        or die("Unable to connect to SQL server");
+  $query = "SELECT DISTINCT substr(date,0,5) AS year FROM sales ORDER BY substr(date,0,5)";
+  $sth = pg_exec ($dbh, $query);
 
+  for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
+    $cat = pg_fetch_array ($sth, $nr);
+    printf ("<option value=\"%s\">%s", $cat["year"], $cat["year"]);
+  }
+?></select><br>
+<b>Kategorie:</b> <select name=category>
+<option>
+<?
   $query = "SELECT DISTINCT category FROM sales ORDER BY category";
   $sth = pg_exec ($dbh, $query);