From 52751c6f5b853deacc569ee708be87c826d7f20c Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Sun, 10 Dec 2000 21:50:12 +0000 Subject: [PATCH 1/1] Aktuelle Version / als naechstes brauche ich ein Kontroll-Frontend --- src/shop/order.wml | 97 ++++++++++------ src/shop/orderit.wml | 263 +++++++++++++++++++++++++++++++++++++++++++ src/shop/porto.wml | 27 +++++ src/shop/readme | 26 ++++- src/shop/submenu.inc | 5 + 5 files changed, 384 insertions(+), 34 deletions(-) create mode 100644 src/shop/orderit.wml create mode 100644 src/shop/porto.wml diff --git a/src/shop/order.wml b/src/shop/order.wml index 402c6b9..37bcc46 100644 --- a/src/shop/order.wml +++ b/src/shop/order.wml @@ -1,9 +1,6 @@ #include #include -

-
-

Bestellung aufgeben

@@ -11,15 +8,17 @@
"; - $le = ""; + # Porto erst einmal auf 20,-- festgesetzt + $porto = 20.00; + + # Colors # $ch = "#5dbbf9"; # $cd = "#9bd4fa"; # $ch = "#85c5f0"; # $cd = "#abdcfc"; - $ch = "#abdcfc"; - $cd = "#eff0f1"; + $ch = ""; + $cd = ""; + $cn = ""; $tind = "Anzahl" ."Artikel" @@ -28,25 +27,30 @@ $dbh = dbconnect(); - // WHERE spool > 0 - $sth = dbquery ($dbh, "SELECT article.name,article.article,offer.subname,offer.price,offer.articleid " - ."FROM article,offer WHERE article.article = offer.article ORDER BY offer.articleid"); + # WHERE spool > 0 + $sth = dbquery ($dbh, "SELECT article.name,article.article,offer.subname,offer.price,offer.articleid,spool.count_spare " + ."FROM article,offer,spool WHERE article.article = offer.article AND offer.articleid = spool.articleid " + ."ORDER BY offer.articleid"); $sum = 0.0; - echo ($la); + $color = $cd; + $maybe_split = 0; for ($i=0; $i < pg_NumRows ($sth); $i++) { $row = pg_fetch_array ($sth, $i); if (${$row['articleid']} > 0) { + if (${$row['articleid']} > $row['count_spare']) { + $maybe_split = 1; + } if ($sum == 0.0) { echo ($tind); } - $color = $color == $cd?"#ffffff":$cd; + $color = $color == $cd?$cn:$cd; printf ("", $color); - printf ("" - ."%d", + printf ("" + ."%d ", $row['articleid'], ${$row['articleid']}, ${$row['articleid']}); printf ("" @@ -65,48 +69,71 @@ printf ("%s", $ch, "Sie haben vergessen, Waren auszuwählen"); } else { + + $color = $color == $cd?$cn:$cd; + printf ("", $color); + printf (""); + printf ("" + ."Porto und Verpackung"); + printf ("%6.2f", + $porto); + printf ("%6.2f", + $porto); + $sum += $porto; + printf ("Summe", $ch); printf ("%7.2f", $sum); } - echo ($le); + ?> - 0.0) { ?> -

Bitte geben Sie Ihre Kundennummer oder Ihre Anschrift ein. + 0.0) { + + if ($maybe_split) { + echo ("

Nicht alle Artikel sind im Moment vorrrätig.
"); + echo ("Sie haben die Möglichkeit, die Bestellung komplett zu erhalten, wenn die Ware vollständig ist oder " + ."sie aufzuteilen. Dann erhalten Sie den ersten Teil sofort und den zweiten sobald die Ware da " + ."ist. Achtung, bei zwei Bestellungen fällt auch zweimal Porto an.

"); + + echo (" Bestellung aufteilen"); + } +?> +

Bitte geben Sie Ihre Kundennummer oder Ihre Anschrift an. -<: print ""; :> + ?> Kundennr. - -Paßwort + +Kennwort - + -<: print ""; :> + ?> - size=50 maxlength=> + size=50 maxlength=> -<: print ""; :> - - - - - + ?> + + + + + PLZ - + *  Stadt * @@ -115,7 +142,11 @@ Deutschland -<: print ""; :> + + +

Die mit einem Stern (*) markierten Eingabefelder sind erforderlich. + + ?>

.
diff --git a/src/shop/orderit.wml b/src/shop/orderit.wml new file mode 100644 index 0000000..359a528 --- /dev/null +++ b/src/shop/orderit.wml @@ -0,0 +1,263 @@ +#include +#include + + + +

Bestellung

+ + +# BEGIN ... COMMIT oder BEGIN ... ROLLBACK +"; + $cd = ""; + $cn = ""; + + $tbest = "" + ."Bestellung Nr. %d

"; + + $tind = "Anzahl" + ."Artikel" + ."Einzel" + ."Gesamt"; + + $trow = "%d " + ."" + ."%s, %s" + ."%6.2f" + ."%6.2f"; + + $tporto = "" + ."Porto und Verpackung" + ."%6.2f" + ."%6.2f"; + + $tsum = "Summe" + ."%7.2f"; + + +# Kundennr. !Kundennr. +# / \ Kundendaten vollständig +# / \ / \ +# korrekt inkorrekt / \ +# \ \ / Kunden aufnehmen +# \ \ / / +# \ Hinweis / +# \ ->Back / +# \ / +# \ / +# Bestellung aufnehmen +# -> Lagerbestand ändern +# -> Bestelliste +# Bestätigung per Mail +# Danke im Web +# +# + + # Infobox für die Kundennummer und das Kennwort + # 0="Firma"/"Name"; 1=Name; 2=Kundennr.; 3=Kennwort + $pwinfo = "

" + ."" + ."" + ."" + ."" + ."" + ."" + ."" + ."" + ."" + ."
\" align=\"center\">" + ."Ihre Kundendaten
\">%s\"> \">%s
\">Kundennr.\"> \">%s
\">Kennwort\"> \">%s

"; + + + $ok = 0; + + #if ($HTTP_REFERER != "http://infocon.infodrom.org/shop/order.php3") { + if (strcasecmp ($HTTP_REFERER, "http://wwww.infodrom.ffis.de/infocon.infodrom.org/shop/order.php3") != 0) { + echo ("

Hier stimmt etwas nicht."); // nämlich fehlt der richtige Referer-Wert... + } else /* Referer */ { + + if ((strlen ($customer) > 0) && (strlen ($passwd) > 0)) { + $dbh = dbconnect(); + $sth = dbquery ($dbh, sprintf ("SELECT passwd FROM customer WHERE customer = %d", $customer)); + if (pg_NumRows ($sth) > 0) { + $row = pg_fetch_array ($sth, 0); + if ( (strlen ($row['passwd']) > 0) && ($passwd == $row['passwd'])) { + $ok = 1; + } else { + echo ("

Das angegebene Kennwort stimmt nicht mit dem gespeicherten überein."); + } + } else { + echo ("

Die angegebene Kundennummer ist falsch."); + } + } else /* customer && passwd */ { + if ( (strlen ($lastname) > 0) + && (strlen ($firstname) > 0) + && (strlen ($street) > 0) + && (strlen ($plz) > 0) + && (strlen ($city) > 0) + && (strlen ($country) > 0) ) { + + <: + for $i (('company','firstname','lastname','appendix','street','city','country')) { + printf " \$%s=sql_prepare (\$%s);\n", $i, $i; + } + :> + + $dbh = dbconnect(); + $sth = dbquery ($dbh, "SELECT max(customer) FROM customer"); + if (pg_NumRows ($sth) > 0) { + $row = pg_fetch_array ($sth, 0); + $customer = $row[0] > ?$row[0]:; + $customer++; + + # Now try to get a password + # + $pwgen = popen ("pwgen 10", "r"); + if (!feof ($pwgen)) { + $newpasswd = fgets ($pwgen, 255); + pclose ($pwgen); + } + + # ACHTUNG: Hier fehlt jeglicher Sicherheitsmechanismus, der verhindern könnte, daß + # eine Firma zig-mal direkt hintereinander mit Bestellungen ... (fixme) + $query = sprintf ("INSERT INTO customer (customer,company,firstname,lastname,appendix,street,plz,city,country,passwd) " + ."VALUES (%d,'%s','%s','%s','%s','%s',%d,'%s','%s','%s')", + $customer,$company,$firstname,$lastname,$appendix,$street,$plz,$city,$country,$newpasswd); + $sth = dbquery ($dbh, $query); + + printf ($pwinfo, strlen ($company)?"Firma":"Name", + strlen ($company)?$company:$firstname . " " . $lastname, $customer, $newpasswd); + $ok = 1; + } else { + echo ("

Es ist ein Datenbankfehler aufgetreten."); + } + + } else { + echo ("

Nicht alle erforderlichen Felder sind ausgefüllt."); + } + } + } + + if ($ok) { + + + # Queries to insert Bestellung... + + $sth = dbquery ($dbh, "SELECT max(dispatch) FROM dispatch"); + if (pg_NumRows ($sth) > 0) { + $dmin = date("Y") . sprintf ("%05d", ); + $row = pg_fetch_array ($sth, 0); + $dispatch = $row[0] > $dmin?$row[0]:$dmin; + $dispatch++; + + # fixme: Find out if 1st dispatch will be empty first... + # Warning: If another user try to add dispatches, this will fail + $sth = dbquery ($dbh, sprintf ("INSERT INTO dispatch (dispatch,customer,date) VALUES (%d,%d,now())", + $dispatch, $customer)); + $sth = dbquery ($dbh, sprintf ("INSERT INTO status (dispatch,status,staff,date) VALUES (%d,,'web',now())", + $dispatch)); + + if ($split == 1) { + $sth = dbquery ($dbh, sprintf ("INSERT INTO dispatch (dispatch,customer,date) VALUES (%d,%d,now())", + $dispatch+1, $customer)); + $sth = dbquery ($dbh, sprintf ("INSERT INTO status (dispatch,status,staff,date) VALUES (%d,,'web',now())", + $dispatch+1)); + } + + printf ($tbest, $ch, $dispatch); + echo ($tind); + + # Status: customer verified || created; 1 or 2 dispatches reserved + # WHERE spool > 0 + $sth = dbquery ($dbh, "SELECT article.name,article.article,offer.subname,offer.price,offer.articleid,spool.count_spare," + ."count_sold " + ."FROM article,offer,spool WHERE article.article = offer.article AND offer.articleid = spool.articleid " + ."ORDER BY offer.articleid"); + + $color = $cd; + $color2 = $cd; + $sum = 0.0; + $table = ""; + for ($i=0; $i < pg_NumRows ($sth); $i++) { + $row = pg_fetch_array ($sth, $i); + + if (${$row['articleid']} > 0) { + $sthi = dbquery ($dbh, sprintf ("UPDATE spool SET count_spare = %d, count_sold = %d WHERE articleid = '%s'", + $row['count_spare'] - ${$row['articleid']}, + $row['count_sold'] + ${$row['articleid']}, + $row['articleid'])); + + if ($split && (${$row['articleid']} > $row['count_spare'])) { + + if ($row['count_spare'] > 0) { + $color = $color == $cd?$cn:$cd; + printf ($trow, $color, $row['count_spare'], $row['article'], $row['name'], $row['subname'], $row['price'], + $row['price'] * $row['count_spare']); + + $sthi = dbquery ($dbh, sprintf ("INSERT INTO dispatchlist (dispatch,articleid,quantity,unitprice) " + ."VALUES (%d,'%s',%d,%5.2f)", + $dispatch,$row['articleid'],$row['count_spare'],$row['price'])); + $sum += $row['price'] * $row['count_spare']; + + ${$row['articleid']} -= $row['count_spare']; + } + + $sthi = dbquery ($dbh, sprintf ("INSERT INTO dispatchlist (dispatch,articleid,quantity,unitprice) " + ."VALUES (%d,'%s',%d,%5.2f)", + $dispatch+1,$row['articleid'],${$row['articleid']},$row['price'])); + $sum2 += $row['price'] * ${$row['articleid']}; + $color2 = $color2 == $cd?$cn:$cd; + $table .= sprintf ($trow, $color2, ${$row['articleid']}, $row['article'], $row['name'], $row['subname'], $row['price'], + $row['price'] * ${$row['articleid']}); + } else { + $color = $color == $cd?$cn:$cd; + printf ($trow, $color, ${$row['articleid']}, $row['article'], $row['name'], $row['subname'], $row['price'], + $row['price'] * ${$row['articleid']}); + $sthi = dbquery ($dbh, sprintf ("INSERT INTO dispatchlist (dispatch,articleid,quantity,unitprice) " + ."VALUES (%d,'%s',%d,%5.2f)", + $dispatch,$row['articleid'],${$row['articleid']},$row['price'])); + $sum += $row['price'] * ${$row['articleid']}; + ${$row['articleid']} = 0; + } + } /* ${$row['articleid']} > 0 */ + } /* for */ + $color = $color == $cd?$cn:$cd; + printf ($tporto, $color, $porto, $porto); + $sum2 += $porto; + printf ($tsum, $ch, $sum); + } else { + echo ("Interner Fehler."); + } + + + if ($split) { + echo ("

"); + + + + printf ($tbest, $ch, $dispatch+1); + echo ($tind); + echo ($table); + $color2 = $color2 == $cd?$cn:$cd; + printf ($tporto, $color2, $porto, $porto); + $sum2 += $porto; + printf ($tsum, $ch, $sum2); + + + } + } else { + echo ("

Bitte benutzen Sie den Back-Button ihres Browsers und korrigieren Sie Ihre Eingaben."); + } + +?>

+ + +# Local variables: +# mode: indented-text +# mode: auto-fill +# mode-: iso-accents +# end: diff --git a/src/shop/porto.wml b/src/shop/porto.wml new file mode 100644 index 0000000..dee6032 --- /dev/null +++ b/src/shop/porto.wml @@ -0,0 +1,27 @@ +#include + + + +

Porto und Verpackung

+ +

Wir bemühen uns, die Kosten für Porto und Verpackung so gering wie +möglich zu halten. Wir verwenden daher teilweise bereits benutzte +Kartons zum Versand der Waren. Kleine Mengen Pins werden z.B. in +gefütterten Briefumschlägen verschickt. + +

Wenn nicht anders gewünscht, werden die Lieferungen mit der +Deutsche Post verschickt. Wenn Sie die Zustellung per UPS wünschen, +geben Sie dieses bitte an. Wir müssen Sie jedoch darauf hinweisen, +daß die Portogebühren dadurch höher liegen. + +

Die automatische Berechnung des Portos ist nicht einfach, da bei +gemischten Waren die Volumina nicht einfach addieren lassen. Die +letztendlich für Porto und Verpackung anfallenden Kosten können daher +von der Berechnung abweichen. Wir hoffen, daß sie nur nach unten +abweichen, können das jedoch nicht garantieren. + + +# Local variables: +# mode: indented-text +# mode: iso-accents +# end: diff --git a/src/shop/readme b/src/shop/readme index 89d0c42..ee2c9a2 100644 --- a/src/shop/readme +++ b/src/shop/readme @@ -12,8 +12,32 @@ Der Shop funktioniert wie folgt: Preis berechnen & anzeigen Bestellung aufgeben Kundennr./Adresse + Bestellung aufsplitten? [order.wml] / \ / \ [orderit.wml] - Kundennr. korrekt Kunden aufnehmen \ No newline at end of file + Kundennr. !Kundennr. + / \ Kundendaten vollständig + / \ / \ + korrekt inkorrekt / \ + \ \ / Kunden aufnehmen + \ \ / / + \ Hinweis / + \ ->Back / + \ / + \ / + Bestellung aufnehmen + -> Lagerbestand ändern + -> Bestelliste + Bestätigung per Mail + Danke im Web + + + + + + + + +(setq indent-tabs-mode 'nil) diff --git a/src/shop/submenu.inc b/src/shop/submenu.inc index 850b7cc..a6dbaf6 100644 --- a/src/shop/submenu.inc +++ b/src/shop/submenu.inc @@ -9,3 +9,8 @@ Mindestmengen Mindestmengen >
+ +  "porto" + Porto + Porto +>
-- 2.20.1