0.14_05 commit r0_14_05
authorTony Cook <tony@develop-help.com>
Mon, 8 Sep 2003 06:12:57 +0000 (06:12 +0000)
committertony <tony@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Mon, 8 Sep 2003 06:12:57 +0000 (06:12 +0000)
26 files changed:
MANIFEST
Makefile
schema/bse.sql
site/cgi-bin/modules/BSE/AdminSiteUsers.pm
site/cgi-bin/modules/BSE/CustomBase.pm
site/cgi-bin/modules/BSE/DB/Mysql.pm
site/cgi-bin/modules/BSE/Session.pm
site/cgi-bin/modules/BSE/Shop/Util.pm
site/cgi-bin/modules/BSE/UserReg.pm
site/cgi-bin/modules/OrderItem.pm
site/cgi-bin/modules/Squirrel/Template.pm
site/cgi-bin/shop.pl
site/docs/bse.pod
site/docs/config.pod
site/templates/admin/edit_product.tmpl
site/templates/admin/order_detail.tmpl
site/templates/checkout_base.tmpl
site/templates/custom/checkout.include [new file with mode: 0644]
site/templates/custom/order_detail.include [new file with mode: 0644]
site/templates/custom/order_detail_payment.include [new file with mode: 0644]
site/templates/custom/payment_type.include [new file with mode: 0644]
site/templates/custom/payment_type_email.include [new file with mode: 0644]
site/templates/mailconfirm.tmpl
site/templates/mailorder.tmpl
t/t010template.t
test.cfg

index ce854ce7a4dabbab136216f369aa2127766f4d70..7efea5d18b2e0d68a6d4ae15cdd0d44c034edcb3 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -280,6 +280,11 @@ site/templates/common/news_item.tmpl
 site/templates/common/rssbase.tmpl
 site/templates/common/sidebar.tmpl
 site/templates/common/sidebar_section.tmpl
+site/templates/custom/checkout.include
+site/templates/custom/order_detail.include
+site/templates/custom/order_detail_payment.include
+site/templates/custom/payment_type.include
+site/templates/custom/payment_type_email.include
 site/templates/error.tmpl
 site/templates/extras.txt
 site/templates/htmlemail/basic.tmpl
index 13df233fe96552bf66a0935edad21f73f89dd3fe..881f5342553d02cc378c776b8d0c6743b5df197b 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.14_04
+VERSION=0.14_05
 DISTNAME=bse-$(VERSION)
 DISTBUILD=$(DISTNAME)
 DISTTAR=../$(DISTNAME).tar
index be9b39ca50d27c07c32ed0846ea6fcbcc59bf19e..6cca06a9892fbe30938608d160fb4165a53ee19c 100644 (file)
@@ -257,6 +257,14 @@ create table order_item (
   -- options (if any) specified on this item in the order
   options varchar(255) not null,
 
+  customInt1 integer null,
+  customInt2 integer null,
+  customInt3 integer null,
+
+  customStr1 varchar(255) null,
+  customStr2 varchar(255) null,
+  customStr3 varchar(255) null,
+
   primary key (id),
   index order_item_order(orderId, id)
 );
index 23981d457e22c2890fde6a75206e555f21caf341..5c0aef1b61e686a5d5ff748c05f62e61378a3385 100644 (file)
@@ -103,7 +103,7 @@ sub req_edit {
   else {
     if (keys %$errors) {
       my %work = %$errors;
-      my @msgs = delete @work{$cgi->param()};
+      my @msgs = grep defined, delete @work{$cgi->param()};
       push @msgs, values %work;
       $msg = join "<br />", map escape_html($_), @msgs;
     }
@@ -305,7 +305,7 @@ sub req_addform {
   else {
     if (keys %$errors) {
       my %work = %$errors;
-      my @msgs = delete @work{$cgi->param()};
+      my @msgs = grep defined, delete @work{$cgi->param()};
       push @msgs, values %work;
       $msg = join "<br />", map escape_html($_), grep $_, @msgs;
     }
index 930d684ce1f91d10735c4a4684cded472e9b91e7..fe7247cabaa67d1804e90ba7f294420cd33276f6 100644 (file)
@@ -32,7 +32,7 @@ sub checkout_update {
 }
 
 sub order_save {
-  my ($class, $cgi, $order, $items, $cfg) = @_;
+  my ($class, $cgi, $order, $items, $products, $custom, $cfg) = @_;
 
   return 1;
 }
@@ -151,7 +151,7 @@ extra tags for the checkout page.
 This is called by the checkupdate target of shop.pl, which does
 nothing else.
 
-=item order_save($cgi, $order, $items)
+=item order_save($cgi, $order, $items, $products, $custom, $cfg)
 
 Called immediately before the order is saved.  You can perform extra
 validation and die() with an error message describing the problem, or
index 8f6f3a9717a048600aba75782c73e0224d55f450..5f6d435cb1edc409d7beb179bb1e25c4b0a691ff 100644 (file)
@@ -73,7 +73,7 @@ EOS
    getOrderItemByOrderId => 'select * from order_item where orderId = ?',
    addOrder => 'insert orders values(null,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
    replaceOrder => 'replace orders values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
-   addOrderItem => 'insert order_item values(null,?,?,?,?,?,?,?)',
+   addOrderItem => 'insert order_item values(null,?,?,?,?,?,?,?,?,?,?,?,?,?)',
    getOrderByUserId => 'select * from orders where userId = ?',
 
    getOrderItemByProductId => 'select * from order_item where productId = ?',
index deba9cdcfe5ad0bfe2120dea198281cd8f5882e1..4bebec4160ff3800deb7f2402acb12c30c313e55 100644 (file)
@@ -42,6 +42,7 @@ sub tie_it {
   unless ($sessionid) {
   # save the new sessionid
     my $domain = $ENV{HTTP_HOST};
+    $domain =~ s/:\d+$//;
     my $cookie = CGI::Cookie->new(-name=>'sessionid', -value=>$session->{_session_id}, 
                                  -expires=>$lifetime, -path=>"/",
                                  -domain=>$domain);
index 4142d1861552b453e5ac94a7198cb1fb301895fe..ede48126b64a050fc2037c007a4f3c72ac21d749 100644 (file)
@@ -3,7 +3,8 @@ use strict;
 use vars qw(@ISA @EXPORT_OK);
 @ISA = qw/Exporter/;
 @EXPORT_OK = qw/shop_cart_tags cart_item_opts nice_options shop_nice_options
-                total shop_total load_order_fields basic_tags need_logon/;
+                total shop_total load_order_fields basic_tags need_logon
+                get_siteuser payment_types/;
 use Constants qw/:shop/;
 use BSE::Util::SQL qw(now_sqldate);
 use BSE::Util::Tags;
@@ -223,7 +224,7 @@ sub load_order_fields {
   $order->{total} += $cust_class->total_extras(\@cart, \@products, 
                                             $session->{custom});
 
-  if (need_logon($cfg, \@cart, \@products, $session)) {
+  if (need_logon($cfg, \@cart, \@products, $session, $q)) {
     $$error = "Your cart contains some file-based products.  Please register or logon";
     return 0;
   }
@@ -269,10 +270,15 @@ sub basic_tags {
 }
 
 sub need_logon {
-  my ($cfg, $cart, $cart_prods, $session) = @_;
+  my ($cfg, $cart, $cart_prods, $session, $cgi) = @_;
 
+  defined $cgi or confess "No cgi parameter supplied";
+  
   my $reg_if_files = $cfg->entryBool('shop', 'register_if_files', 1);
-  if (!$session->{userid} && $reg_if_files) {
+
+  my $user = get_siteuser($session, $cfg, $cgi);
+
+  if (!$user && $reg_if_files) {
     require 'ArticleFiles.pm';
     # scan to see if any of the products have files
     for my $prod (@$cart_prods) {
@@ -284,11 +290,102 @@ sub need_logon {
   }
 
   my $require_logon = $cfg->entryBool('shop', 'require_logon', 0);
-  if (!$session->{userid} && $require_logon) {
+  if (!$user && $require_logon) {
     return ("register before checkout", "shop/logonrequired");
   }
   
   return;
 }
 
+sub get_siteuser {
+  my ($session, $cfg, $cgi) = @_;
+
+  require SiteUsers;
+  if ($cfg->entryBool('custom', 'user_auth')) {
+    my $custom = Util::custom_class($cfg);
+    
+    return $custom->siteuser_auth($session, $cgi, $cfg);
+  }
+  else {
+    my $userid = $session->{userid}
+      or return;
+    my $user = SiteUsers->getBy(userId=>$userid)
+      or return;
+    
+    return $user;
+  }
+}
+
+=item payment_types($cfg)
+
+Returns payment type ids, and hashes describing each of the configured
+payment types.
+
+These are used to generate the tags used for testing whether payment
+types are available.  Also used for validating payment type
+information.
+
+=cut
+
+sub payment_types {
+  my ($cfg) = @_;
+
+  my %types =
+    (
+     0 => { 
+          id => 0, 
+          name => 'CC', 
+          desc => 'Credit Card',
+          require => [ qw/cardNumber cardExpiry/ ],
+         },
+     1 => { 
+          id => 1, 
+          name => 'Cheque', 
+          desc => 'Cheque',
+          require => [],
+         },
+     2 => {
+          id => 2,
+          name => 'CallMe',
+          desc => 'Call customer for payment',
+          require => [],
+         },
+    );
+
+  my @payment_types = split /,/, $cfg->entry('shop', 'payment_types', '0');
+  
+  for my $type (@payment_types) {
+    my $hash = $types{$type}; # avoid autovivification
+    my $name = $cfg->entry('payment type names', $type, $hash->{name});
+    my $desc = $cfg->entry('payment type descs', $type, 
+                          $hash->{desc} || $name);
+    my @require = $hash->{require} ? @{$hash->{require}} : ();
+    @require = split /,/, $cfg->entry('payment type required', $type,
+                                     join ",", @require);
+    if ($name && $desc) {
+      $types{$type} = 
+       {
+        id => $type,
+        name => $name, 
+        desc => $desc,
+        require => \@require,
+       };
+    }
+  }
+
+  for my $type (@payment_types) {
+    unless ($types{$type}) {
+      print STDERR "** payment type $type doesn't have a name defined\n";
+      next;
+    }
+    $types{$type}{enabled} = 1;
+  }
+
+  use Data::Dumper;
+  print STDERR Dumper \%types;
+
+  return values %types;
+}
+
+
 1;
index dba11ecfb2355095980c064b4f293b83ad6fac0b..12179b77156e297d9e41759840eba9ae2f8d48e6 100644 (file)
@@ -323,9 +323,12 @@ sub _get_user {
     my $uid = $cgi->param('u');
     defined $uid && $uid =~ /^\d+$/ && defined $password
       or do { refresh_to($ENV{SCRIPT}."?nopassword=1"); return };
-      
+
     my $user = SiteUsers->getByPkey($uid)
       or do { refresh_to($ENV{SCRIPT}."?nopassword=1"); return };
+
+    $user->{password} eq $password
+      or do { refresh_to($ENV{SCRIPT}."?nopassword=1"); return };
     
     return $user;
   }
index 0cbbed140f90ddef07b7120603489c293cb7833c..b898ffa98ad1bef999fccb1a45de380266ca7361 100644 (file)
@@ -6,7 +6,8 @@ use vars qw/@ISA/;
 @ISA = qw/Squirrel::Row/;
 
 sub columns {
-  return qw/id productId orderId units price wholesalePrice gst options/;
+  return qw/id productId orderId units price wholesalePrice gst options
+            customInt1 customInt2 customInt3 customStr1 customStr2 customStr3/;
 }
 
 1;
index 4641ce5a84ad8626cbfd36570c499b244d6f7a4e..513223242bf6fc401bfd56aded52d094a13131d3 100644 (file)
@@ -186,7 +186,7 @@ sub with {
       $result = $self->replace_template($result, $acts);
     }
 
-    return $code->(@args, $result, $sep, $acts, $name, $self);
+    return $code->(@args, $args, $result, $sep, $acts, $name, $self);
   }
   else {
     return $orig;
index 8702684170f4acd584f789802896a850c24553cc..c6ae083130e10d72dc43bee47145030124897c6b 100755 (executable)
@@ -13,10 +13,13 @@ use CGI::Cookie;
 use Util qw(refresh_to);
 use BSE::Mail;
 use BSE::Shop::Util qw/shop_cart_tags cart_item_opts nice_options total 
-                       basic_tags load_order_fields need_logon/;
+                       basic_tags load_order_fields need_logon get_siteuser
+                       payment_types/;
 use BSE::Session;
 use BSE::Cfg;
 use Util qw/refresh_to/;
+use BSE::Util::Tags qw(tag_hash);
+
 
 my $cfg = BSE::Cfg->new();
 
@@ -46,13 +49,13 @@ my $toEmail= $cfg->entry('shop', 'to_email', $SHOP_TO_EMAIL);
 use constant PAYMENT_CC => 0;
 use constant PAYMENT_CHEQUE => 1;
 use constant PAYMENT_CALLME => 2;
-my %valid_payment_types = 
-  ( 
-   PAYMENT_CC()     =>1, 
-   PAYMENT_CHEQUE() =>1, 
-   PAYMENT_CALLME() =>1
-  );
-my %payment_names = qw(CC 0 Cheque 1 CallMe 2);
+my %valid_payment_types = 
+  ( 
+   PAYMENT_CC()     =>1, 
+   PAYMENT_CHEQUE() =>1, 
+   PAYMENT_CALLME() =>1
+  );
+# my %payment_names = ;
 
 my $urlbase = $cfg->entryVar('site', 'url');
 my $securlbase = $cfg->entryVar('site', 'secureurl');
@@ -247,16 +250,12 @@ sub checkout {
 
   my @cart_prods = map { Products->getByPkey($_->{productId}) } @cart;
 
-  if (my ($msg, $id) = need_logon($cfg, \@cart, \@cart_prods, \%session)) {
+  if (my ($msg, $id) = need_logon($cfg, \@cart, \@cart_prods, \%session, $CGI::Q)) {
     refresh_logon($msg, $id);
     return;
   }
 
-  my $user;
-  if ($session{userid}) {
-    require 'SiteUsers.pm';
-    $user = SiteUsers->getBy(userId=>$session{userid});
-  }
+  my $user = get_siteuser(\%session, $cfg, $CGI::Q);
 
   $session{custom} ||= {};
   my %custom_state = %{$session{custom}};
@@ -266,8 +265,8 @@ sub checkout {
 
   my $noencrypt = $cfg->entryBool('shop', 'noencrypt', 0);
 
-  my @payment_types = split /,/, $cfg->entry('shop', 'payment_types', '0');
-  @payment_types = grep $valid_payment_types{$_}, @payment_types;
+  my @pay_types = payment_types($cfg);
+  my @payment_types = map $_->{id}, grep $_->{enabled}, @pay_types;
   if ($noencrypt) {
     @payment_types = grep $_ ne PAYMENT_CC, @payment_types;
     @payment_types or @payment_types = ( PAYMENT_CALLME );
@@ -305,12 +304,19 @@ sub checkout {
      $cust_class->checkout_actions(\%acts, \@cart, \@cart_prods, 
                                   \%custom_state, $CGI::Q, $cfg),
      ifMultPaymentTypes => @payment_types > 1,
+     ifUser => defined $user,
+     user => $user ? [ \&tag_hash, $user ] : '',
     );
-  for my $name (keys %payment_names) {
-    my $id = $payment_names{$name};
+  my $payment;
+  $olddata and $payment = param('paymentType');
+  defined $payment or $payment = $payment_types[0];
+  for my $type (@pay_types) {
+    my $id = $type->{id};
+    my $name = $type->{name};
     $acts{"if${name}Payments"} = exists $payment_types{$id};
     $acts{"if${name}FirstPayment"} = $payment_types[0] == $id;
     $acts{"checkedIfFirst$name"} = $payment_types[0] == $id ? "checked " : "";
+    $acts{"checkedPayment$name"} = $payment == $id ? 'checked="checked" ' : "";
   }
   $session{custom} = \%custom_state;
 
@@ -447,7 +453,7 @@ sub prePurchase {
   use BSE::Util::SQL qw(now_sqldatetime);
   $order{orderDate} = now_sqldatetime();
 
-  if (my ($msg, $id) = need_logon($cfg, \@cart, \@products, \%session)) {
+  if (my ($msg, $id) = need_logon($cfg, \@cart, \@products, \%session, $CGI::Q)) {
     refresh_logon($msg, $id);
     return;
   }
@@ -563,8 +569,11 @@ sub purchase {
 
   my $noencrypt = $cfg->entryBool('shop', 'noencrypt', 0);
 
-  my @payment_types = split /,/, $cfg->entry('shop', 'payment_types', '0');
-  @payment_types = grep $valid_payment_types{$_}, @payment_types;
+  my @pay_types = payment_types($cfg);
+  my %pay_types = map { $_->{id} => $_ } @pay_types;
+  use Data::Dumper;
+  print STDERR Dumper \%pay_types;
+  my @payment_types = map $_->{id}, grep $_->{enabled}, @pay_types;
   if ($noencrypt) {
     @payment_types = grep $_ ne PAYMENT_CC, @payment_types;
     @payment_types or @payment_types = ( PAYMENT_CALLME );
@@ -580,8 +589,7 @@ sub purchase {
   $payment_types{$paymentType}
     or return checkout("Invalid payment type");
 
-  push @required, qw(cardHolder cardExpiry)
-    if $paymentType == PAYMENT_CC;
+  push @required, @{$pay_types{$paymentType}{require}};
 
   for my $field (@required) {
     defined(param($field)) && length(param($field))
@@ -673,7 +681,7 @@ sub purchase {
     $order{gst} += $item->{gst} * $item->{units};
   }
 
-  if (my ($msg, $id) = need_logon($cfg, \@cart, \@products, \%session)) {
+  if (my ($msg, $id) = need_logon($cfg, \@cart, \@products, \%session, $CGI::Q)) {
     refresh_logon($msg, $id);
     return;
   }
@@ -691,8 +699,9 @@ sub purchase {
   $order{filled} = 0;
   $order{paidFor} = 0;
 
-  if ($session{userid}) {
-    $order{userId} = $session{userid};
+  my $user = get_siteuser(\%session, $cfg, $CGI::Q);
+  if ($user) {
+    $order{userId} = $user->{userId};
   }
   else {
     $order{userId} = '';
@@ -778,8 +787,9 @@ sub purchase {
      ifOptions => sub { @options },
      options => sub { nice_options(@options) },
     );
-  for my $name (keys %payment_names) {
-    my $id = $payment_names{$name};
+  for my $type (@pay_types) {
+    my $id = $type->{id};
+    my $name = $type->{name};
     $acts{"if${name}Payment"} = $order->{paymentType} == $id;
   }
   send_order($order, \@items, \@products, $noencrypt);
@@ -788,7 +798,14 @@ sub purchase {
 }
 
 sub tag_with_wrap {
-  
+  my ($args, $text) = @_;
+
+  my $margin = $args =~ /^\d+$/ && $args > 30 ? $args : 70;
+
+  require Text::Wrap;
+  $Text::Wrap::columns = $margin;
+
+  return Text::Wrap::fill('', '', split /\n/, $text);
 }
 
 # sends the email order confirmation and the PGP encrypted
@@ -806,7 +823,6 @@ sub send_order {
   my $item_index = -1;
   my @options;
   my $option_index;
-  require BSE::Util::Tags;
   my %acts;
   %acts =
     (
index 0c35fd7e0a6ed32e82cb47764ff26e3fbfd655eb..077924445736b75b0a56a47c330be2536736e3fc 100644 (file)
@@ -10,6 +10,83 @@ Maybe I'll add some other bits here.
 
 =head1 CHANGES
 
+=head2 0.14_05
+
+This is still a development release.
+
+There have been database changes in this release.  You will need to
+run upgrade_mysql.pl.
+
+=over
+
+=item *
+
+CRITICAL: nopassword wasn't checking the password at all.  If you
+don't want to upgrade completely you can include just the three line
+change that checks the password.
+
+=item *
+
+blank lines are no longer included in the error messages on add/edit
+site user validation errors
+
+=item *
+
+the shop now uses the site user authentication hook
+
+=item *
+
+the domain value sent to the browser in cookies now has the port
+number stripped.
+
+=item *
+
+you can now configure new payment types through the [payment type
+names], [payment type descs] and [payment type required] sections of
+the configuration file.
+
+=item *
+
+various templates include custom sub-templates which can be used to
+add custom payment types.
+
+=item *
+
+new <:checkedPaymentI<payment-type-name> :> tag on the checkout form
+to make retaining the selected payment type easier.
+
+=item *
+
+new basic template facility, C<with> allows sections of text to be
+processed by a tag:
+
+  <:with begin I<tagname> :>
+    I<some text>
+  <:with end I<tagname :>
+
+=item *
+
+<:with ... wrap:> tag added to order email tag sets:
+
+  <:with begin wrap:>Special Instructions: <:order instructions:><:with end wrap:>
+
+=item *
+
+the site user editor would include empty lines for valid fields in
+error messages
+
+=item *
+
+cookies were being generated with the port numbers included in the
+domain value.
+
+=item *
+
+billing address fields are now included in the default checkout form,
+optionally
+
+=back
+
 =head2 0.14_04
 
 This is a development release and is not suitable for production use.
index 743c7cf1c32003b483e43428ae6b1fa743e91d5b..b3be45d61d837b2fd37edc8f9df7f123a304e251 100644 (file)
@@ -456,6 +456,9 @@ The possible payment types are:
 
 =back
 
+Other types can be added by adding entries to the [payment type names]
+and [payment type descs] sections.
+
 =item address1
 
 =item address2
@@ -753,6 +756,29 @@ allowing users to register themselves.
 
 =back
 
+=head2 [payment type names]
+
+This section and [payment type descs] are used to configure new
+paymeny type ids.
+
+The key is the integer representing the payment type.  The value is
+the name used in tags for checking the payment type.
+
+You can also add a description (currently unused) to [payment type
+descs].
+
+You should use numbers starting from 10 to avoid conflicts with future
+BSE payment types.
+
+=head2 [payment type descs]
+
+See [payment type names].
+
+=head2 [payment type required]
+
+Set the key given by the payment type id to a value of a
+comma-separated list of fields required for that payment type.
+
 =head1 AUTHOR
 
 Tony Cook <tony@develop-help.com>
index b568881175d18515fdaf89afccd115dd5a27c4ca..b1ab9d2dbf3840ef8b2cba1e0ab54d1282ae8229 100644 (file)
             leadTime:></td>
           </tr>
           <tr> 
-            <th align="left" bgcolor="#FFFFFF">Retail price:</th>
+            <th align="left" bgcolor="#FFFFFF"><:cfg "product fields" retailPrice "Retail price":>:</th>
             <td bgcolor="#FFFFFF">$ 
               <:ifFieldPerm retailPrice:><input type="text" name="retailPrice" value="<:old retailPrice money product retailPrice:>" size=7>
               (0.00)<:or:><:money product retailPrice:><:eif:> </td>
index 58113122d01012822e85ca06939b960a7755ce68..dca2d0004da539563a6fae8367d4f7cb45988378 100644 (file)
@@ -42,6 +42,7 @@
     <td><:order delivCountry:></td>
     <td><:order billCountry:></td>
   </tr>
+  <:include custom/order_detail.include:>
 </table>
 
 <br>
@@ -88,7 +89,7 @@
 <:ifEq [order paymentType] "0":><p>Payment made by credit card.</p><:or:><:eif:>
 <:ifEq [order paymentType] "1":><p>Payment will be made by cheque.</p><:or:><:eif:>
 <:ifEq [order paymentType] "2":><p>Contact the customer to arrange for payment.</p><:or:><:eif:>
-
+<:include custom/order_detail_payment.include:>
 <:if Order filled:>
 <p>This order was filled on <:date order whenFilled:> by <:order whoFilled:>.</p>
 <:or Order:>
index f9876c8c22bf22ca23c730013cd4aab499b2174d..a7eaae7028415158d43673b92961d7e63d82d13d 100644 (file)
@@ -237,10 +237,64 @@ else {
     </tr>
   </table>
   <p>&nbsp; </p>
+ <:if Cgi need_billing:>
+  <font face="Verdana, Arial, Helvetica, sans-serif" size="3"><input type="checkbox" name="need_billing" checked="checked" onClick="this.form.checkupdate.click()" /> <b>Billing Details:</b></font> 
+   
+  <hr size="1" noshade>
+  <table border="0" cellspacing="0" cellpadding="0">
+    <tr> 
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> First 
+        Name:</font></td>
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
+        <input type="Text" name="billFirstName" size=34 value="<:old billFirstName:>">
+        *</font></td>
+    </tr>
+    <tr> 
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Last Name:</font></td>
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
+        <input type="Text" name="billLastName" size=34 value="<:old billLastName:>">
+        *</font></td>
+    </tr>
+    <tr> 
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Address:</font></td>
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
+        <input type="Text" name="billStreet" size=34 value="<:old billStreet:>">
+        *</font></td>
+    </tr>
+    <tr> 
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> City:</font></td>
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
+        <input type="Text" name="billSuburb" size=34 value="<:old billSuburb:>">
+        *</font></td>
+    </tr>
+    <tr> 
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Postcode:</font></td>
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
+        <input type="Text" name="billPostCode" size=10 value="<:old billPostCode:>">
+        *</font></td>
+    </tr>
+    <tr> 
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> State:</font></td>
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
+        <input type="Text" name="billState" size=10 value="<:old billState:>">
+        *</font></td>
+    </tr>
+    <tr> 
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Country:</font></td>
+      <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
+        <input type="Text" name="billCountry" size=20 value="<:old billCountry:>">
+        *</font></td>
+    </tr>
+  </table>
+  <p>&nbsp; </p>
+ <:or Cgi:>
+   <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input type="checkbox" name="need_billing" onClick="this.form.checkupdate.click()" /> Billing details different to shipping</font></p>
+ <:eif Cgi:>
+<:include custom/checkout.include:>
   <font face="Verdana, Arial, Helvetica, sans-serif" size="3"> <b>Payment Details:</b></font> 
   <hr size="1" noshade>
   <:if CCPayments :>
-  <:if MultPaymentTypes:><p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><input type=radio name=paymentType value=0 <:checkedIfFirstCC:>> Credit Card</font></p><:or MultPaymentTypes:><input type=hidden name=paymentType value=0><:eif MultPaymentTypes:>
+  <:if MultPaymentTypes:><p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><input type=radio name=paymentType value=0 <:checkedPaymentCC:>> Credit Card</font></p><:or MultPaymentTypes:><input type=hidden name=paymentType value=0><:eif MultPaymentTypes:>
   <table border="0" cellspacing="0" cellpadding="0">
     <tr> 
       <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Name on 
@@ -276,7 +330,7 @@ else {
   </table>
   <:or CCPayments:><:eif CCPayments:>
   <:if ChequePayments:>
-  <:if MultPaymentTypes:><p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input type=radio name=paymentType value=1 <:checkedIfFirstCheque:>/>
+  <:if MultPaymentTypes:><p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input type=radio name=paymentType value=1 <:checkedPaymentCheque:>/>
     Cheque</font></p><:or MultPaymentTypes:><input type=hidden name=paymentType value=1><:eif MultPaymentTypes:>
   <p> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Please send your cheque to:</font></p>
   <ul> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <:cfg shop address1:><br />
@@ -284,7 +338,7 @@ else {
      <:cfg shop address3:></font></ul>
   <:or ChequePayments:><:eif ChequePayments:>
   <:if CallMePayments:>
-   <:if MultPaymentTypes:><p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><input type=radio name=paymentType value=2 <:checkedIfFirstCallMe:>/> Contact me for billing details</font></p>
+   <:if MultPaymentTypes:><p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><input type=radio name=paymentType value=2 <:checkedPaymentCallMe:>/> Contact me for billing details</font></p>
    <:or MultPaymentTypes:>
      <input type=hidden name=paymentType value=2>
      <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">We will call you to arrange for payment.</font></p>
@@ -292,6 +346,7 @@ else {
   <:or CallMePayments:>
 
   <:eif CallMePayments:>
+  <:include custom/payment_type.include:>
   <p>&nbsp; </p>
   <font face="Verdana, Arial, Helvetica, sans-serif" size="3"> <b>Tax Invoice 
   / Receipt &amp; Delivery Costs:</b></font> 
@@ -304,6 +359,7 @@ else {
     </tr>
   </table>
   <p>
+    <input type="submit" value="Update" name="checkupdate" />
     <input type="submit" value="Purchase Now" name="purchase">
     <input type="reset" value="Reset Form" name="reset">
   </p>
diff --git a/site/templates/custom/checkout.include b/site/templates/custom/checkout.include
new file mode 100644 (file)
index 0000000..b92ee3d
--- /dev/null
@@ -0,0 +1,3 @@
+<:if Eq 0 1:>
+<!-- replace this with any extra fields you need -->
+<:or Eq:><:eif Eq:>
\ No newline at end of file
diff --git a/site/templates/custom/order_detail.include b/site/templates/custom/order_detail.include
new file mode 100644 (file)
index 0000000..a888f90
--- /dev/null
@@ -0,0 +1 @@
+<!-- custom/order_detail.include -->
\ No newline at end of file
diff --git a/site/templates/custom/order_detail_payment.include b/site/templates/custom/order_detail_payment.include
new file mode 100644 (file)
index 0000000..8f61e2d
--- /dev/null
@@ -0,0 +1 @@
+<!-- custom/order_detail_payment.include -->
\ No newline at end of file
diff --git a/site/templates/custom/payment_type.include b/site/templates/custom/payment_type.include
new file mode 100644 (file)
index 0000000..21bb1c0
--- /dev/null
@@ -0,0 +1,3 @@
+<:if Eq 0 1:>
+<!-- use this file to add extra custom payment types -->
+<:or Eq:><:eif Eq:>
\ No newline at end of file
diff --git a/site/templates/custom/payment_type_email.include b/site/templates/custom/payment_type_email.include
new file mode 100644 (file)
index 0000000..86225c2
--- /dev/null
@@ -0,0 +1,3 @@
+<:if Eq 0 1:>
+<!-- use this file to add extra custom payment types to the emails -->
+<:or Eq:><:eif Eq:>
\ No newline at end of file
index 289094642d7811576fac5a8e7e5bfb2c47aea10a..c3011dcb3d146f553551ea0dd5b5d79f92700029 100644 (file)
@@ -23,4 +23,8 @@ Product                                   Units  Price   Extended
 <:ifEq [order paymentType] "0" :>Paid by credit card.<:or:><:eif
 :><:ifEq [order paymentType] "1" :>Will be paid by cheque<:or
 :><:eif:><:ifEq [order paymentType] "2"
-:>We will call you to arrange for payment<:or:><:eif:>
+:>We will call you to arrange for payment<:or:><:eif:><:
+include custom/payment_type_email.include:>
+<:if Order instructions:>
+<:with begin wrap:>Special Instructions: <:order instructions:><:with end wrap:>
+<:or Order:><:eif Order:>
index 266d0b409a270de009736e39419033b715ac608b..521a000429d4012e51d28b0aa8f79bee8f8fd861 100644 (file)
@@ -27,4 +27,8 @@ Name on Card : <:order ccName:>
 Card Type    : <:order ccType :><:or:><:eif
 :><:ifEq [order paymentType] "1" :>Will be paid by cheque<:or
 :><:eif:><:ifEq [order paymentType] "2"
-:>Please call the customer to arrange for payment<:or:><:eif:>
+:>Please call the customer to arrange for payment<:or:><:eif:><:
+include custom/payment_type_email.include:>
+<:if Order instructions:>
+<:with begin wrap:>Special Instruction: <:order instructions:><:with end wrap:>
+<:or Order:><:eif Order:>
index cccca499e0a521b6cea2fa4247d481c1456ab52b..1ed1b44abef7c849f3797ae19df8e927f0770b50 100644 (file)
@@ -1,7 +1,7 @@
 #!perl -w
 # Basic tests for Squirrel::Template
 use strict;
-use Test::More tests => 12;
+use Test::More tests => 13;
 
 sub template_test($$$$;$);
 
@@ -24,6 +24,7 @@ SKIP: {
      repeat => \$repeat_value,
      strref => \$str,
      str => $str,
+     with_upper => \&tag_with_upper,
     );
   template_test("<:str:>", "ABC", "simple", \%acts);
   template_test("<:strref:>", "ABC", "scalar ref", \%acts);
@@ -55,7 +56,8 @@ IN
   template_test($switch, "TWO", "switch2", \%acts, "both");
   $str = "DEF";
   template_test($switch, "DEF", "switch def", \%acts, "both");
-  
+
+  template_test("<:with begin upper:>Alpha<:with end upper:>", "ALPHA", "with", \%acts);
 }
 
 sub template_test ($$$$;$) {
@@ -123,3 +125,9 @@ sub get_expr {
   
   @values;
 }
+
+sub tag_with_upper {
+  my ($args, $text) = @_;
+
+  return uc($text);
+}
index 276214c53a1859e0eb5d74df8fc858cc2736d366..b8810005da2f3c27d3350c7c1a4d35ad66e6fe77 100644 (file)
--- a/test.cfg
+++ b/test.cfg
@@ -50,3 +50,13 @@ site users.billing_on_main_opts=0
 paths.libraries=/home/tony/dev/bse/tandb_dealer/cvs/modules
 paths.siteuser_passwd=/home/httpd/bsetest/data/supasswd
 custom.user_auth=1
+product fields.retailPrice=Dealer Price Inc GST
+paths.local_templates=/home/tony/dev/bse/tandb_dealer/cvs/templates
+shop.payment_types=1,2,10,11,12
+payment type names.10=DirectDeposit
+payment type names.11=FaxProForma
+payment type names.12=EmailProForma
+payment type required.11=facsimile
+
+dealer.bsb=999999
+dealer.accountno=77777777