+
}
@@ -352,7 +356,7 @@
set grade_tree_id [parameter::get -package_id [ad_conn package_id] -parameter GradeCategoryTree -default 0]
-db_multirow -extend { category_name community_url course_edit_url section_add_url section_edit_url course_grades section_grades sections_url member_p sessions instructors prices shopping_cart_add_url attendees available_slots pending_p waiting_p approved_p } course_list get_courses { } {
+db_multirow -extend { category_name community_url course_edit_url section_add_url section_edit_url course_grades section_grades sections_url member_p sessions instructor_names prices shopping_cart_add_url attendees available_slots pending_p waiting_p approved_p instructor_p registration_approved_url } course_list get_courses { } {
# set mapped [category::get_mapped_categories $course_id]
# foreach element $mapped {
@@ -371,18 +375,20 @@
# if we're not asking for payment, change shopping cart url
# to dotlrn-ecommerce/register
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}]
+ set shopping_cart_add_url [export_vars -base register/ { community_id product_id }]
} else {
- set shopping_cart_add_url [export_vars -base ecommerce/prerequisite-confirm { user_id product_id return_url }]
+ set shopping_cart_add_url [export_vars -base ecommerce/participant-change { user_id product_id return_url }]
}
+ set registration_approved_url [export_vars -base ecommerce/shopping-cart-add { user_id product_id }]
+
set member_p [dotlrn_community::member_p $community_id $user_id]
set pending_p [dotlrn_community::member_pending_p -community_id $community_id -user_id $user_id]
set section_grades ""
set course_grades ""
set sessions ""
- set instructors ""
+ set instructor_names ""
set prices ""
array unset arr_sessions
@@ -422,19 +428,26 @@
set sessions [util_memoize [list dotlrn_ecommerce::section::sessions $calendar_id]]
set instructors [util_memoize [list dotlrn_ecommerce::section::instructors $community_id $__instructors]]
+
+ set instructor_names [list]
+ set instructor_ids [list]
+ foreach instructor $instructors {
+ lappend instructor_names [lindex $instructor 1]
+ lappend instructor_ids [lindex $instructor 0]
+ }
- if { [llength $instructors] == 1 } {
- set instructors "Instructor: [join $instructors ", "]"
- } elseif { [llength $instructors] > 1 } {
- set instructors "Instructors: [join $instructors ", "]"
+ if { [llength $instructor_names] == 1 } {
+ set instructor_names "Instructor: [join $instructor_names ", "]"
+ } elseif { [llength $instructor_names] > 1 } {
+ set instructor_names "Instructors: [join $instructor_names ", "]"
} else {
- set instructors ""
+ set instructor_names ""
}
- if { ! [empty_string_p $instructors] && $member_p } {
- append instructors "
[_ dotlrn-ecommerce.view_bios]"
+ if { ! [empty_string_p $instructor_names] && $member_p } {
+ append instructor_names "
[_ dotlrn-ecommerce.view_bios]"
}
- db_1row attendees { }
+ set attendees [dotlrn_ecommerce::section::attendees $section_id]
if { ! [empty_string_p $maxparticipants] } {
set available_slots [expr $maxparticipants - $attendees]
@@ -459,25 +472,25 @@
}
}
- set waiting_p [db_string awaiting_approval {
- select 1
- where exists (select *
- from acs_rels r,
- membership_rels m
- where r.rel_id = m.rel_id
- and r.object_id_one = :community_id
- and r.object_id_two = :user_id
- and m.member_state = 'request approval')
- } -default 0]
+ set member_state [db_string awaiting_approval {
+ select m.member_state
+ from acs_rels r,
+ membership_rels m
+ where r.rel_id = m.rel_id
+ and r.object_id_one = :community_id
+ and r.object_id_two = :user_id
+ limit 1
+ } -default ""]
+
+ switch $member_state {
+ "request approval" {
+ set waiting_p 1
+ }
+ "waitinglist approved" -
+ "request approved" {
+ set approved_p 1
+ }
+ }
- set approved_p [db_string approved {
- select 1
- where exists (select *
- from acs_rels r,
- membership_rels m
- where r.rel_id = m.rel_id
- and r.object_id_one = :community_id
- and r.object_id_two = :user_id
- and m.member_state = 'request approved')
- } -default 0]
+ set instructor_p [lsearch $instructor_ids $user_id]
}
Index: openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl 28 Jun 2005 17:06:22 -0000 1.4
+++ openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl 16 Jul 2005 12:51:06 -0000 1.5
@@ -16,7 +16,9 @@
if { ![exists_and_not_null user_id] } {
set user_id [ad_conn untrusted_user_id]
} elseif { $user_id != [auth::get_user_id -account_status closed] } {
- permission::require_permission -object_id $user_id -privilege admin
+# Don't check for permissions since ordinary users can edit other
+# people's profiles
+# permission::require_permission -object_id $user_id -privilege admin
}
if { ![exists_and_not_null return_url] } {
@@ -140,22 +142,22 @@
}
{grade:text(select),optional
- {label "Grade"}
+ {label "[_ dotlrn-ecommerce.Grade]"}
{options {$grade_options}}
}
{allergies:text,optional
- {label "Medical Issues"}
+ {label "[_ dotlrn-ecommerce.Medical_Issues]"}
{html {size 60}}
}
{special_needs:text,optional
- {label "Special Needs"}
+ {label "[_ dotlrn-ecommerce.Special_Needs]"}
{html {size 60}}
}
- {add:text(submit) {label "Proceed"}}
- {cancel:text(submit) {label "Cancel"}}
+ {add:text(submit) {label "[_ dotlrn-ecommerce.Proceed]"}}
+ {cancel:text(submit) {label "[_ dotlrn-ecommerce.Cancel]"}}
} -on_request {
foreach var { authority_id first_names last_name email username screen_name url bio } {
set $var $user($var)
@@ -250,4 +252,4 @@
element set_properties user_info url -display_value \
"
[element get_value user_info url]"
}
-}
\ No newline at end of file
+}
Index: openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl 5 Jul 2005 23:58:24 -0000 1.5
+++ openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl 16 Jul 2005 12:51:06 -0000 1.6
@@ -60,7 +60,7 @@
if { [permission::permission_p -object_id $rel_group_id -privilege "admin"] } {
ad_form -extend -name register -form {
{rel_type:text(select)
- {label "Role"}
+ {label "[_ dotlrn-ecommerce.Role]"}
{options {[group::get_rel_types_options -group_id $rel_group_id]}}
}
}
@@ -82,21 +82,21 @@
ad_form -extend -name register -form {
{grade:text(select),optional
- {label "Grade"}
+ {label "[_ dotlrn-ecommerce.Grade]"}
{options {$grade_options}}
}
{allergies:text,optional
- {label "Medical Issues"}
+ {label "[_ dotlrn-ecommerce.Medical_Issues]"}
{html {size 60}}
}
{special_needs:text,optional
- {label "Special Needs"}
+ {label "[_ dotlrn-ecommerce.Special_Needs]"}
{html {size 60}}
}
- {add:text(submit) {label "Add Participant"}}
+ {add:text(submit) {label "[_ dotlrn-ecommerce.Add_Participant]"}}
}
ad_form -extend -name register -on_request {
@@ -222,4 +222,4 @@
ad_returnredirect $return_url
ad_script_abort
}
-}
\ No newline at end of file
+}
Index: openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.adp 19 Jun 2005 06:05:06 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.adp 16 Jul 2005 12:51:06 -0000 1.2
@@ -1,4 +1,11 @@
-
+
+
+ | Before 12pm |
+ | Between 12pm and 5pm |
+ | After 5pm |
+
+
+
@@ -36,17 +43,18 @@
| onclick="javascript:location.href='@items.add_url@';">
@items.day_number@@items.day_number@
-
+
-
|
Index: openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.tcl 19 Jun 2005 06:05:06 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/lib/view-month-display.tcl 16 Jul 2005 12:51:06 -0000 1.2
@@ -104,8 +104,8 @@
today_p \
outside_month_p \
time_p \
- add_url \
- day_url
+ add_url day_url \
+ fontcolor
# Calculate number of greyed days and then add them to the calendar mulitrow
set greyed_days_before_month [expr [expr [dt_first_day_of_month $this_year $this_month]] -1 ]
@@ -130,6 +130,7 @@
t \
"" \
"" \
+ "" \
""
}
@@ -182,7 +183,8 @@
f \
0 \
"${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time" \
- $day_link
+ $day_link \
+ ""
}
}
@@ -213,6 +215,24 @@
} else {
set day_link ""
}
+ ns_log Notice "$ansi_start_time"
+
+ns_log Notice "*** [lc_time_fmt $ansi_start_date '%H'] ***"
+
+ if { [lc_time_fmt $ansi_start_date "%H"] < 12 } {
+ set fontcolor "#1958B7"
+ }
+
+ if { [lc_time_fmt $ansi_start_date "%H"] >= 12 && [lc_time_fmt $ansi_start_date "%H"] <= 17 } {
+ set fontcolor "#FFFD88"
+ }
+
+ if { [lc_time_fmt $ansi_start_date "%H"] > 17 } {
+ set fontcolor "#A7C3FE"
+ }
+
+ns_log Notice " **** $fontcolor ****"
+
multirow append items \
$name \
[subst $item_template] \
@@ -226,7 +246,8 @@
f \
$time_p \
"${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time" \
- $day_link
+ $day_link \
+ $fontcolor
}
# Add cells for remaining days inside the month
@@ -256,7 +277,8 @@
f \
0 \
"${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time" \
- $day_link
+ $day_link \
+ ""
}
# Add cells for remaining days outside the month
@@ -277,6 +299,7 @@
t \
0 \
"" \
- ""
+ "" \
+ ""
}
}
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.9 -r1.10
--- openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 7 Jul 2005 18:17:22 -0000 1.9
+++ openacs-4/packages/dotlrn-ecommerce/sql/postgresql/dotlrn-ecommerce-create.sql 16 Jul 2005 12:51:06 -0000 1.10
@@ -82,5 +82,9 @@
alter table ec_custom_product_field_values add maxparticipants integer;
alter table ec_custom_p_field_values_audit add maxparticipants integer;
+-- 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)));
+
\i dotlrn-ecommerce-memberships-create.sql
\i dotlrn-ecommerce-admin-portlet-create.sql
Index: openacs-4/packages/dotlrn-ecommerce/tcl/dotlrn-ecommerce-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/tcl/dotlrn-ecommerce-init.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/tcl/dotlrn-ecommerce-init.tcl 16 Jul 2005 12:51:06 -0000 1.1
@@ -0,0 +1,14 @@
+# packages/dotlrn-ecommerce/tcl/dotlrn-ecommerce-init.tcl
+
+ad_library {
+
+ Procs to run at startup
+
+ @author Roel Canicula (roelmc@pldtdsl.net)
+ @creation-date 2005-07-14
+ @arch-tag: 40963a7c-970b-41d0-a3da-355d187e42eb
+ @cvs-id $Id: dotlrn-ecommerce-init.tcl,v 1.1 2005/07/16 12:51:06 hamiltonc Exp $
+}
+
+ad_schedule_proc -thread t 300 dotlrn_ecommerce::section::check_elapsed_registrations
+ad_schedule_proc -thread t 600 dotlrn_ecommerce::section::check_and_approve_sections_for_slots
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.9 -r1.10
--- openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl 6 Jul 2005 16:51:08 -0000 1.9
+++ openacs-4/packages/dotlrn-ecommerce/tcl/implementation-procs.tcl 16 Jul 2005 12:51:06 -0000 1.10
@@ -17,6 +17,9 @@
} {
} {
+ # DEDS: for notifying when wait list notify reached
+ set community_notify_waitlist_list [list]
+
if { [exists_and_not_null patron_id] } {
if { ! [dotlrn::user_p -user_id $patron_id] } {
dotlrn::user_add -user_id $patron_id
@@ -59,11 +62,31 @@
}
}
+ set membership_product_p 0
+ set membership_category_id [parameter::get -parameter "MembershipECCategoryId" -default ""]
+ if {![empty_string_p $membership_category_id]} {
+ set membership_product_p [db_string get_count {
+ select count(*)
+ from ec_category_product_map m
+ where m.category_id = :membership_category_id
+ and m.product_id = :product_id
+ }]
+ }
+
foreach user_id $user_ids {
if { ! [dotlrn::user_p -user_id $user_id] } {
dotlrn::user_add -user_id $user_id
}
+ if {$membership_product_p} {
+ set membership_group_id [parameter::get -parameter MemberGroupId -package_id [apm_package_id_from_key "dotlrn-ecommerce"]]
+ if {![empty_string_p $membership_group_id]} {
+ if {![group::member_p -user_id $user_id -group_id $membership_group_id]} {
+ group::add_member -group_id $membership_group_id -user_id $user_id
+ }
+ }
+ }
+
# Get community mapped to product
db_foreach communities {
select community_id
@@ -75,28 +98,28 @@
if { [catch {
set waiting_list_p 0
- if { ! [empty_string_p $maxparticipants] } {
- db_1row attendees {
- select count(*) as attendees
- from dotlrn_member_rels_approved
- where community_id = :community_id
- and (rel_type = 'dotlrn_member_rel'
- or rel_type = 'dc_student_rel')
- }
+# if { ! [empty_string_p $maxparticipants] } {
+# db_1row attendees {
+# select count(*) as attendees
+# from dotlrn_member_rels_approved
+# where community_id = :community_id
+# and (rel_type = 'dotlrn_member_rel'
+# or rel_type = 'dc_student_rel')
+# }
- # If the group members will exceed the maximum
- # participants, the entire group goes to the
- # waiting list
- if { [acs_object_type $participant_id] == "group" } {
- if { ($attendees + [llength $user_ids]) > $maxparticipants } {
- set waiting_list_p 1
- }
- } else {
- if { $attendees >= $maxparticipants } {
- set waiting_list_p 1
- }
- }
- }
+# # If the group members will exceed the maximum
+# # participants, the entire group goes to the
+# # waiting list
+# if { [acs_object_type $participant_id] == "group" } {
+# if { ($attendees + [llength $user_ids]) > $maxparticipants } {
+# set waiting_list_p 1
+# }
+# } else {
+# if { $attendees >= $maxparticipants } {
+# set waiting_list_p 1
+# }
+# }
+# }
if { ! [empty_string_p $method] && $method != "cc" } {
set waiting_list_p 1
@@ -106,6 +129,16 @@
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"
}
if { ! [exists_and_not_null patron_id] } {
@@ -141,5 +174,125 @@
}
}
+ # DEDS
+ # loop for possible notifications on wait list triggered email
+ set wait_list_notify_email [parameter::get -package_id [ad_acs_kernel_id] -parameter AdminOwner]
+ set mail_from [parameter::get -package_id [ad_acs_kernel_id] -parameter OutgoingSender]
+ foreach community_id_wait $community_notify_waitlist_list {
+ ns_log notice "dotlrn-ecommerce wait list notify: potential community is $community_id"
+ if {[db_0or1row get_nwn {
+ select s.notify_waiting_number,
+ s.section_name
+ from dotlrn_ecommerce_section s
+ where s.community_id = :community_id_wait
+ }]} {
+ if {![empty_string_p $notify_waiting_number]} {
+ set current_waitlisted [db_string get_cw {
+ select count(*)
+ from membership_rels m,
+ acs_rels r
+ where m.member_state = 'needs_approval'
+ and m.rel_id = r.rel_id
+ and r.rel_type = 'dotlrn_member_rel'
+ and r.object_id_one = :community_id_wait
+ }]
+ ns_log notice "dotlrn-ecommerce wait list notify: community $community_id wait number is $notify_waiting_number"
+ ns_log notice "dotlrn-ecommerce wait list notify: community $community_id waitlisteed is $current_waitlisted"
+ if {$current_waitlisted >= $notify_waiting_number} {
+ set subject "Waitlist notification for $section_name"
+ set body "$section_name is set to notify when the waitlist reaches ${notify_waiting_number}.
+Total persons in the waiting list for ${section_name}: $current_waitlisted"
+ acs_mail_lite::send \
+ -to_addr $wait_list_notify_email \
+ -from_addr $mail_from \
+ -subject $subject \
+ -body $body
+ ns_log notice "dotlrn-ecommerce wait list notify: community $community_id sending email"
+ } else {
+ ns_log notice "dotlrn-ecommerce wait list notify: community $community_id NOT sending email"
+ }
+ }
+ }
+ }
+
ns_log notice "dotlrn-ecommerce callback: Run successfully"
}
+
+namespace eval dotlrn_ecommerce::ec {}
+
+ad_proc -public dotlrn_ecommerce::ec::toggle_offer_codes {
+ {-order_id:required}
+ {-offer_code "dotlrn-ecommerce"}
+ {-insert:boolean}
+} {
+ toggles offer codes with respect to membership
+
+ @author Deds Castillo (deds@i-manila.com.ph)
+ @creation-date 2005-07-13
+ @cvs-id $Id$
+} {
+ # only do this if we have param set
+ if {[parameter::get -parameter MemberPriceP -default 0]} {
+ # first see if this order is in_basket
+ set in_basket_p [db_string get_in_basket {
+ select count(*)
+ from ec_orders
+ where order_id = :order_id
+ and order_state = 'in_basket'
+ }]
+ if {$in_basket_p} {
+ # first get the session
+ set user_session_id [db_string get_id {
+ select user_session_id
+ from ec_orders
+ where order_id = :order_id
+ } -default 0]
+ if {$insert_p} {
+ # we could either be inserting or updating
+ # so handle that accordingly
+ set product_id_list [db_list get_items {
+ select i.product_id
+ from ec_items i,
+ ec_sale_prices p
+ where i.order_id = :order_id
+ and i.item_state = 'in_basket'
+ and p.product_id = i.product_id
+ and p.offer_code = :offer_code
+ and p.sale_ends > current_timestamp
+ }]
+ foreach product_id $product_id_list {
+ set exists_p [db_string get_exists {
+ select count(*)
+ from ec_user_session_offer_codes
+ where user_session_id = :user_session_id
+ and offer_code = :offer_code
+ and product_id = :product_id
+ }]
+ if {$exists_p} {
+ db_dml update_oc {
+ update ec_user_session_offer_codes
+ set offer_code = :offer_code
+ where user_session_id = :user_session_id
+ and product_id = :product_id
+ }
+ } else {
+ db_dml update_oc {
+ insert into ec_user_session_offer_codes
+ (user_session_id, product_id, offer_code)
+ values
+ (:user_session_id, :product_id, :offer_code)
+ }
+ }
+ }
+ } else {
+ # we are removing
+ db_dml delete_offer_codes {
+ delete
+ from ec_user_session_offer_codes
+ where user_session_id = :user_session_id
+ and offer_code = :offer_code
+ }
+ }
+ }
+ }
+}
Index: openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-oracle.xql 4 Jul 2005 14:28:32 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-oracle.xql 16 Jul 2005 12:51:06 -0000 1.2
@@ -57,7 +57,7 @@
- select u.first_names||' '||u.last_name
+ select u.user_id, u.first_names||' '||u.last_name
from dotlrn_users u, dotlrn_member_rels_approved r
where u.user_id = r.user_id
and r.community_id = :community_id
Index: openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-postgresql.xql 4 Jul 2005 14:28:32 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/tcl/section-procs-postgresql.xql 16 Jul 2005 12:51:06 -0000 1.2
@@ -51,7 +51,7 @@
- select u.first_names||' '||u.last_name
+ select u.user_id, u.first_names||' '||u.last_name
from dotlrn_users u, dotlrn_member_rels_approved r
where u.user_id = r.user_id
and r.community_id = :community_id
Index: openacs-4/packages/dotlrn-ecommerce/tcl/section-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/tcl/section-procs.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/dotlrn-ecommerce/tcl/section-procs.tcl 7 Jul 2005 17:01:08 -0000 1.9
+++ openacs-4/packages/dotlrn-ecommerce/tcl/section-procs.tcl 16 Jul 2005 12:51:06 -0000 1.10
@@ -31,7 +31,7 @@
} {
set instructor_string [join $instructors ,]
if { ![empty_string_p $instructor_string] } {
- return [db_list instructors { }]
+ return [db_list_of_lists instructors { }]
} else {
return ""
}
@@ -226,14 +226,7 @@
}
if { ![empty_string_p $maxparticipants] } {
- db_1row attendees {
- select count(*) as attendees
- from dotlrn_member_rels_approved
- where community_id = :community_id
- and (rel_type = 'dotlrn_member_rel'
- or rel_type = 'dc_student_rel')
- }
-
+ set attendees [dotlrn_ecommerce::section::attendees $section_id]
set available_slots [expr $maxparticipants - $attendees]
if { $available_slots < 0 } {
set available_slots 0
@@ -244,3 +237,127 @@
return ""
}
+ad_proc -public dotlrn_ecommerce::section::attendees {
+ section_id
+} {
+ Return number of attendees
+
+ @author Roel Canicula (roelmc@pldtdsl.net)
+ @creation-date 2005-07-14
+
+ @param section_id
+
+ @return
+
+ @error
+} {
+ return [db_string attendees {
+ select count(*) as attendees
+ from dotlrn_member_rels_full
+ where community_id = (select community_id
+ from dotlrn_ecommerce_section
+ where section_id = :section_id)
+ and (rel_type = 'dotlrn_member_rel' or rel_type = 'dc_student_rel')
+ and member_state in ('approved', 'request approval', 'request approved', 'waitinglist approved')
+ }]
+}
+
+ad_proc -public dotlrn_ecommerce::section::check_elapsed_registrations {
+} {
+ Check registrations
+
+ @author Roel Canicula (roelmc@pldtdsl.net)
+ @creation-date 2005-07-14
+
+ @return
+
+ @error
+} {
+ set time_period [parameter::get -package_id [apm_package_id_from_key dotlrn-ecommerce] -parameter ApprovedRegistrationTimePeriod -default 86400]
+
+ db_foreach check_applications {
+ select community_id, user_id
+ from acs_objects o, dotlrn_member_rels_full r
+ where o.object_id = r.rel_id
+ and (current_timestamp - o.creation_date)::interval >= (:time_period||' seconds')::interval
+ and r.member_state in ('request approved', 'waitinglist approved')
+ } {
+ dotlrn_community::membership_reject -community_id $community_id -user_id $user_id
+ }
+}
+
+ad_proc -public dotlrn_ecommerce::section::approve_next_in_waiting_list {
+ community_id
+} {
+ Approve people in waiting list if slot becomes available
+
+ @author Roel Canicula (roelmc@pldtdsl.net)
+ @creation-date 2005-07-14
+
+ @return
+
+ @error
+} {
+ set section_id [db_string section {
+ select section_id
+ from dotlrn_ecommerce_section
+ where community_id = :community_id
+ }]
+ set available_slots [dotlrn_ecommerce::section::available_slots $section_id]
+
+ if { $available_slots > 0 } {
+ db_foreach next_in_waiting_list [subst {
+ select pretty_name as community_name, person__name(r.user_id) as person_name, r.user_id, p.email
+ from acs_objects o, dotlrn_member_rels_full r, dotlrn_communities_all c, parties p
+ where o.object_id = r.rel_id
+ and r.community_id = c.community_id
+ and r.user_id = p.party_id
+ and member_state = 'needs approval'
+ and r.community_id = :community_id
+
+ order by o.creation_date
+ limit $available_slots
+ }] {
+ set admin_email [parameter::get -package_id [ad_acs_kernel_id] -parameter AdminOwner]
+
+ db_dml approve_request {
+ update membership_rels
+ set member_state = 'waitinglist approved'
+ where rel_id in (select r.rel_id
+ from acs_rels r,
+ membership_rels m
+ where r.rel_id = m.rel_id
+ and r.object_id_one = :community_id
+ and r.object_id_two = :user_id
+ and m.member_state = 'needs approval')
+ }
+
+ acs_mail_lite::send \
+ -to_addr $email \
+ -from_addr $admin_email \
+ -subject "[subst [_ dotlrn-ecommerce.lt_A_space_has_opened_up]]" \
+ -body "[subst [_ dotlrn-ecommerce.lt_A_space_has_opened_up_1]]"
+ }
+ }
+}
+
+ad_proc -public dotlrn_ecommerce::section::check_and_approve_sections_for_slots {
+} {
+ Check all sections for opened slots
+
+ @author Roel Canicula (roelmc@pldtdsl.net)
+ @creation-date 2005-07-14
+
+ @return
+
+ @error
+} {
+ db_foreach sections {
+ select community_id
+ from dotlrn_ecommerce_section
+ } {
+ ns_log notice "DEBUG:: Checking community $community_id for open slots"
+ dotlrn_ecommerce::section::approve_next_in_waiting_list $community_id
+ ns_log notice "DEBUG:: Done check"
+ }
+}
Index: openacs-4/packages/dotlrn-ecommerce/www/application-approve.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/application-approve.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/application-approve.tcl 8 Jul 2005 15:51:44 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/application-approve.tcl 16 Jul 2005 12:51:06 -0000 1.2
@@ -11,22 +11,49 @@
} {
community_id:integer,notnull
user_id:integer,notnull
+ {type waiting_list}
} -properties {
} -validate {
} -errors {
}
-# Check for security
+### Check for security
+
+if { $type == "waiting_list" } {
+ set new_member_state "waitinglist approved"
+ set old_member_state "needs approval"
+} else {
+ set new_member_state "request approved"
+ set old_member_state "request approval"
+}
+
db_dml approve_request {
update membership_rels
- set member_state = 'request approved'
+ set member_state = :new_member_state
where rel_id in (select r.rel_id
from acs_rels r,
membership_rels m
where r.rel_id = m.rel_id
and r.object_id_one = :community_id
and r.object_id_two = :user_id
- and m.member_state = 'request approval')
+ and m.member_state = :old_member_state)
}
+# Send email to applicant
+set actor_id [ad_conn user_id]
+
+if { $user_id != $actor_id } {
+ set applicant_email [cc_email_from_party $user_id]
+ set actor_email [cc_email_from_party $actor_id]
+ set community_name [dotlrn_community::get_community_name $community_id]
+
+# set application_url [ad_url]/[apm_package_url_from_key dotlrn-ecommerce]ecommerce/prerequisite-confirm
+
+ acs_mail_lite::send \
+ -to_addr $applicant_email \
+ -from_addr $actor_email \
+ -subject [subst "[_ dotlrn-ecommerce.Application_approved]"] \
+ -body [subst "[_ dotlrn-ecommerce.lt_Your_application_to_j]"]
+}
+
ad_returnredirect applications
Index: openacs-4/packages/dotlrn-ecommerce/www/application-reject.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/application-reject.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/application-reject.tcl 8 Jul 2005 15:51:44 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/application-reject.tcl 16 Jul 2005 12:51:06 -0000 1.2
@@ -11,11 +11,27 @@
} {
community_id:integer,notnull
user_id:integer,notnull
+ {type waiting_list}
+ {send_email_p 1}
} -properties {
} -validate {
} -errors {
}
dotlrn_community::membership_reject -community_id $community_id -user_id $user_id
+# Send email to applicant
+set actor_id [ad_conn user_id]
+
+if { $user_id != $actor_id && $send_email_p } {
+ set applicant_email [cc_email_from_party $user_id]
+ set actor_email [cc_email_from_party $actor_id]
+ set community_name [dotlrn_community::get_community_name $community_id]
+ acs_mail_lite::send \
+ -to_addr $applicant_email \
+ -from_addr $actor_email \
+ -subject [subst "[_ dotlrn-ecommerce.Application_rejected]"] \
+ -body [subst "[_ dotlrn-ecommerce.lt_Your_application_to_j_1]"]
+}
+
ad_returnredirect applications
Index: openacs-4/packages/dotlrn-ecommerce/www/applications.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/applications.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/applications.adp 8 Jul 2005 15:51:44 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/applications.adp 16 Jul 2005 12:51:06 -0000 1.2
@@ -3,12 +3,33 @@
{Pending Applications}
- #dotlrn-ecommerce.lt_Users_in_waiting_list#
+
+ View User Requests
+ #dotlrn-ecommerce.lt_Users_in_waiting_list#
+
+
+
+ #dotlrn-ecommerce.lt_Approved_Users_from_W#
+
+
+
+
+ View Pending
+ #dotlrn-ecommerce.lt_User_requests_for_app#
+
+
+
+ #dotlrn-ecommerce.lt_Approved_Applications#
+
+
+
+
+
+ #dotlrn-ecommerce.lt_User_requests_for_app#
-
+
-
-
- #dotlrn-ecommerce.lt_User_requests_for_app#
-
-
+ #dotlrn-ecommerce.lt_Approved_Applications#
+
+
+
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.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 8 Jul 2005 15:51:44 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 16 Jul 2005 12:51:06 -0000 1.2
@@ -9,91 +9,137 @@
@arch-tag: 47e50b22-750a-4337-98ed-747058310624
@cvs-id $Id$
} {
-
+ {type "pending"}
} -properties {
} -validate {
} -errors {
}
-template::list::create \
- -name "applications" \
- -multirow "applications" \
- -no_data "No pending applications" \
- -page_flush_p 1 \
- -elements {
- community_name {
- label "Section"
+set user_id [ad_conn user_id]
+
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+set admin_p [permission::permission_p -object_id $cc_package_id -privilege "admin"]
+
+
+if { $type == "pending" } {
+ template::list::create \
+ -name "applications" \
+ -multirow "applications" \
+ -no_data "No pending applications" \
+ -page_flush_p 1 \
+ -elements {
+ community_name {
+ label "Section"
+ }
+ person_name {
+ label "Participant"
+ }
+ member_state {
+ label "Member Request"
+ display_template {
+ User is in waiting list
+ }
+ }
+ assessment_result {
+ label "Application"
+ display_template {
+
+ View
+
+
+ N/A
+
+ }
+ html { align center }
+ }
+ actions {
+ label ""
+ display_template {
+ Approve
+ Reject
+ }
+ html { align center }
+ }
}
- person_name {
- label "Participant"
+
+ db_multirow -extend { approve_url reject_url asm_url } applications applications {
+ 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'
+ } {
+ 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} }]
+
+ # Get associated assessment
+ if { [db_0or1row assessment {
+ select ss.session_id
+
+ from dotlrn_ecommerce_section s,
+ (select c.*
+ from dotlrn_catalogi c,
+ cr_items i
+ where c.course_id = i.live_revision) c,
+ (select a.*
+ from as_assessmentsi a,
+ cr_items i
+ where a.assessment_id = i.latest_revision) a,
+ as_sessions ss
+
+ where s.community_id = :community_id
+ 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
+
+ order by creation_datetime desc
+
+ limit 1
+ }] } {
+ set asm_url [export_vars -base /assessment/asm-admin/results-session { session_id }]
}
- member_state {
- label "Member Request"
- display_template {
- User is in waiting list
+ }
+
+ template::list::create \
+ -name "approved_applications" \
+ -multirow "approved_applications" \
+ -no_data "No approved applications" \
+ -page_flush_p 1 \
+ -elements {
+ community_name {
+ label "Section"
}
- }
- assessment_result {
- label "Application"
- display_template {
-
- View
-
-
- N/A
-
+ person_name {
+ label "Participant"
}
- html { align center }
- }
- actions {
- label ""
- display_template {
- Approve
- Reject
+ phone {
+ label "Phone Number"
}
- html { align center }
+ actions {
+ label ""
+ display_template {
+ Cancel
+ }
+ html { align center }
+ }
}
+
+ db_multirow -extend { approve_url reject_url asm_url } approved_applications approved_applications {
+ select pretty_name as community_name, person__name(r.user_id) as person_name, c.community_id, r.user_id as applicant_user_id, e.phone
+ from dotlrn_member_rels_full r
+ left join (select *
+ from ec_addresses
+ where address_id in (select max(address_id)
+ from ec_addresses
+ group by user_id)) e
+ on (r.user_id = e.user_id), dotlrn_communities_all c
+ where r.community_id = c.community_id
+ and member_state = 'waitinglist approved'
+ } {
+ set reject_url [export_vars -base application-reject { community_id {user_id $applicant_user_id} {send_email_p 0} }]
}
-
-db_multirow -extend { approve_url reject_url asm_url } applications applications {
- select pretty_name as community_name, person__name(user_id) as person_name, member_state, c.community_id, user_id
- from dotlrn_member_rels_full r, dotlrn_communities_all c
- where r.community_id = c.community_id
- and member_state = 'needs approval'
-} {
- set approve_url [export_vars -base application-approve { community_id user_id }]
- set reject_url [export_vars -base application-reject { community_id user_id }]
-
- # Get associated assessment
- if { [db_0or1row assessment {
- select ss.session_id
-
- from dotlrn_ecommerce_section s,
- (select c.*
- from dotlrn_catalogi c,
- cr_items i
- where c.course_id = i.live_revision) c,
- (select a.*
- from as_assessmentsi a,
- cr_items i
- where a.assessment_id = i.latest_revision) a,
- as_sessions ss
-
- where s.community_id = :community_id
- 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
-
- order by creation_datetime desc
-
- limit 1
- }] } {
- set asm_url [export_vars -base /assessment/asm-admin/results-session { session_id }]
- }
}
-
template::list::create \
-name "for_approval" \
-multirow "for_approval" \
@@ -134,57 +180,49 @@
}
}
-set user_id [ad_conn user_id]
-
-set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
-set admin_p [permission::permission_p -object_id $cc_package_id -privilege "admin"]
-
if { $admin_p } {
set user_clause ""
} else {
- set user_clause [subst {
+ set user_clause {
and c.community_id in (select community_id
from dotlrn_member_rels_full
- where user_id = $user_id
+ where user_id = :user_id
and rel_type = 'dotlrn_admin_rel')
- }]
+ }
}
db_multirow -extend { approve_url reject_url asm_url } for_approval for_approval [subst {
select pretty_name as community_name,
- person__name(user_id) as person_name,
- member_state,
- c.community_id,
- user_id
+ person__name(user_id) as person_name,
+ member_state,
+ c.community_id,
+ user_id,
+ r.rel_id
from dotlrn_member_rels_full r, dotlrn_communities_all c
where r.community_id = c.community_id
and member_state = 'request approval'
$user_clause
}] {
- set approve_url [export_vars -base application-approve { community_id user_id }]
- set reject_url [export_vars -base application-reject { community_id user_id }]
+ set approve_url [export_vars -base application-approve { community_id user_id {type prereq} }]
+ set reject_url [export_vars -base application-reject { community_id user_id {type prereq} }]
# Get associated assessment
+ set assessment_id [parameter::get -parameter ApplicationAssessment -default ""]
+
if { [db_0or1row assessment {
select ss.session_id
- from dotlrn_ecommerce_section s,
- (select c.*
- from dotlrn_catalogi c,
- cr_items i
- where c.course_id = i.live_revision) c,
+ from
(select a.*
from as_assessmentsi a,
cr_items i
where a.assessment_id = i.latest_revision) a,
as_sessions ss
- where s.community_id = :community_id
- 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
+ where a.assessment_id = ss.assessment_id
+ and a.item_id = :assessment_id
+ and ss.subject_id = (select creation_user from acs_objects where object_id = :rel_id)
order by creation_datetime desc
@@ -193,3 +231,43 @@
set asm_url [export_vars -base /assessment/asm-admin/results-session { session_id }]
}
}
+
+template::list::create \
+ -name "approved_applications_prereq" \
+ -multirow "approved_applications_prereq" \
+ -no_data "No approved applications" \
+ -page_flush_p 1 \
+ -elements {
+ community_name {
+ label "Section"
+ }
+ person_name {
+ label "Participant"
+ }
+ phone {
+ label "Phone Number"
+ }
+ actions {
+ label ""
+ display_template {
+ Cancel
+ }
+ html { align center }
+ }
+ }
+
+db_multirow -extend { approve_url reject_url asm_url } approved_applications_prereq approved_applications_prereq {
+ select pretty_name as community_name, person__name(r.user_id) as person_name, c.community_id, r.user_id as applicant_user_id, e.phone, (current_timestamp - o.creation_date)::interval as elapsed_time
+ from acs_objects o, dotlrn_member_rels_full r
+ left join (select *
+ from ec_addresses
+ where address_id in (select max(address_id)
+ from ec_addresses
+ group by user_id)) e
+ on (r.user_id = e.user_id), dotlrn_communities_all c
+ where o.object_id = r.rel_id
+ and r.community_id = c.community_id
+ and member_state = 'request approved'
+} {
+ set reject_url [export_vars -base application-reject { community_id {user_id $applicant_user_id} {send_email_p 0} }]
+}
Index: openacs-4/packages/dotlrn-ecommerce/www/admin/course-info.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/course-info.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/dotlrn-ecommerce/www/admin/course-info.tcl 4 Jul 2005 14:28:32 -0000 1.4
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/course-info.tcl 16 Jul 2005 12:51:06 -0000 1.5
@@ -194,12 +194,8 @@
set num_sessions [db_string num_sessions {} ]
- db_1row attendees { }
-
- if { ! [empty_string_p $maxparticipants] } {
- set available_slots [expr $maxparticipants - $attendees]
- }
-
+ set attendees [dotlrn_ecommerce::section::attendees $section_id]
+ set available_slots [dotlrn_ecommerce::section::available_slots $section_id]
set sessions [util_memoize [list dotlrn_ecommerce::section::sessions $calendar_id]]
}
@@ -309,4 +305,4 @@
set template_item_type_id [db_string get_item_type_id { } -default 0]
set template_calendar_url [export_vars -base ${template_community_url}calendar/cal-item-new { {item_type_id $template_item_type_id} {calendar_id $template_calendar_id} {view day} }]
}
-}
\ No newline at end of file
+}
Index: openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp 8 Jul 2005 15:51:43 -0000 1.6
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/index.adp 16 Jul 2005 12:51:06 -0000 1.7
@@ -15,7 +15,8 @@
Manage Registration Assessment
-
+Pending Applications (@pending_count@)
+User Requests for Applications (@request_count@)
Administrative Setup
Index: openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl 4 Jul 2005 13:39:47 -0000 1.6
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/index.tcl 16 Jul 2005 12:51:06 -0000 1.7
@@ -30,9 +30,21 @@
# HAM : check if scholarship is installed
set scholarship_installed_p [apm_package_installed_p "scholarship-fund"]
+
# HAM : check if expenses is installed
set expenses_installed_p [apm_package_installed_p "expenses"]
+# HAM : count number of pending applications and user requests
+set pending_count [db_string "count_pending" "select count(user_id)
+ from dotlrn_member_rels_full r, dotlrn_communities_all c
+ where r.community_id = c.community_id
+ and member_state = 'needs approval'"]
+
+set request_count [db_string "count_requests" "select count(user_id)
+ from dotlrn_member_rels_full r, dotlrn_communities_all c
+ where r.community_id = c.community_id
+ and member_state = 'request approval'"]
+
set course_options [db_list_of_lists courses {
select course_name, course_id
from dotlrn_catalog c, cr_items i
Index: openacs-4/packages/dotlrn-ecommerce/www/admin/one-section.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/one-section.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/www/admin/one-section.adp 4 Jul 2005 14:28:32 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/one-section.adp 16 Jul 2005 12:51:06 -0000 1.3
@@ -4,43 +4,43 @@
\ No newline at end of file
+
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.13 -r1.14
--- openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl 8 Jul 2005 11:05:49 -0000 1.13
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/process-purchase-course.tcl 16 Jul 2005 12:51:06 -0000 1.14
@@ -166,24 +166,6 @@
}
}
-# Select a participant/participants
-# set participant_list [linsert [db_list_of_lists participants [subst {
-# select first_names||' '||last_name||' ('||email||')', u.user_id
-# from dotlrn_users u
-# left join ec_addresses a
-# on (u.user_id = a.user_id)
-# where u.user_id != :user_id
-# and (case when :participant is null
-# then true
-# else $participant_search_clause end)
-# }]] 0 {{} 0}]
-
-# if { [llength $participant_list] == 1 } {
-# set form [rp_getform]
-# ns_set delkey $form __refreshing_p
-# ns_set put $form __refreshing_p 0
-# } else
-
if { ! [empty_string_p $participant] } {
# Search found users, show a more detailed list
template::list::create \
@@ -280,10 +262,6 @@
}
if { ! $participant_id } {
-# {participant_pays_p:boolean(checkbox),optional {label ""} {options {{"Check here if $user_info(first_names) $user_info(last_name) is both purchasing and attending the course" t}}}
-# {help_text "If you select this option, there's no need to select a user below.
Leave this unchecked for group purchases"}
-# }
-
set locale [ad_conn locale]
set related_user_options [linsert [db_list_of_lists related_users {
select *
@@ -510,17 +488,17 @@
set participant_id $group_id
set item_count $num_members
- ad_returnredirect [export_vars -base "../ecommerce/prerequisite-confirm" { product_id user_id participant_id item_count return_url }]
+ ad_returnredirect [export_vars -base "../ecommerce/shopping-cart-add" { product_id user_id participant_id item_count return_url }]
ad_script_abort
}
- set add_url [export_vars -base "../ecommerce/prerequisite-confirm" { product_id user_id participant_id item_count return_url }]
+ set add_url [export_vars -base "../ecommerce/shopping-cart-add" { 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 } {
ad_returnredirect $add_url
} else {
- ad_returnredirect [export_vars -base "participant-add" { {user_id $participant_id} section_id return_url add_url }]
+ ad_returnredirect [export_vars -base "../ecommerce/participant-add" { {user_id $participant_id} section_id return_url add_url }]
}
ad_script_abort
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.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl 8 Jul 2005 11:03:52 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl 16 Jul 2005 12:51:06 -0000 1.2
@@ -11,6 +11,8 @@
} {
participant_id:integer,notnull
community_id:integer,notnull
+ {type full}
+ next_url:notnull
} -properties {
} -validate {
} -errors {
@@ -19,8 +21,18 @@
set extra_vars [ns_set create]
ns_set put $extra_vars user_id $participant_id
ns_set put $extra_vars community_id $community_id
+
+switch $type {
+ full {
+ set member_state "needs approval"
+ }
+ prereq {
+ set member_state "request approval"
+ }
+}
+
if {[catch {set rel_id [relation_add \
- -member_state "request approval" \
+ -member_state $member_state \
-extra_vars $extra_vars \
dotlrn_member_rel \
$community_id \
@@ -29,6 +41,57 @@
ad_return_complaint "There was a problem with your request" $errmsg
} else {
ns_log notice "DEBUG:: RELATION $participant_id, $community_id, $rel_id"
+ set wait_list_notify_email [parameter::get -package_id [ad_acs_kernel_id] -parameter AdminOwner]
+ set mail_from [parameter::get -package_id [ad_acs_kernel_id] -parameter OutgoingSender]
+ ns_log notice "application-request: wait list notify: potential community is $community_id"
+ if {[db_0or1row get_nwn {
+ select s.notify_waiting_number,
+ s.section_name
+ from dotlrn_ecommerce_section s
+ where s.community_id = :community_id
+ }]} {
+ if {![empty_string_p $notify_waiting_number]} {
+ set current_waitlisted [db_string get_cw {
+ select count(*)
+ from membership_rels m,
+ acs_rels r
+ where m.member_state = 'needs approval'
+ and m.rel_id = r.rel_id
+ and r.rel_type = 'dotlrn_member_rel'
+ and r.object_id_one = :community_id
+ }]
+ ns_log notice "application-request: wait list notify: community $community_id wait number is $notify_waiting_number"
+ ns_log notice "application-request: wait list notify: community $community_id waitlisteed is $current_waitlisted"
+ if {$current_waitlisted >= $notify_waiting_number} {
+ set subject "Waitlist notification for $section_name"
+ set body "$section_name is set to notify when the waitlist reaches ${notify_waiting_number}.
+Total persons in the waiting list for ${section_name}: $current_waitlisted"
+ acs_mail_lite::send \
+ -to_addr $wait_list_notify_email \
+ -from_addr $mail_from \
+ -subject $subject \
+ -body $body
+ ns_log notice "application-request: wait list notify: community $community_id sending email"
+ } else {
+ ns_log notice "application-request: wait list notify: community $community_id NOT sending email"
+ }
+ }
+ }
}
-ad_returnredirect ".."
+set section_id [db_string section {
+ select section_id
+ from dotlrn_ecommerce_section
+ where community_id = :community_id
+}]
+
+dotlrn_ecommerce::section::flush_cache $section_id
+
+# Redirect to application assessment if exists
+set assessment_id [parameter::get -parameter ApplicationAssessment -default ""]
+
+if { [empty_string_p $assessment_id] || $type == "full" } {
+ ad_returnredirect $next_url
+} else {
+ ad_returnredirect [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]assessment" { assessment_id {return_url $next_url} }]
+}
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.14 -r1.15
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form.tcl 7 Jul 2005 19:11:41 -0000 1.14
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/checkout-one-form.tcl 16 Jul 2005 12:51:06 -0000 1.15
@@ -141,13 +141,14 @@
db_foreach order_details_select "
select i.price_name, i.price_charged, i.color_choice, i.size_choice, i.style_choice,
- p.product_name, p.one_line_description, p.product_id, count(*) as quantity
+ p.product_name, p.one_line_description, p.product_id, count(*) as quantity, c.offer_code
from ec_items i, ec_products p
+ left join ec_user_session_offer_codes c on (c.product_id = p.product_id and c.user_session_id = :user_session_id)
where i.order_id = :order_id
and i.product_id = p.product_id
- group by p.product_name, p.one_line_description, p.product_id, i.price_name, i.price_charged, i.color_choice, i.size_choice, i.style_choice" {
+ group by p.product_name, p.one_line_description, p.product_id, i.price_name, i.price_charged, i.color_choice, i.size_choice, i.style_choice, c.offer_code" {
if {$product_id != $last_product_id} {
- set lowest_price [lindex [ec_lowest_price_and_price_name_for_an_item $product_id $user_id] 0]
+ set lowest_price [lindex [ec_lowest_price_and_price_name_for_an_item $product_id $user_id $offer_code] 0]
}
set option_list [list]
if { ![empty_string_p $color_choice] } {
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/member-validate.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/member-validate.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/member-validate.adp 16 Jul 2005 12:51:06 -0000 1.1
@@ -0,0 +1,7 @@
+
+ @title@
+ @context@
+
+
+
+@result_stub;noquote@
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/member-validate.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/member-validate.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/member-validate.tcl 16 Jul 2005 12:51:06 -0000 1.1
@@ -0,0 +1,48 @@
+# packages/mos-integration/www/admin/member-validate.tcl
+
+ad_page_contract {
+
+ test page for validating members
+
+ @author Deds Castillo (deds@i-manila.com.ph)
+ @creation-date 2005-07-11
+ @arch-tag: 752d975b-1f3d-4256-8d17-9da5e243c25e
+ @cvs-id $Id: member-validate.tcl,v 1.1 2005/07/16 12:51:06 hamiltonc Exp $
+} {
+ {user_id:optional}
+} -properties {
+} -validate {
+} -errors {
+}
+
+if {![exists_and_not_null user_id]} {
+ set user_id [auth::require_login]
+}
+
+set title "Member validation"
+set context [list $title]
+
+set group_id [parameter::get -parameter MemberGroupId]
+
+set result_stub ""
+set validate_result ""
+
+ad_form \
+ -name member_validate \
+ -form {
+ {group_id:text(hidden) {value $group_id}}
+ {user_id:text(hidden) {value $user_id}}
+ {memberid:text {label "Member ID"}}
+ {zipcode:text {label "Zip code"}}
+ {lastname:text {label "Last Name"}}
+ } \
+ -after_submit {
+ set validate_result [mos_integration::member_validate -user_id $user_id -group_id $group_id -memberid $memberid -zipcode $zipcode -lastname $lastname]
+ if {[string equal $validate_result 1]} {
+ ad_returnredirect [export_vars -base "shopping-cart" {user_id}]
+ } elseif {[string equal $validate_result "EXPIRED"]} {
+ append result_stub "Your membership has expired. You can buy one now"
+ } else {
+ append result_stub "The information you provided did not validate.
Continue shopping without validating your membership or
Buy one now"
+ }
+ }
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/memberships.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/memberships.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/memberships.adp 16 Jul 2005 12:51:06 -0000 1.1
@@ -0,0 +1,7 @@
+
+ @title@
+ @context@
+
+
+
+
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/memberships.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/memberships.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/memberships.tcl 16 Jul 2005 12:51:07 -0000 1.1
@@ -0,0 +1,40 @@
+# packages/dotlrn-ecommerce/www/ecommerce/memberships.tcl
+
+ad_page_contract {
+
+ displays membership product chunks
+
+ @author Deds Castillo (deds@i-manila.com.ph)
+ @creation-date 2005-07-14
+ @arch-tag: c5741497-5c4c-43f3-a528-7d733ec5dbac
+ @cvs-id $Id: memberships.tcl,v 1.1 2005/07/16 12:51:07 hamiltonc Exp $
+} {
+ user_id:integer,notnull,optional
+} -properties {
+} -validate {
+} -errors {
+}
+
+if {![exists_and_not_null user_id]} {
+ set user_id [auth::require_login]
+}
+
+set title "Purchase membership"
+set context {}
+
+set suppress_membership_p 0
+if {[parameter::get -parameter MemberPriceP -default 0]} {
+ set category_id [parameter::get -parameter "MembershipECCategoryId" -default ""]
+ if {[empty_string_p $category_id]} {
+ set suppress_membership_p 1
+ } else {
+ set group_id [parameter::get -parameter MemberGroupId -default 0]
+ if {$group_id} {
+ set suppress_membership_p [group::member_p -group_id $group_id -user_id $user_id]
+ } else {
+ # just set to 1 if we do not find a group
+ set suppress_membership_p 1
+ }
+ }
+}
+
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-add.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-add.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-add.adp 16 Jul 2005 12:51:07 -0000 1.1
@@ -0,0 +1,11 @@
+
+ @title@
+ @context@
+
+
\ No newline at end of file
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-add.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-add.tcl 16 Jul 2005 12:51:07 -0000 1.1
@@ -0,0 +1,41 @@
+# packages/dotlrn-ecommerce/www/admin/participant-add.tcl
+
+ad_page_contract {
+
+
+
+ @author Roel Canicula (roelmc@pldtdsl.net)
+ @creation-date 2005-06-01
+ @arch-tag: 0ee8915f-9e76-4a92-9d43-89c2c757276d
+ @cvs-id $Id: participant-add.tcl,v 1.1 2005/07/16 12:51:07 hamiltonc Exp $
+} {
+ user_id:integer
+ {return_url ""}
+ section_id:integer
+ {cancel ""}
+ {add_url ""}
+} -properties {
+} -validate {
+} -errors {
+}
+
+if { ! [empty_string_p $cancel] } {
+ ns_log notice "DEBUG:: CANCEL - $cancel - $return_url"
+
+ ad_returnredirect $return_url
+ ad_script_abort
+}
+
+db_1row get_section_info "select c.course_id, c.course_name, s.section_name, s.product_id
+ from dotlrn_ecommerce_section s, dotlrn_catalogi c, cr_items ci
+ where s.course_id = c.item_id
+ and ci.live_revision=c.revision_id
+ and s.section_id = :section_id"
+
+set title "Partipant Info for $course_name: $section_name"
+set context [list [list [export_vars -base course-info { course_id }] $section_name] "Participants and Patrons"]
+
+if { [empty_string_p $add_url] } {
+ set add_url [export_vars -base "ecommerce/shopping-cart-add" { product_id user_id }]
+}
+#set addpatron_url [export_vars -base "[apm_package_url_from_key dotlrn-ecommerce]admin/membership-add" { user_id section_id community_id {referer $return_url} }]
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change-2.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change-2.tcl 8 Jul 2005 16:46:33 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change-2.tcl 16 Jul 2005 12:51:07 -0000 1.3
@@ -11,7 +11,9 @@
} {
user_id:integer,notnull
patron_id:integer,notnull
- item_id:integer,notnull
+ product_id:integer,notnull
+ {new_user_p 0}
+ return_url:notnull
} -properties {
} -validate {
} -errors {
@@ -23,15 +25,32 @@
dotlrn::user_add -user_id $user_id
}
-db_dml update_participant {
- update dotlrn_ecommerce_orders
- set participant_id = :user_id
- where item_id = :item_id
+# Get section
+db_1row section {
+ select section_id, community_id
+ from dotlrn_ecommerce_section
+ where product_id = :product_id
}
+# set member_state [db_string awaiting_approval {
+# select m.member_state
+# from acs_rels r,
+# membership_rels m
+# where r.rel_id = m.rel_id
+# and r.object_id_one = :community_id
+# and r.object_id_two = :user_id
+# limit 1
+# } -default ""]
+
set rel_id [relation::get_id -object_id_one $patron_id -object_id_two $user_id -rel_type "patron_rel"]
+set add_url [export_vars -base "shopping-cart-add" { product_id {user_id $patron_id} {participant_id $user_id} return_url }]
+
if { ![empty_string_p $rel_id] || $user_id == $patron_id } {
- ad_returnredirect [export_vars -base shopping-cart { {user_id $patron_id} }]
+ if { $new_user_p } {
+ ad_returnredirect $add_url
+ } else {
+ ad_returnredirect [export_vars -base "participant-add" { section_id user_id return_url add_url }]
+ }
ad_script_abort
} else {
set participant_name [person::name -person_id $user_id]
@@ -41,7 +60,7 @@
lappend tree_options [list [lindex $tree 1] [lindex $tree 0]]
}
- ad_form -name relationship -export { user_id patron_id item_id } -form {
+ ad_form -name relationship -export { user_id patron_id product_id new_user_p return_url member_state } -form {
{relationship:text(select) {label "[subst [_ dotlrn-ecommerce.lt_How_are_you_related_t]]"}
{options {$tree_options}}}
} -on_submit {
@@ -56,7 +75,18 @@
}]
category::map_object -remove_old -object_id $rel_id [list $relationship]
- ad_returnredirect [export_vars -base [ad_conn url] { user_id patron_id item_id}]
+# if { $member_state != "waitinglist approved" } {
+# set available_slots [dotlrn_ecommerce::section::available_slots $section_id]
+
+# if { $available_slots == 0 } {
+# # No more slots left, ask user if he wants to go to
+# # waiting list
+# ad_returnredirect [export_vars -base waiting-list-confirm { product_id user_id return_url }]
+# ad_script_abort
+# }
+# }
+
+ ad_returnredirect [export_vars -base [ad_conn url] { user_id patron_id product_id new_user_p return_url }]
ad_script_abort
}
}
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.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.adp 8 Jul 2005 16:46:33 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.adp 16 Jul 2005 12:51:07 -0000 1.3
@@ -1,7 +1,26 @@
- #dotlrn-ecommerce.Change_Participant#
+ #dotlrn-ecommerce.lt_Whos_participating_in#
-
+
+
+ #dotlrn-ecommerce.lt_Im_participating_in_t#
+
+
+
+ #dotlrn-ecommerce.lt_Continue_Registration_1#
+
+
+
+ #dotlrn-ecommerce.lt_Youve_already_purchas#
+
+
+
+ #dotlrn-ecommerce.lt_Your_request_has_been#
+
+
+
+
+
#dotlrn-ecommerce.lt_Users_related_to_the_#
@@ -12,21 +31,10 @@
-
-
- #dotlrn-ecommerce.lt_patron_name_also_pays#
-
-
- #dotlrn-ecommerce.lt_Back_to_shopping_cart#
#dotlrn-ecommerce.lt_Or_create_an_account_#
-
-
-
- #dotlrn-ecommerce.lt_Back_to_shopping_cart#
-
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.tcl 8 Jul 2005 16:46:33 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/participant-change.tcl 16 Jul 2005 12:51:07 -0000 1.3
@@ -9,26 +9,33 @@
@arch-tag: f24b7927-abe0-463d-bcd0-a96b6c6b5cdb
@cvs-id $Id$
} {
- item_id:integer,notnull,optional
+ product_id:integer,notnull,optional
next_url:optional
+ return_url:optional
} -properties {
} -validate {
} -errors {
}
-if { [exists_and_not_null item_id] } {
- db_1row order {
- select patron_id,
- participant_id
- from dotlrn_ecommerce_orders
- where item_id = :item_id
+set patron_id [ad_conn user_id]
+
+if { $patron_id == 0 } {
+ ad_returnredirect [export_vars -base login { {return_url "[ad_return_url]"} }]
+ ad_script_abort
+}
+
+if { [exists_and_not_null product_id] } {
+ # Check if the section is full and if it allows waiting lists
+ db_1row section_info {
+ select section_id, community_id
+ from dotlrn_ecommerce_section
+ where product_id = :product_id
}
template::list::create \
-name "relations" \
-multirow "relations" \
-no_data "No related users" \
- -pass_properties participant_id \
-elements {
ruser {
label "Related User"
@@ -39,12 +46,17 @@
actions {
label ""
display_template {
-
- [_ dotlrn-ecommerce.Currently_Selected]
+
+ Already Participating
+
[_ dotlrn-ecommerce.Choose_Participant]
+
+
+ Application Pending
+
}
}
}
@@ -53,15 +65,27 @@
db_multirow -extend { participant_change_url } relations relations {
select *
from (
- select u.first_names||' '||u.last_name as ruser, u.user_id, u.email
+ select u.first_names||' '||u.last_name as ruser, u.user_id, u.email,
+ (select m.member_state
+ from acs_rels r,
+ membership_rels m
+ where r.rel_id = m.rel_id
+ and r.object_id_one = :community_id
+ and r.object_id_two = u.user_id) as member_state
from acs_rels r, dotlrn_users u
where r.object_id_two = u.user_id
and r.rel_type = 'patron_rel'
and r.object_id_one = :patron_id
union
- select u.first_names||' '||u.last_name as ruser, u.user_id, u.email
+ select u.first_names||' '||u.last_name as ruser, u.user_id, u.email,
+ (select m.member_state
+ from acs_rels r,
+ membership_rels m
+ where r.rel_id = m.rel_id
+ and r.object_id_one = :community_id
+ and r.object_id_two = u.user_id) as member_state
from acs_rels r, dotlrn_users u
where r.object_id_one = u.user_id
and r.rel_type = 'patron_rel'
@@ -73,11 +97,21 @@
) r
where not ruser is null
} {
- set participant_change_url [export_vars -base participant-change-2 { item_id user_id patron_id }]
+ set participant_change_url [export_vars -base participant-change-2 { product_id user_id patron_id return_url }]
}
- set next_url [export_vars -base participant-change-2 { item_id patron_id }]
+ set next_url [export_vars -base participant-change-2 { product_id patron_id return_url {new_user_p 1} }]
set patron_name [person::name -person_id $patron_id]
- set participant_pays_url [export_vars -base participant-change-2 { item_id {user_id $patron_id} patron_id}]
+ set participant_pays_url [export_vars -base participant-change-2 { product_id {user_id $patron_id} patron_id return_url }]
set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege "admin"]
+
+ set member_state [db_string awaiting_approval {
+ select m.member_state
+ from acs_rels r,
+ membership_rels m
+ where r.rel_id = m.rel_id
+ and r.object_id_one = :community_id
+ and r.object_id_two = :patron_id
+ limit 1
+ } -default ""]
}
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.adp 8 Jul 2005 11:03:52 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.adp 16 Jul 2005 12:51:07 -0000 1.3
@@ -12,8 +12,8 @@
+
#dotlrn-ecommerce.Continue#
-
- #dotlrn-ecommerce.lt_Hold_slot_and_wait_fo#
+ #dotlrn-ecommerce.lt_Hold_slot_and_wait_fo#
#dotlrn-ecommerce.Cancel#
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.tcl 8 Jul 2005 15:51:43 -0000 1.3
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.tcl 16 Jul 2005 12:51:07 -0000 1.4
@@ -34,7 +34,7 @@
}
# See if we need to check for prerequisites
-set shopping_cart_add_url [export_vars -base shopping-cart-add { user_id participant_id product_id item_count }]
+set shopping_cart_add_url [export_vars -base shopping-cart-add { user_id participant_id product_id item_count {override_p 1} }]
set approved_p [db_string approved {
select 1
@@ -93,4 +93,4 @@
ad_script_abort
}
-set request_url [export_vars -base application-request { participant_id community_id }]
+set request_url [export_vars -base application-request { participant_id community_id {type prereq} {next_url $return_url} }]
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.3 -r1.4
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 8 Jul 2005 11:03:52 -0000 1.3
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 16 Jul 2005 12:51:07 -0000 1.4
@@ -34,7 +34,115 @@
user_id:integer,notnull
{participant_id:integer 0}
+
+ {override_p 0}
}
+
+# Roel: Participant also pays
+if { $participant_id == 0 } {
+ set participant_id $user_id
+}
+
+if { [acs_object_type $participant_id] != "group" } {
+ ns_log notice "DEBUG:: checking if this should go to the waiting list"
+
+ set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege admin]
+
+ db_0or1row section_info {
+ select section_id, community_id
+ from dotlrn_ecommerce_section
+ where product_id = :product_id
+ }
+
+ if { [exists_and_not_null community_id] } {
+ ns_log notice "DEBUG:: checking available slots"
+ set member_state [db_string awaiting_approval {
+ select m.member_state
+ from acs_rels r,
+ membership_rels m
+ where r.rel_id = m.rel_id
+ and r.object_id_one = :community_id
+ and r.object_id_two = :participant_id
+ 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 { $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
+ }
+ }
+
+ # 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
+ }]
+
+ # 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
+ }
+ }
+
+ 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
+ }
+ }
+ }
+
+}
+
# added default values to above params so that this page works
# when a post from a form to shopping-cart-add originates from another domain.
@@ -49,7 +157,7 @@
# 5. ad_returnredirect them to their shopping cart
set user_session_id [ec_get_user_session_id]
-ec_create_new_session_if_necessary [export_url_vars product_id user_id participant_id]
+ec_create_new_session_if_necessary [export_url_vars product_id user_id participant_id item_count]
set n_confirmed_orders [db_string get_n_confirmed_orders "
select count(*)
from ec_orders
@@ -122,10 +230,30 @@
# That should be enough to protect from double clicks yet provides a
# more intuitive user experience.
-# Roel: Participant also pays
-if { $participant_id == 0 } {
- set participant_id $user_id
+# DEDS: do we use the member price
+set use_member_price_p 0
+if {[parameter::get -parameter MemberPriceP -default 0]} {
+ set ec_category_id [parameter::get -parameter "MembershipECCategoryId" -default ""]
+ set group_id [parameter::get -parameter MemberGroupId -default 0]
+ if {$group_id} {
+ set use_member_price_p [group::member_p -group_id $group_id -user_id $user_id]
+ }
+ if {!$use_member_price_p} {
+ if {![empty_string_p $ec_category_id]} {
+ set use_member_price_p [db_string get_in_basket {
+ select count(*)
+ from ec_orders o,
+ ec_items i,
+ ec_category_product_map m
+ where o.user_session_id = :user_session_id
+ and o.order_id = i.order_id
+ and i.product_id = m.product_id
+ and m.category_id = :ec_category_id
+ }]
+ }
+ }
}
+
for {set i 0} {$i < $item_count} {incr i} {
db_transaction {
set item_id [db_nextval ec_item_id_sequence]
@@ -161,6 +289,54 @@
where item_id = :item_id
}
}
+ if {$use_member_price_p} {
+ set offer_code [db_string get_offer_code {
+ select offer_code
+ from ec_sale_prices
+ where product_id = :product_id
+ and offer_code = 'dotlrn-ecommerce'
+ } -default ""]
+ if {![empty_string_p $offer_code]} {
+ # DEDS: at this point we need to insert or update an offer
+ set offer_code_exists_p [db_string get_offer_code_p {
+ select count(*)
+ from ec_user_session_offer_codes
+ where user_session_id=:user_session_id
+ and product_id=:product_id
+ }]
+ if {$offer_code_exists_p} {
+ db_dml update_ec_us_offers {
+ update ec_user_session_offer_codes
+ set offer_code = :offer_code
+ where user_session_id = :user_session_id
+ and product_id = :product_id
+ }
+ } else {
+ db_dml inert_uc_offer_code {
+ insert into ec_user_session_offer_codes
+ (user_session_id, product_id, offer_code)
+ values
+ (:user_session_id, :product_id, :offer_code)
+ }
+ }
+ }
+ }
+ # DEDS
+ # at this point if user is purchasing
+ # a member product then we probably need to adjust
+ # any other products in basket
+ if {[parameter::get -parameter MemberPriceP -default 0]} {
+ if {![empty_string_p $ec_category_id]} {
+ if {[db_string membership_product_p {
+ select count(*)
+ from ec_category_product_map
+ where category_id = :ec_category_id
+ and product_id = :product_id
+ }]} {
+ dotlrn_ecommerce::ec::toggle_offer_codes -order_id $order_id -insert
+ }
+ }
+ }
}
}
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-delete-from.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-delete-from.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-delete-from.tcl 23 Jun 2005 12:28:21 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-delete-from.tcl 16 Jul 2005 12:51:07 -0000 1.2
@@ -44,4 +44,22 @@
db_dml delete_item_from_cart "delete from ec_items where order_id=:order_id and product_id=:product_id and color_choice [ec_decode $color_choice "" "is null" "= :color_choice"] and size_choice [ec_decode $size_choice "" "is null" "= :size_choice"] and style_choice [ec_decode $style_choice "" "is null" "= :style_choice"]"
db_release_unused_handles
+# DEDS
+# at this point if user is deleting
+# a member product then we probably need to adjust
+# any other products in basket
+if {[parameter::get -parameter MemberPriceP -default 0]} {
+ set ec_category_id [parameter::get -parameter "MembershipECCategoryId" -default ""]
+ if {![empty_string_p $ec_category_id]} {
+ if {[db_string membership_product_p {
+ select count(*)
+ from ec_category_product_map
+ where category_id = :ec_category_id
+ and product_id = :product_id
+ }]} {
+ dotlrn_ecommerce::ec::toggle_offer_codes -order_id $order_id
+ }
+ }
+}
+
rp_internal_redirect shopping-cart
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.adp 8 Jul 2005 15:51:43 -0000 1.6
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.adp 16 Jul 2005 12:51:07 -0000 1.7
@@ -11,6 +11,12 @@
#dotlrn-ecommerce.click_here#)
+
+
+ Buy a membership now and save on your course purchases.
+ Are you already a member? Enter your member id now
+
+
@@ -39,7 +45,7 @@
@in_cart.patron_name@
- #dotlrn-ecommerce.lt_Participant_pays_for_# (#dotlrn-ecommerce.change#)
+ #dotlrn-ecommerce.lt_Participant_pays_for_#
|
@@ -53,7 +59,6 @@
@in_cart.participant_name@
- (#dotlrn-ecommerce.change#)
@@ -65,9 +70,6 @@
#dotlrn-ecommerce.delete#
- DISABLED FOR NOW
- #dotlrn-ecommerce.change#
-
|
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.tcl 8 Jul 2005 15:51:43 -0000 1.5
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart.tcl 16 Jul 2005 12:51:07 -0000 1.6
@@ -354,5 +354,32 @@
db_release_unused_handles
set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege "admin"]
+set suppress_membership_p 0
+if {[parameter::get -parameter MemberPriceP -default 0]} {
+ set category_id [parameter::get -parameter "MembershipECCategoryId" -default ""]
+ if {[empty_string_p $category_id]} {
+ set suppress_membership_p 1
+ } else {
+ set suppress_membership_p [db_string get_in_basket {
+ select count(*)
+ from ec_orders o,
+ ec_items i,
+ ec_category_product_map m
+ where o.user_session_id = :user_session_id
+ and o.order_id = i.order_id
+ and i.product_id = m.product_id
+ and m.category_id = :category_id
+ }]
+ if {!$suppress_membership_p} {
+ set group_id [parameter::get -parameter MemberGroupId -default 0]
+ if {$group_id} {
+ set suppress_membership_p [group::member_p -group_id $group_id -user_id $user_id]
+ } else {
+ # just set to 1 if we do not find a group
+ set suppress_membership_p 1
+ }
+ }
+ }
+}
ad_return_template
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/waiting-list-confirm.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/waiting-list-confirm.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/waiting-list-confirm.adp 16 Jul 2005 12:51:07 -0000 1.1
@@ -0,0 +1,23 @@
+
+ #dotlrn-ecommerce.The_section_is_full#
+
+
+
#dotlrn-ecommerce.The_section_is_full#
+
+
+
+ - #dotlrn-ecommerce.lt_You_may_continue_with#
+ - #dotlrn-ecommerce.lt_Or_put_this_purchase_#
+
+
+ - #dotlrn-ecommerce.lt_You_may_wish_to_conti#
+
+
+
+
+
+
+ #dotlrn-ecommerce.Continue#
+
+ #dotlrn-ecommerce.lt_Go_on_the_waiting_lis#
+ #dotlrn-ecommerce.Cancel#
Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/waiting-list-confirm.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/waiting-list-confirm.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/waiting-list-confirm.tcl 16 Jul 2005 12:51:07 -0000 1.1
@@ -0,0 +1,39 @@
+# packages/dotlrn-ecommerce/www/ecommerce/prerequisite-confirm.tcl
+
+ad_page_contract {
+
+ Check if prerequisites are met
+
+ @author Roel Canicula (roelmc@pldtdsl.net)
+ @creation-date 2005-07-07
+ @arch-tag: 4ad97aab-c572-4c9f-b359-4ee60c18872d
+ @cvs-id $Id: waiting-list-confirm.tcl,v 1.1 2005/07/16 12:51:07 hamiltonc Exp $
+} {
+ product_id:integer
+ {item_count 1}
+ user_id:integer,notnull
+ {participant_id:integer 0}
+ return_url:notnull
+} -properties {
+} -validate {
+} -errors {
+}
+
+set package_id [ad_conn package_id]
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+set admin_p [permission::permission_p -object_id $cc_package_id -privilege "admin"]
+
+db_1row section {
+ select section_id, community_id, section_name
+ from dotlrn_ecommerce_section
+ where product_id = :product_id
+}
+
+if { $participant_id == 0 } {
+ set participant_id $user_id
+}
+
+# See if we need to check for prerequisites
+set shopping_cart_add_url [export_vars -base shopping-cart-add { user_id participant_id product_id item_count {override_p 1} }]
+
+set request_url [export_vars -base application-request { participant_id community_id {next_url $return_url} }]