#include <infocon.style>
#include <shop.inc>

<page title="Online-Shop">

&nbsp;<table width=100% border=0 cellpadding=0 cellspacing=0>

<?
  # So werden 1 Pixel dicke Rahmen erzeugt
  $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\">";
  $le = "</td></tr></table></td></tr>";
  $ch = "#abdcfc";
  $cd = "#eff0f1";

  $dbh = dbconnect();

  # FIXME: kill ' from $article
  $sth = dbquery ($dbh, "SELECT * FROM article WHERE article = '$article'");

  if (pg_NumRows ($sth) == 0) {
    echo ($la);
    echo ("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" summary=\"\">");
    printf ("<tr><th align=\"left\" colspan=\"2\" bgcolor=\"%s\">"
  	   ."<font face=\"Helvetica,Arial\">Kein Artikel gefunden.</font></th></tr>",
  	   $ch);
    echo ("</table>");
    echo ($le);
  } else {
    $row = pg_fetch_array ($sth, 0);
    echo ($la);
  
    echo ("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" summary=\"\">");
    printf ("<tr><th align=\"left\" colspan=\"2\" bgcolor=\"%s\">"
  	   ."<font face=\"Helvetica,Arial\">%s</font></th></tr>",
  	   $ch, $row['name']);
  
    if (strlen ($row['url_path']) > 0) {
      $img = sprintf ("src=\"%s\" width=\"%d\" height=\"%d\" alt=\"[Artikel #%s]\"",
  		      $row['url_path'], $row['url_width'], $row['url_height'], $row['article']);
    } else {
      $img = "src=\"<root_prefix>Pics/nopix.png\" width=\"158\" height=\"183\" alt=\"[Kein Bild vorhanden]\"";
    }

    # Sub-Query
    $sthi = dbquery ($dbh, sprintf ("SELECT subname,price,articleid FROM offer WHERE article = '%s'ORDER BY articleid",
  				      $row['article']));
    if (pg_NumRows ($sthi) > 0) {
      <protect>
      $table = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"$cd\">";
      </protect>
      for ($ii=0; $ii < pg_NumRows ($sthi); $ii++) {
	$rowi = pg_fetch_array ($sthi, $ii);
	$table .= sprintf ("<tr><td align=\"left\" width=\"70%%\"><font face=\"Helvetica,Arial\">&nbsp;%s</font></td>",
			   $rowi['subname']);
	$table .= sprintf ("<td align=\"right\" width=\"20%%\"><font face=\"Helvetica,Arial\">%6.2f DM&nbsp;</font></td></tr>",
			   $rowi['price']);
      }
      $table .= "</table>";
    } else {
      $table = "";
    }
    # /Sub-Query

    <protect>
    printf ("<tr><td width=\60%%\" align=\"left\" valign=\"top\">"
  	   ."<font face=\"Helvetica,Arial\"><p>%s</font></td>"
  	   ."<td width=\40%%\" rowspan=\"2\" align=\"center\" valign=\"top\"><img %s>&nbsp;</td></tr>",
  	   $row['description'], $img);
    </protect>
    printf ("<tr><td width=\60%%\" align=\"left\" valign=\"bottom\">%s</td></tr>", $table);
  
    echo ("</table>");
    echo ($le);
  }
?>

</table>

<p>Preise freibleibend.  Alle Preise verstehen sich inklusive gesetzlich vorgeschriebener Mehrwertsteuer.

</page>
# Local variables:
# mode: indented-text
# mode: auto-fill
# mode-: iso-accents
# end:
