Rudimentaere Buchhaltung hinzugefuegt.
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / pay.wml
1 #include <infocon.style>
2
3 <page title="Kontoführung">
4
5 <headline "Buchhaltung">
6
7 <?
8   $dbh = pg_pconnect ("kuolema", "5432", "<db>")
9          or die("Unable to connect to SQL server");
10
11   $query = "SELECT nr FROM sales WHERE paid=0";
12   $sth = pg_exec ($dbh, $query);
13
14   # Collect all to be paid entries
15   #
16   for ($nr=0; $nr <pg_NumRows ($sth); $nr++) {
17     $row = pg_fetch_array ($sth, $nr);
18
19     $v = sprintf ("pay_%d", $row['nr']);
20     if (${$v}) {
21       $pay[] = $row['nr'];
22     }
23   }
24
25   # Now pay them
26   if (count ($pay)>0) {
27     echo ("Folgende Buchungen werden bezahlt:<p>");
28     for ($i=0; $i < count ($pay); $i++) {
29       $query = sprintf ("UPDATE sales SET paid=1 WHERE nr = %d", $pay[$i]);
30   
31       printf ("%s<br>", $query);
32       $sth = pg_exec ($dbh, $query);
33     }
34   }
35
36 ?>
37 </page>
38
39 # Local variables:
40 # mode: text
41 # mode: auto-fill
42 # mode: iso-accents
43 # end: