Display only visible items
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / index.wml
index cf8cd81..1e2084c 100644 (file)
@@ -1,18 +1,36 @@
 #include <infocon.style>
 
-<page title="Buchhaltung">
+<page func=InfoCon title="Buchhaltung">
+<calendar_init -5>
 
-<headline "Buchhaltung">
+<style type="text/css">
+span.in { color: green; }
+span.out { color: red; }
+span.in:hover, span.out:hover { background: yellow; border: 1px solid #ccc; }
+</style>
 
-<form method=POST action=list.php3>
+<h3>Übersichten</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 ("kuolema", "5432", "<db>")
-        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) DESC";
+  $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);
 
 ?></select><br>
 <b>Zahlung</b>: <input type=checkbox name=input value=1 checked> Einnahmen <input type=checkbox name=output value=1 checked> Ausgaben<br>
 
-<p><center><input type=submit value="Query"> <input type=reset value="Reset"></center><p>
+<p><center>
+<input class=button type=submit name=submit value="List"> 
+<input class=button type=submit name=submit value="Overview"> 
+<input class=button type=submit name=submit value="Tally"> 
+<input class=button type=reset value="Reset">
+</center></p>
 </form>
 
 <?
-  $query = "SELECT nr,date,description,price FROM sales WHERE paid=0 ORDER BY date,nr";
+  $form = 0;
+  $query = "SELECT nr,date,description,price FROM sales_dm WHERE paid=0 AND visible=1 ORDER BY date,nr";
   $sth = pg_exec ($dbh, $query);
 
   if (pg_NumRows ($sth) > 0) {
+    $form = 1;
     echo ("<h3>Nicht bezahlte Rechnungen</h3>");
-    echo ("<form method=\"POST\" action=\"pay.php3\">");
+    echo ("<form method=\"POST\" action=\"pay.php\">");
   }
 
   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
     $row = pg_fetch_array ($sth, $nr);
     $date = substr ($row['date'],6,2) . "." . substr ($row['date'],4,2) . "." . substr ($row['date'],0,4);
-    printf (" <input type=\"checkbox\" name=\"pay_%d\" value=\"1\">", $row['nr']);
-    printf ("%d. %s %s (%.2f)<br>", $row['nr'], $date, $row['description'], $row['price']);
+    printf (" <input type=\"text\" id=\"date_%d\" name=\"date_%d\" size=\"6\" value=\"\">", $row['nr'], $row['nr']);
+    printf (" <img class=\"calendar\" src=\"<root_prefix>pix/calendar.gif\" onclick=\"event.cancelBubble=true;popcalendar('date_%d');\" alt=\"\">", $row['nr']);
+    printf (" %d. %s %s (%.2f&nbsp;DM)<br>", $row['nr'], $date, $row['description'], $row['price']);
   }
 
-  if (pg_NumRows ($sth) > 0) {
-    echo ("<p><input type=\"submit\" value=\"Bezahlen\"> <input type=\"reset\" value=\"Reset\"><p>");
+  $query = "SELECT nr,date,description,price FROM sales WHERE paid=0 AND visible=1 ORDER BY date,nr";
+  $sth = pg_exec ($dbh, $query);
+
+  if (!form && pg_NumRows ($sth) > 0) {
+    $form = 1;
+    echo ("<h3>Nicht bezahlte Rechnungen</h3>");
+    echo ("<form method=\"POST\" action=\"pay.php\">");
+  }
+
+  for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
+    $row = pg_fetch_array ($sth, $nr);
+    $date = substr ($row['date'],6,2) . "." . substr ($row['date'],4,2) . "." . substr ($row['date'],0,4);
+    printf (" <input type=\"text\" id=\"date_%d\" name=\"date_%d\" size=\"6\" value=\"\">", $row['nr'], $row['nr']);
+    printf (" <img class=\"calendar\" src=\"<root_prefix>pix/calendar.gif\" onclick=\"event.cancelBubble=true;popcalendar('date_%d');\" alt=\"\">", $row['nr']);
+    printf (' <span class="%s">%d. %s %s (%.2f&nbsp;&euro;)</span><br>',
+           $row['price'] < 0 ? 'out' : 'in',
+           $row['nr'], $date, $row['description'], $row['price']);
+  }
+
+  if ($form > 0) {
+    echo ("<p><input type=\"submit\" class=\"button\" value=\"Bezahlen\"> <input type=\"reset\" class=\"button\" value=\"Reset\"><p>");
     echo ("</form>");
   }
 ?>
@@ -53,5 +98,4 @@
 # Local variables:
 # mode: text
 # mode: auto-fill
-# mode: iso-accents
 # end: