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.15 -r1.16 --- openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 18 Jul 2005 19:01:21 -0000 1.15 +++ openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 19 Jul 2005 18:15:10 -0000 1.16 @@ -306,7 +306,7 @@ display_template {
- + [_ dotlrn-ecommerce.add_to_cart] @@ -384,7 +384,12 @@ if { $allow_other_registration_p } { set shopping_cart_add_url [export_vars -base ecommerce/participant-change { user_id product_id return_url }] } else { - set shopping_cart_add_url [export_vars -base ecommerce/shopping-cart-add { user_id product_id }] + set return_url [export_vars -base shopping-cart-add { user_id product_id }] + if { $user_id == 0 } { + set shopping_cart_add_url [export_vars -base ecommerce/login { return_url }] + } else { + set shopping_cart_add_url ecommerce/$return_url + } } } @@ -491,6 +496,7 @@ } -default ""] switch $member_state { + "awaiting payment" - "request approval" { set waiting_p 1 } 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.10 -r1.11 --- openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 16 Jul 2005 12:51:06 -0000 1.10 +++ openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 19 Jul 2005 18:15:10 -0000 1.11 @@ -84,7 +84,7 @@ -- Add member states alter table membership_rels drop constraint membership_rel_mem_ck; -alter table membership_rels add CONSTRAINT membership_rel_mem_ck CHECK ((((((((member_state)::text = 'merged'::text) OR ((member_state)::text = 'approved'::text)) OR ((member_state)::text = 'needs approval'::text)) OR ((member_state)::text = 'banned'::text)) OR ((member_state)::text = 'rejected'::text)) OR ((member_state)::text = 'deleted'::text) OR ((member_state)::text = 'request approval'::text) OR ((member_state)::text = 'request approved'::text) OR ((member_state)::text = 'waiting list approvedq'::text))); +alter table membership_rels add CONSTRAINT membership_rel_mem_ck CHECK ((((((((member_state)::text = 'merged'::text) OR ((member_state)::text = 'approved'::text)) OR ((member_state)::text = 'needs approval'::text)) OR ((member_state)::text = 'banned'::text)) OR ((member_state)::text = 'rejected'::text)) OR ((member_state)::text = 'deleted'::text) OR ((member_state)::text = 'request approval'::text) OR ((member_state)::text = 'request approved'::text) OR ((member_state)::text = 'waitinglist approved'::text) OR ((member_state)::text = 'awaiting payment'::text) OR ((member_state)::text = 'payment approved'::text))); \i dotlrn-ecommerce-memberships-create.sql \i dotlrn-ecommerce-admin-portlet-create.sql Index: openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl 16 Jul 2005 12:51:06 -0000 1.10 +++ openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl 19 Jul 2005 18:15:10 -0000 1.11 @@ -97,7 +97,7 @@ if { [catch { - set waiting_list_p 0 +# set waiting_list_p 0 # if { ! [empty_string_p $maxparticipants] } { # db_1row attendees { # select count(*) as attendees @@ -121,25 +121,25 @@ # } # } - if { ! [empty_string_p $method] && $method != "cc" } { - set waiting_list_p 1 - } +# if { ! [empty_string_p $method] && $method != "cc" } { +# set waiting_list_p 1 +# } - if { ! $waiting_list_p } { - dotlrn_community::add_user $community_id $user_id - } else { - dotlrn_community::add_user -member_state "needs approval" $community_id $user_id +# if { ! $waiting_list_p } { + dotlrn_community::add_user $community_id $user_id +# } else { +# dotlrn_community::add_user -member_state "needs approval" $community_id $user_id # DEDS # we hit a waitlist # we need to check if we possibly notify for this community # we do the actual check if we reached the number at the end # of the proc so that we save on execution time - ns_log notice "dotlrn-ecommerce wait list notify: hit wait list on $community_id" - if {[lsearch $community_notify_waitlist_list $community_id] == -1} { - lappend community_notify_waitlist_list $community_id - } - ns_log notice "dotlrn-ecommerce wait list notify: list is now $community_notify_waitlist_list" - } +# ns_log notice "dotlrn-ecommerce wait list notify: hit wait list on $community_id" +# if {[lsearch $community_notify_waitlist_list $community_id] == -1} { +# lappend community_notify_waitlist_list $community_id +# } +# ns_log notice "dotlrn-ecommerce wait list notify: list is now $community_notify_waitlist_list" +# } if { ! [exists_and_not_null patron_id] } { set patron_id $saved_patron_id Index: openacs-4/packages/dotlrn-ecommerce/www/applications.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/applications.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 16 Jul 2005 12:51:06 -0000 1.2 +++ openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 19 Jul 2005 18:15:09 -0000 1.3 @@ -37,7 +37,12 @@ member_state { label "Member Request" display_template { + User is in waiting list + + + User has submitted an application and is waiting for approval + } } assessment_result { @@ -66,7 +71,7 @@ select pretty_name as community_name, person__name(user_id) as person_name, member_state, c.community_id, user_id as applicant_user_id from dotlrn_member_rels_full r, dotlrn_communities_all c where r.community_id = c.community_id - and member_state = 'needs approval' + and member_state in ('needs approval', 'awaiting payment') } { set approve_url [export_vars -base application-approve { community_id {user_id $applicant_user_id} }] set reject_url [export_vars -base application-reject { community_id {user_id $applicant_user_id} }] @@ -90,7 +95,7 @@ and s.course_id = c.item_id and c.assessment_id = a.item_id and a.assessment_id = ss.assessment_id - and ss.subject_id = :user_id + and ss.subject_id = :applicant_user_id order by creation_datetime desc Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl 16 Jul 2005 12:51:06 -0000 1.2 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl 19 Jul 2005 18:15:09 -0000 1.3 @@ -29,6 +29,9 @@ prereq { set member_state "request approval" } + payment { + set member_state "awaiting payment" + } } if {[catch {set rel_id [relation_add \ @@ -79,14 +82,35 @@ } } -set section_id [db_string section { - select section_id +db_1row section { + select section_id, product_id from dotlrn_ecommerce_section where community_id = :community_id -}] +} dotlrn_ecommerce::section::flush_cache $section_id +if { [db_0or1row get_assessment { + select c.assessment_id + + from dotlrn_ecommerce_section s, + dotlrn_catalogi c, + cr_items i + + where s.course_id = c.item_id + and c.item_id = i.item_id + and i.live_revision = c.course_id + and s.product_id = :product_id + + limit 1 +}] } { + if { ! [empty_string_p $assessment_id] && $assessment_id != -1 } { + ad_returnredirect [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]assessment" { assessment_id { return_url $next_url } }] + ad_script_abort + + } +} + # Redirect to application assessment if exists set assessment_id [parameter::get -parameter ApplicationAssessment -default ""] 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.7 -r1.8 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form-2.tcl 4 Jul 2005 13:39:47 -0000 1.7 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form-2.tcl 19 Jul 2005 18:15:09 -0000 1.8 @@ -617,25 +617,25 @@ where item_id = :item_id" # Get associated application assessments - set assessment_ids [list] - if { [db_0or1row get_assessment { - select c.assessment_id +# set assessment_ids [list] +# if { [db_0or1row get_assessment { +# select c.assessment_id - from dotlrn_ecommerce_section s, - dotlrn_catalogi c, - cr_items i +# from dotlrn_ecommerce_section s, +# dotlrn_catalogi c, +# cr_items i - where s.course_id = c.item_id - and c.item_id = i.item_id - and i.live_revision = c.course_id - and s.product_id = :product_id +# where s.course_id = c.item_id +# and c.item_id = i.item_id +# and i.live_revision = c.course_id +# and s.product_id = :product_id - limit 1 - }] } { - if { [lsearch $assessment_ids $assessment_id] == -1 && ! [empty_string_p $assessment_id] && $assessment_id != -1 } { - lappend assessment_ids $assessment_id - } - } +# limit 1 +# }] } { +# if { [lsearch $assessment_ids $assessment_id] == -1 && ! [empty_string_p $assessment_id] && $assessment_id != -1 } { +# lappend assessment_ids $assessment_id +# } +# } } # 3. Determine base shipping cost & put it into ec_orders @@ -905,14 +905,14 @@ set checkout_url [export_vars -base [apm_package_url_from_key dotlrn-ecommerce]ecommerce/checkout-3.tcl { {url checkout-one-form-2} user_id participant_id }] # Determine if there's an application assessment -if { [llength $assessment_ids] > 0 } { - # Since we can have multiple sections under the shopping cart, we - # can have multiple associated assessments, we keep track of all - # these assessments but for now just use the first one +# if { [llength $assessment_ids] > 0 } { +# # Since we can have multiple sections under the shopping cart, we +# # can have multiple associated assessments, we keep track of all +# # these assessments but for now just use the first one - ad_returnredirect [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]assessment" { {assessment_id "[lindex $assessment_ids 0]"} {return_url $checkout_url} }] - ad_script_abort -} +# ad_returnredirect [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]assessment" { {assessment_id "[lindex $assessment_ids 0]"} {return_url $checkout_url} }] +# ad_script_abort +# } db_release_unused_handles #rp_form_put url checkout-one-form-2 Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.adp 18 Jul 2005 19:01:21 -0000 1.4 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.adp 19 Jul 2005 18:15:09 -0000 1.5 @@ -14,7 +14,7 @@ #dotlrn-ecommerce.lt_Youve_already_purchas# - + #dotlrn-ecommerce.lt_Your_request_has_been# Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 16 Jul 2005 12:51:07 -0000 1.4 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 19 Jul 2005 18:15:09 -0000 1.5 @@ -66,78 +66,108 @@ limit 1 } -default ""] - # FIRST check if the section is full - # and if prerequisites are met - - # Is section full? - if { $member_state != "waitinglist approved" } { - set available_slots [dotlrn_ecommerce::section::available_slots $section_id] - ns_log notice "DEBUG:: $available_slots available slots, override $override_p, admin $admin_p" + if { $member_state != "approved" && + $member_state != "waitinglist approved" && + $member_state != "payment received" } { - if { $available_slots == 0 && ( $override_p != 1 || $admin_p == 0 ) } { - # No more slots left, ask user if he wants to go to - # waiting list - - if { $admin_p && $user_id != [ad_conn user_id] } { - set return_url [export_vars -base ../admin/process-purchase-course { user_id }] - } else { - set return_url .. + # FIRST check if the section is full + # and if prerequisites are met + + # Is section full? + if { $member_state != "waitinglist approved" } { + set available_slots [dotlrn_ecommerce::section::available_slots $section_id] + ns_log notice "DEBUG:: $available_slots available slots, override $override_p, admin $admin_p" + + if { $available_slots == 0 && ( $override_p != 1 || $admin_p == 0 ) } { + # No more slots left, ask user if he wants to go to + # waiting list + + if { $admin_p && $user_id != [ad_conn user_id] } { + set return_url [export_vars -base ../admin/process-purchase-course { user_id }] + } else { + set return_url .. + } + ad_returnredirect [export_vars -base waiting-list-confirm { product_id user_id participant_id return_url }] + ad_script_abort } - ad_returnredirect [export_vars -base waiting-list-confirm { product_id user_id participant_id return_url }] - ad_script_abort } - } - # Are prerequisites met? - if { $member_state != "request approved" } { - ns_log notice "DEBUG:: checking prerequisites" - set prereq_not_met 0 - db_foreach prereqs { - select m.tree_id, m.user_field, s.community_id - from dotlrn_ecommerce_prereqs p, - dotlrn_ecommerce_prereq_map m, - dotlrn_ecommerce_section s - where p.tree_id = m.tree_id - and p.section_id = s.section_id - and s.section_id = :section_id - } { - set section_prereqs [db_list section_prereqs { - select category_id - from category_object_map_tree - where tree_id = :tree_id - and object_id = :community_id - }] + # Are prerequisites met? + if { $member_state != "request approved" } { + ns_log notice "DEBUG:: checking prerequisites" + set prereq_not_met 0 + db_foreach prereqs { + select m.tree_id, m.user_field, s.community_id + from dotlrn_ecommerce_prereqs p, + dotlrn_ecommerce_prereq_map m, + dotlrn_ecommerce_section s + where p.tree_id = m.tree_id + and p.section_id = s.section_id + and s.section_id = :section_id + } { + set section_prereqs [db_list section_prereqs { + select category_id + from category_object_map_tree + where tree_id = :tree_id + and object_id = :community_id + }] - set user_prereqs [db_list participant_prereqs { - select category_id - from category_object_map_tree - where tree_id = :tree_id - and object_id = :participant_id - }] + set user_prereqs [db_list participant_prereqs { + select category_id + from category_object_map_tree + where tree_id = :tree_id + and object_id = :participant_id + }] - # Check if prereq is met - if { [llength $user_prereqs] > 0 } { - foreach user_prereq $user_prereqs { - if { [llength $section_prereqs] > 0 && [lsearch $section_prereqs $user_prereq] == -1 } { - # Prereq not met - incr prereq_not_met + # Check if prereq is met + if { [llength $user_prereqs] > 0 } { + foreach user_prereq $user_prereqs { + if { [llength $section_prereqs] > 0 && [lsearch $section_prereqs $user_prereq] == -1 } { + # Prereq not met + incr prereq_not_met + } } + } else { + incr prereq_not_met } - } else { - incr prereq_not_met } - } - if { $prereq_not_met > 0 } { - ns_log notice "DEBUG:: prerequisites not met" - if { $admin_p && $user_id != [ad_conn user_id] } { - set return_url [export_vars -base ../admin/process-purchase-course { user_id }] - } else { - set return_url .. + if { $prereq_not_met > 0 } { + ns_log notice "DEBUG:: prerequisites not met" + if { $admin_p && $user_id != [ad_conn user_id] } { + set return_url [export_vars -base ../admin/process-purchase-course { user_id }] + } else { + set return_url .. + } + ad_returnredirect [export_vars -base prerequisite-confirm { product_id user_id participant_id return_url }] + ad_script_abort } - ad_returnredirect [export_vars -base prerequisite-confirm { product_id user_id participant_id return_url }] - ad_script_abort } + + # Check application assessment + if { $member_state != "payment received" } { + if { [db_0or1row get_assessment { + select c.assessment_id + + from dotlrn_ecommerce_section s, + dotlrn_catalogi c, + cr_items i + + where s.course_id = c.item_id + and c.item_id = i.item_id + and i.live_revision = c.course_id + and s.product_id = :product_id + + limit 1 + }] } { + if { ! [empty_string_p $assessment_id] && $assessment_id != -1 } { + set return_url [ad_conn package_url] + ad_returnredirect [export_vars -base application-request { participant_id community_id {next_url $return_url} { type payment } }] + ad_script_abort + + } + } + } } }