Index: openacs-4/packages/dotlrn-ecommerce/lib/section.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/section.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/dotlrn-ecommerce/lib/section.tcl 6 Jul 2005 17:05:50 -0000 1.8 +++ openacs-4/packages/dotlrn-ecommerce/lib/section.tcl 7 Jul 2005 18:17:23 -0000 1.9 @@ -137,13 +137,30 @@ from dotlrn_ecommerce_section where section_id = :section_id } + + set tree_options [list] + db_foreach prerequisites { + select tree_id + from dotlrn_ecommerce_prereq_map + } { + lappend tree_options [list [category_tree::get_name $tree_id] $tree_id] + } + ad_form -extend -name add_section -form { {categories:text(category),multiple,optional {label "Categories"} {html {size 4}} {value "$community_id $package_id"} } } + + if { [llength $tree_options] > 0 } { + ad_form -extend -name add_section -form { + {prerequisites:integer(checkbox),multiple,optional {label "Check Prerequisites"} + {options {$tree_options}} + } + } + } } else { ad_form -extend -name add_section -form { {categories:text(category),multiple,optional @@ -194,6 +211,15 @@ [list "${field_identifier}:text(radio),optional" {label $field_name} {value $default_value} {options {{Yes t} {No f}}}] \ ] } + + # maxparticipants is a special field, it is created on install + # it can be empty but not zero or negative + if { $field_identifier == "maxparticipants" } { + lappend validate {maxparticipants + { $maxparticipants > 0 || [empty_string_p $maxparticipants] } + "Please enter a value greater than 0" + } + } } # Create the section for predefined sessions @@ -203,8 +229,6 @@ set sessions_list [list] } -ns_log Notice "** $sessions_list **" - if { [llength $sessions_list] } { ad_form -extend -name add_section -form { {-section "Predefined Sessions"} @@ -327,6 +351,12 @@ set member_price [template::util::currency::create "$" [lindex $member_price_split 0] [lindex $member_price_split 1] ] } } + + set prerequisites [db_list prerequisites { + select tree_id + from dotlrn_ecommerce_prereqs + where section_id = :section_id + }] } -new_data { db_transaction { # create the class instance @@ -463,6 +493,17 @@ set tree_id [parameter::get -package_id [ad_conn package_id] -parameter PatronRelationshipCategoryTree -default 0] category_tree::map -tree_id $tree_id -object_id $community_id + # Prerequisites + if { [info exists prerequisites] } { + foreach prereq $prerequisites { + db_dml insert_prereq { + insert into dotlrn_ecommerce_prereqs + (section_id, tree_id) + values + (:section_id, :prereq) + } + } + } } # HAM : let's now add a "Section Administration" portlet for this new section @@ -644,6 +685,22 @@ } } + # Prerequisites + if { [info exists prerequisites] } { + db_dml delete_prereq { + delete from dotlrn_ecommerce_prereqs + where section_id = :section_id + } + foreach prereq $prerequisites { + db_dml insert_prereq { + insert into dotlrn_ecommerce_prereqs + (section_id, tree_id) + values + (:section_id, :prereq) + } + } + } + dotlrn_ecommerce::section::flush_cache $section_id } } -after_submit { Index: openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 7 Jul 2005 00:35:32 -0000 1.8 +++ openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 7 Jul 2005 18:17:23 -0000 1.9 @@ -363,7 +363,7 @@ if { [parameter::get -package_id [ad_conn package_id] -parameter NoPayment -default 0] } { set shopping_cart_add_url [export_vars -base register/ { community_id product_id}] } else { - set shopping_cart_add_url [export_vars -base ecommerce/shopping-cart-add { user_id product_id }] + set shopping_cart_add_url [export_vars -base ecommerce/prerequisite-confirm { user_id product_id return_url }] } set member_p [dotlrn_community::member_p $community_id $user_id] @@ -448,4 +448,4 @@ set prices "" } } -} \ No newline at end of file +} 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.8 -r1.9 --- openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 23 Jun 2005 12:31:21 -0000 1.8 +++ openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 7 Jul 2005 18:17:22 -0000 1.9 @@ -65,10 +65,22 @@ internal_account text ); +-- user_field should point to person_info fields +-- maybe the person_info fields should be object attributes +create table dotlrn_ecommerce_prereq_map ( + tree_id integer references category_trees on delete cascade not null, + user_field text +); + +create table dotlrn_ecommerce_prereqs ( + section_id integer references dotlrn_ecommerce_section on delete cascade not null, + tree_id integer references category_trees on delete cascade not null +); + -- Create custom ecommerce field insert into ec_custom_product_fields (field_identifier, field_name, default_value, column_type, last_modified,last_modifying_user, modified_ip_address) values ('maxparticipants', 'Max Participants', '', 'integer', now(), '0', '0.0.0.0'); alter table ec_custom_product_field_values add maxparticipants integer; alter table ec_custom_p_field_values_audit add maxparticipants integer; \i dotlrn-ecommerce-memberships-create.sql -\i dotlrn-ecommerce-admin-portlet-create.sql \ No newline at end of file +\i dotlrn-ecommerce-admin-portlet-create.sql Index: openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-drop.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-drop.sql 19 Jun 2005 06:05:06 -0000 1.5 +++ openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-drop.sql 7 Jul 2005 18:17:22 -0000 1.6 @@ -7,8 +7,11 @@ -- @cvs-id $Id$ -- +drop table dotlrn_ecommerce_transactions; +drop table dotlrn_ecommerce_prereqs; +drop table dotlrn_ecommerce_prereq_map; drop table dotlrn_ecommerce_section; drop table person_info; select acs_rel_type__drop_role('as_session_role'); -select acs_rel_type__drop_role('ec_product_role'); \ No newline at end of file +select acs_rel_type__drop_role('ec_product_role'); Index: openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl 6 Jul 2005 16:51:08 -0000 1.10 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl 7 Jul 2005 18:17:22 -0000 1.11 @@ -325,9 +325,11 @@ {help_text "How is the purchaser related to the participant?"} {options {$tree_options}} } + {isubmit:text(submit) {label "Continue"}} {-section "Group Purchase"} {name:text,optional {label "Group Name"} {html {size 30}}} {num_members:integer(text),optional {label "Number of attendees"} {html {size 30}}} + {gsubmit:text(submit) {label "Continue"}} } lappend validate {name @@ -413,7 +415,7 @@ # if { ! $waiting_list_p } { lappend validate \ {num_members - { $num_members > 1 } + { $num_members > 1 || [template::element::get_value participant related_user] != -1 } "[_ dotlrn-ecommerce.lt_Please_enter_a_value_]" } {num_members { $num_members <= $available_slots || [empty_string_p $num_members] || [template::element::get_value participant related_user] != -1} @@ -501,11 +503,11 @@ set participant_id $group_id set item_count $num_members - ad_returnredirect [export_vars -base "../ecommerce/shopping-cart-add" { product_id user_id participant_id item_count }] + ad_returnredirect [export_vars -base "../ecommerce/prerequisite-confirm" { product_id user_id participant_id item_count return_url }] ad_script_abort } - set add_url [export_vars -base "../ecommerce/shopping-cart-add" { product_id user_id participant_id item_count }] + set add_url [export_vars -base "../ecommerce/prerequisite-confirm" { product_id user_id participant_id item_count return_url }] set participant_id [ad_decode $participant_id 0 $user_id $participant_id] if { $new_user_p } {