Index: openacs-4/packages/dotlrn-ecommerce/sql/oracle/dotlrn-ecommerce-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/sql/oracle/dotlrn-ecommerce-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn-ecommerce/sql/oracle/dotlrn-ecommerce-create.sql 22 Jul 2005 10:56:09 -0000 1.2 +++ openacs-4/packages/dotlrn-ecommerce/sql/oracle/dotlrn-ecommerce-create.sql 30 Jul 2005 22:19:00 -0000 1.3 @@ -61,7 +61,7 @@ create table dotlrn_ecommerce_transactions ( order_id integer references ec_orders on delete cascade not null unique, - method char(1) check (method in ('cc', 'internal_account', 'check')) not null, + method char(1) check (method in ('cc', 'internal_account', 'check', 'cash', 'invoice', 'scholarship')) not null, internal_account clob ); Index: openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql,v diff -u -r1.15 -r1.16 --- openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 25 Jul 2005 13:25:13 -0000 1.15 +++ openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 30 Jul 2005 22:17:00 -0000 1.16 @@ -64,7 +64,7 @@ create table dotlrn_ecommerce_transactions ( order_id integer references ec_orders on delete cascade not null unique, - method text check (method in ('cc', 'internal_account', 'check')) not null, + method text check (method in ('cc', 'internal_account', 'check', 'cash', 'invoice', 'scholarship')) not null, internal_account text ); Index: openacs-4/packages/dotlrn-ecommerce/sql/postgresql/upgrade/upgrade-0.1d1-0.1d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/sql/postgresql/upgrade/upgrade-0.1d1-0.1d2.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/sql/postgresql/upgrade/upgrade-0.1d1-0.1d2.sql 30 Jul 2005 22:17:00 -0000 1.1 @@ -0,0 +1,12 @@ +-- +-- packages/dotlrn-ecommerce/sql/postgresql/upgrade/upgrade-0.1d1-0.1d2.sql +-- +-- @author Roel Canicula (roelmc@pldtdsl.net) +-- @creation-date 2005-07-31 +-- @arch-tag: 07ad1a3f-f53c-4f51-ae9a-cab8f9e69642 +-- @cvs-id $Id: upgrade-0.1d1-0.1d2.sql,v 1.1 2005/07/30 22:17:00 roelc Exp $ +-- + +-- Add payment methods +alter table dotlrn_ecommerce_transactions drop constraint dotlrn_ecommerce_transactions_method; +alter table dotlrn_ecommerce_transactions add constraint dotlrn_ecommerce_transactions_method check (method in ('cc', 'internal_account', 'check', 'cash', 'invoice', 'scholarship')); \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form-2.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form-2.tcl 19 Jul 2005 18:15:09 -0000 1.8 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form-2.tcl 30 Jul 2005 22:17:00 -0000 1.9 @@ -827,15 +827,19 @@ (:order_id, 'internal_account', :internal_account) } } - } elseif { $method == "check" } { + } elseif { $method == "check" || + $method == "cash" || + $method == "invoice" || + $method == "scholarship" + } { if { [db_0or1row check_transaction { select 1 from dotlrn_ecommerce_transactions where order_id = :order_id }] } { db_dml update_transaction_check { update dotlrn_ecommerce_transactions - set method = 'check', + set method = :method, internal_account = null where order_id = :order_id } @@ -844,7 +848,7 @@ insert into dotlrn_ecommerce_transactions (order_id, method) values - (:order_id, 'check') + (:order_id, :method) } } } Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form.tcl,v diff -u -r1.15 -r1.16 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form.tcl 16 Jul 2005 12:51:06 -0000 1.15 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form.tcl 30 Jul 2005 22:17:00 -0000 1.16 @@ -22,6 +22,8 @@ {creditcard_expire_2 ""} } +set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] + set form [rp_getform] ns_set delkey $form creditcard_expires @@ -525,9 +527,28 @@ if { [empty_string_p [set payment_methods [parameter::get -parameter PaymentMethods]]] } { lappend payment_methods cc } + +set method_count 0 +set new_payment_methods [list] foreach payment_method [split $payment_methods] { - set ${payment_method}_p 1 + set _payment_method [split $payment_method :] + if { [llength $_payment_method] == 2 } { + lappend new_payment_methods [set payment_method [lindex $_payment_method 0]] + switch [lindex $_payment_method 1] { + admin { + if { $admin_p } { + set ${payment_method}_p 1 + } else { + continue + } + } + } + } else { + set ${payment_method}_p 1 + lappend new_payment_methods $payment_method + } + switch $payment_method { internal_account { lappend method_options [list "Internal account number" internal_account] @@ -554,28 +575,53 @@ "A full credit card expiration date (month and year) is required" } } + cash { + lappend method_options [list "User pays cash" cash] + } + invoice { + lappend method_options [list "Invoice" invoice] + } + scholarship { + lappend method_options [list "Scholarship" scholarship] + } } + incr method_count } -set method_count [llength [split $payment_methods]] +set payment_methods $new_payment_methods if { $method_count > 1 } { ad_form -extend -name checkout -form { {-section "Payment Information"} {method:text(radio) {label "Select a payment method"} {options {$method_options}}} - {internal_account:text,optional {label "Internal Account"}} } + + if { [exists_and_equal internal_account_p 1] } { + ad_form -extend -name checkout -form { + {internal_account:text,optional {label "Internal Account"}} + } + } } elseif { $method_count == 1 } { ad_form -extend -name checkout -export { {method "[lindex [split $payment_methods] 0]"} } -form {} } else { ad_form -extend -name checkout -export { {method cc} } -form {} } if { [info exists cc_p] } { - ad_form -extend -name checkout -form { - {-section "Credit card information"} - {creditcard_number:text,optional {label "Credit card number"}} - {creditcard_type:text(select),optional {label Type} {options {{"Please select one" ""} {VISA v} {MasterCard m} {"American Express" a}}}} - {creditcard_expires:text(inform),optional {label Expires} {value $ec_expires_widget}} + if { $method_count == 1 } { + # The creditcard_expires field is a hack, improve it + ad_form -extend -name checkout -form { + {-section "Credit card information"} + {creditcard_number:text {label "Credit card number"}} + {creditcard_type:text(select) {label Type} {options {{"Please select one" ""} {VISA v} {MasterCard m} {"American Express" a}}}} + {creditcard_expires:text(inform) {label "Expires *"} {value $ec_expires_widget}} + } + } else { + ad_form -extend -name checkout -form { + {-section "Credit card information"} + {creditcard_number:text,optional {label "Credit card number"}} + {creditcard_type:text(select),optional {label Type} {options {{"Please select one" ""} {VISA v} {MasterCard m} {"American Express" a}}}} + {creditcard_expires:text(inform),optional {label "Expires"} {value $ec_expires_widget}} + } } }