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

<page func=InfoCon title="Online Shop">

<table width=100% border=0 cellpadding=0 cellspacing=0>

<?
  $tline = "<tr><td valign=\"top\" width=\"18%%\" align=\"right\"><font face=\"Helvetica,Arial\"><b>%s</b></font></td>"
	  ."<td width=\"2%%\">&nbsp;</td>"
	  ."<td valign=\"top\" width=\"80%%\"><font face=\"Helvetica,Arial\">%s</font></td></tr>";

  $dbh = dbconnect();
  $sth = dbquery ($dbh, sprintf ("SELECT * FROM customer WHERE customer = %d", $customer));

  if (pg_NumRows ($sth) > 0) {
    $row = pg_fetch_array ($sth, 0);

    printf ($tline, "Kundennr.", $row['customer']);
    printf ($tline, "Firma", $row['company']);
    printf ($tline, "Name", $row['firstname'] . " " . $row['lastname']);
    printf ($tline, "Zusatz", $row['appendix']);
    printf ($tline, "Straße", $row['street']);
    printf ($tline, "Ort", $row['plz'] . " " . $row['city']);
    printf ($tline, "Land", $row['country']);
    printf ($tline, "Kommentar", $row['comment']);

    $sth = dbquery ($dbh, sprintf ("SELECT dispatch,date FROM dispatch WHERE customer = %d ORDER BY date", $customer));

    $dispatches = "";
    for ($i=0; $i < pg_NumRows ($sth); $i++) {
      $row = pg_fetch_array ($sth, $i);
      $date = explode (" ", $row['date']);
      $date = explode ("-", $date[0]);
      $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);

      $dispatches .= sprintf ("<a href=\"dispatch.php3?dispatch=%d\">Auftrag %d</a> (%s)<br>",
		             $row['dispatch'], $row['dispatch'], $date);
    }
    printf ($tline, "Aufträge", $dispatches);
  }

?>
</table>

</page>

# Local variables:
# mode: text
# mode: auto-fill
# mode: iso-accents
# end:
