. offer.name -> offer.subname, damit ich eindeutige Feldbezeichner
[infodrom.org/infocon.infodrom.org] / src / shop / calc.wml
1 #include <infocon.style>
2 #include <shop.inc>
3
4 <page title="InfoCon - Online-Shop">
5
6 <h1 align=center>Bestellungskontrolle</h1>
7
8 <form method=post action=order.php3>
9 &nbsp;<table width=100% border=0 cellpadding=0 cellspacing=0>
10
11 <?
12   # So werden 1 Pixel dicke Rahmen erzeugt
13   $la = "<tr><td width=\"2\" bgcolor=\"#000000\"></td><td bgcolor=\"#000000\"><table cellpadding=\"0\" cellspacing=\"1\" width=\"100%\" border=\"0\" summary=\"\"><tr><td bgcolor=\"#ffffff\">";
14   $le = "</td></tr></table></td></tr>";
15 #  $ch = "#5dbbf9";
16 #  $cd = "#9bd4fa";
17 #  $ch = "#85c5f0";
18 #  $cd = "#abdcfc";
19   $ch = "#abdcfc";
20   $cd = "#eff0f1";
21
22   $tind = "<tr bgcolor=\"$ch\"><th><font face=\"Helvetica,Arial\">Anzahl</font></th>"
23          ."<th align=\"left\"><font face=\"Helvetica,Arial\">Artikel</font></th>"
24          ."<th align=\"right\"><font face=\"Helvetica,Arial\">Einzel</font></th>"
25          ."<th align=\"right\"><font face=\"Helvetica,Arial\">Gesamt</font></th></tr>";
26
27   $dbh = dbconnect();
28
29   // WHERE spool > 0
30   $sth = dbquery ($dbh, "SELECT article.name,article.article,offer.subname,offer.price,offer.articleid "
31                        ."FROM article,offer WHERE article.article = offer.article ORDER BY offer.articleid");
32
33   $sum = 0.0;
34   echo ($la);
35   echo ("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" summary=\"\">");
36
37   $color = $cd;
38   for ($i=0; $i < pg_NumRows ($sth); $i++) {
39     $row = pg_fetch_array ($sth, $i);
40
41     if (${$row['articleid']} > 0) {
42       if ($sum == 0.0) {
43         echo ($tind);
44       }
45       $color = $color == $cd?"#ffffff":$cd;
46       printf ("<tr bgcolor=\"%s\">", $color);
47       printf ("<td width=\"10%%\" align=\"center\"><font face=\"Helvetica,Arial\">"
48              ."<input name=\"%s\" size=\"3\" maxlength=\"3\" value=\"%d\"></font></td>",
49              $row['articleid'], ${$row['articleid']});
50
51       printf ("<td width=\"70%%\" align=\"left\"><font face=\"Helvetica,Arial\">"
52              ."<a href=\"show.php3?article=%s\">%s, %s</a></font></td>",
53              $row['article'], $row['name'], $row['subname']);
54
55       printf ("<td width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%6.2f</font></td>",
56              $row['price']);
57
58       printf ("<td width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%6.2f</font></td></tr>",
59              $row['price'] * ${$row['articleid']});
60       $sum += $row['price'] * ${$row['articleid']};
61     }
62   }
63   if ($sum == 0.0) {
64     printf ("<tr bgcolor=\"%s\"><th colspan=\"4\" align=\"left\"><font face=\"Helvetica,Arial\">%s</font></th>",
65             $ch, "Sie haben vergessen, Waren auszuwählen");
66   } else {
67     printf ("<tr bgcolor=\"%s\"><th colspan=\"3\" align=\"left\"><font face=\"Helvetica,Arial\">Summe</font></th>", $ch);
68     printf ("<th align=\"right\"><font face=\"Helvetica,Arial\">%7.2f</font></th></tr>", $sum);
69   }
70   echo ("</table>");
71   echo ($le);
72 ?>
73
74 </table>
75 <? if ($sum > 0.0) { ?>
76 <p><center><input type=submit value="Bestellen"> . <input type=reset value="Reset"></center>
77 <? } ?>
78 </form><p>
79
80 </page>
81 # Local variables:
82 # mode: indented-text
83 # mode: auto-fill
84 # mode-: iso-accents
85 # end: