Index: openacs-4/packages/dotlrn-ecommerce/www/application-bulk-approve.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/application-bulk-approve.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/application-bulk-approve.adp 1 Oct 2005 21:35:14 -0000 1.1 @@ -0,0 +1,51 @@ + + #dotlrn-ecommerce.lt_Bulk_Approve_Applicat# + + + #dotlrn-ecommerce.lt_Approve_the_following# +

+

+ + +
+ +

+ + + #dotlrn-ecommerce.lt_The_following_applica# +

+ + + + + +

+ + + #dotlrn-ecommerce.lt_The_following_applica_1# +

+

+ + +

+ + #dotlrn-ecommerce.Back_to# #dotlrn-ecommerce.lt_Waiting_List_and_Prer# \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/application-bulk-approve.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/application-bulk-approve.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/application-bulk-approve.tcl 1 Oct 2005 21:35:14 -0000 1.1 @@ -0,0 +1,154 @@ +# packages/dotlrn-ecommerce/www/application-bulk-approve.tcl + +ad_page_contract { + + Bulk approve applications + + @author Roel Canicula (roelmc@pldtdsl.net) + @creation-date 2005-09-29 + @arch-tag: 6af8efc8-8de8-498b-950c-2cf207c24f5b + @cvs-id $Id: application-bulk-approve.tcl,v 1.1 2005/10/01 21:35:14 roelc Exp $ +} { + {rel_id:multiple {}} + return_url + __confirmed_p:optional + + {filter_community_id ""} + {filter_member_state:multiple {{needs approval} {awaiting payment}}} +} -properties { +} -validate { +} -errors { +} + +# Properly check for permissions as non-sw-admin instructors can +# access the applications list and perform operations on their +# specific classes +#permission::require_permission -object_id [ad_conn package_id] -privilege admin + +set actor_id [ad_conn user_id] +set email_reg_info_to [parameter::get -parameter EmailRegInfoTo -default "patron"] + +if { [info exists __confirmed_p] } { + set rel_id [split [lindex $rel_id 0]] + set filter_member_state [lindex $filter_member_state 0] +} + +if { [llength $rel_id] == 0 } { + ad_returnredirect $return_url + ad_script_abort +} + +# We need to do this coz there may be section specific email templates +db_multirow -extend { url type } todo todo [subst { + select r.community_id, r.member_state, c.pretty_name as community_name + + from dotlrn_member_rels_full r, dotlrn_communities c + + where r.community_id = c.community_id + and rel_id in ([join $rel_id ,]) + and r.member_state = 'request approval' + and (case when :filter_community_id is null then true else not r.community_id = :filter_community_id end) + + group by r.community_id, r.member_state, c.pretty_name +}] { + set url [export_vars -base application-bulk-approve { rel_id:multiple return_url {filter_community_id $community_id} {filter_member_state $member_state} }] + + set type [ad_decode $member_state \ + "needs approval" "Waiting List" \ + "request approval" "Prerequisite" \ + "awaiting payment" "Application" \ + "Waiting List"] +} + +# Create a list for the applications we can approve +db_multirow -extend { type } applications applications [subst { + select rel_id as _rel_id, user_id, person__name(user_id), pretty_name as community_name, member_state + from dotlrn_member_rels_full r, dotlrn_communities_full c + where r.community_id = c.community_id + and rel_id in ([join $rel_id ,]) + and member_state in ('[join $filter_member_state ',']') + and (case when :filter_community_id is null then true else r.community_id = :filter_community_id end) +}] { + set type [ad_decode $member_state \ + "needs approval" "Waiting List" \ + "request approval" "Prerequisite" \ + "awaiting payment" "Application" \ + "Waiting List"] +} + +if { [template::multirow size applications] > 0 } { + ad_form -name confirm -export { rel_id return_url filter_member_state filter_community_id } -form { + } + + if { ! [empty_string_p $filter_community_id] && [string equal "request approval" [lindex $filter_member_state 0]] } { + ad_form -extend -name confirm -form { + {subject:text {html {size 60}}} + {reason:text(textarea),optional {label "[_ dotlrn-ecommerce.Reason]"} {html {rows 10 cols 60}}} + } -on_request { + set reason_email [lindex [callback dotlrn::default_member_email -community_id $filter_community_id -to_user 0 -type "prereq approval"] 0] + set reason [lindex $reason_email 2] + set subject [lindex $reason_email 1] + } + } + + ad_form -extend -name confirm -form { + {approve:text(submit) {label "[_ dotlrn-ecommerce.Approve]"}} + } -on_submit { + + db_foreach applications_to_approve [subst { + select rel_id as _rel_id, user_id, r.community_id, member_state, s.section_id, o.creation_user as patron_id + from dotlrn_member_rels_full r, dotlrn_ecommerce_section s, acs_objects o + where r.community_id = s.community_id + and r.rel_id = o.object_id + and rel_id in ([join $rel_id ,]) + and member_state in ('[join $filter_member_state ',']') + and (case when :filter_community_id is null then member_state != 'request approval' else r.community_id = :filter_community_id end) + }] { + + if {$email_reg_info_to == "participant"} { + set email_user_id $user_id + } else { + set email_user_id $patron_id + } + + if { "request approval" == $member_state } { + array set vars [lindex [callback dotlrn::member_email_var_list -community_id $filter_community_id -to_user $email_user_id -type prereq] 0] + set email_vars [lang::message::get_embedded_vars $reason] + foreach var [concat $email_vars] { + if {![info exists vars($var)]} { + set vars($var) "" + } + } + set var_list [array get vars] + set reason "[lang::message::format $reason $var_list]" + + dotlrn_community::send_member_email -community_id $community_id -to_user $email_user_id -type "prereq approval" -override_email $reason -override_subject $subject + } else { + set email_type [ad_decode $member_state "needs approval" "waitinglist approved" "awaiting payment" "on approval" "waitinglist approved"] + + dotlrn_community::send_member_email -community_id $community_id -to_user $email_user_id -type $email_type + } + + dotlrn_ecommerce::section::user_approve -rel_id $_rel_id -user_id $user_id -community_id $community_id + dotlrn_ecommerce::section::flush_cache -user_id $user_id $section_id + } + + # Redirect to myself, if there's nothing left to do, we'll go + # back to return_url + ad_returnredirect [export_vars -base [ad_conn url] { rel_id:multiple return_url }] + ad_script_abort + } +} + +# Create a list for applications that have already been approved +db_multirow approved approved [subst { + select rel_id as _rel_id, user_id, person__name(user_id), pretty_name as community_name + from dotlrn_member_rels_full r, dotlrn_communities_full c + where r.community_id = c.community_id + and rel_id in ([join $rel_id ,]) + and member_state in ('waitinglist approved', 'request approved', 'payment received') + + order by r.community_id +}] + +set now_url [export_vars -base [ad_conn url] { rel_id:multiple return_url }] \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/application-bulk-reject.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/application-bulk-reject.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/application-bulk-reject.adp 1 Oct 2005 21:35:14 -0000 1.1 @@ -0,0 +1,33 @@ + + #dotlrn-ecommerce.lt_Bulk_Reject_Applicati# + + + #dotlrn-ecommerce.lt_Reject_the_following_# +

+

+ + + + +

+ + + #dotlrn-ecommerce.lt_The_following_applica_2# +

+ + + #dotlrn-ecommerce.lt_The_applications_have# + + +

+ + + #dotlrn-ecommerce.Back_to# #dotlrn-ecommerce.lt_Waiting_List_and_Prer# \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/application-bulk-reject.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/application-bulk-reject.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/www/application-bulk-reject.tcl 1 Oct 2005 21:35:14 -0000 1.1 @@ -0,0 +1,189 @@ +# packages/dotlrn-ecommerce/www/application-bulk-reject.tcl + +ad_page_contract { + + Bulk reject applications + + @author Roel Canicula (roelmc@pldtdsl.net) + @creation-date 2005-09-30 + @arch-tag: 35bc095d-0e16-4896-9545-0c8bffb03806 + @cvs-id $Id: application-bulk-reject.tcl,v 1.1 2005/10/01 21:35:14 roelc Exp $ +} { + {rel_id:multiple {}} + return_url + __confirmed_p:optional + + {filter_community_id ""} + {filter_member_state ""} +} -properties { +} -validate { +} -errors { +} + +# Properly check for permissions as non-sw-admin instructors can +# access the applications list and perform operations on their +# specific classes +#permission::require_permission -object_id [ad_conn package_id] -privilege admin + +set actor_id [ad_conn user_id] +set email_reg_info_to [parameter::get -parameter EmailRegInfoTo -default "patron"] + +if { [info exists __confirmed_p] } { + set rel_id [split [lindex $rel_id 0]] + +} + +if { [llength $rel_id] == 0 } { + ad_returnredirect $return_url + ad_script_abort +} + +# Build todo list, we need to do this because each section can have +# its specific email template +db_multirow -extend { url type } todo todo [subst { + select r.community_id, r.member_state, c.pretty_name as community_name, max(r.user_id) as any_user_id + + from dotlrn_member_rels_full r, dotlrn_communities c + + where r.community_id = c.community_id + and rel_id in ([join $rel_id ,]) + and r.member_state in ('needs approval', 'request approval', 'awaiting payment', 'waitinglist approved', 'request approved', 'payment received') + + group by r.community_id, r.member_state, c.pretty_name +}] { + set url [export_vars -base application-bulk-reject { rel_id:multiple return_url {filter_community_id $community_id} {filter_member_state $member_state} }] + + set type [ad_decode $member_state \ + "needs approval" "Waiting List" \ + "request approval" "Prerequisite" \ + "awaiting payment" "Application" \ + "waitinglist approved" "Waiting List" \ + "request approved" "Prerequisite" \ + "payment received" "Application" \ + "Waiting List"] +} + +# Create a list for the applications we can approve +db_multirow -extend { type } applications applications [subst { + select rel_id as _rel_id, user_id, person__name(user_id), pretty_name as community_name, member_state + from dotlrn_member_rels_full r, dotlrn_communities_full c + where r.community_id = c.community_id + and rel_id in ([join $rel_id ,]) + and member_state = :filter_member_state + and (case when :filter_community_id is null then true else r.community_id = :filter_community_id end) +}] { + set type [ad_decode $member_state \ + "needs approval" "Waiting List" \ + "request approval" "Prerequisite" \ + "awaiting payment" "Application" \ + "waitinglist approved" "Waiting List" \ + "request approved" "Prerequisite" \ + "payment received" "Application" \ + "Waiting List"] +} + +if { [template::multirow size applications] > 0 } { + ad_form -name confirm -export { rel_id return_url filter_member_state filter_community_id } -form { + } + + if { ! [empty_string_p $filter_community_id] && ! [empty_string_p $filter_member_state] } { + ad_form -extend -name confirm -form { + {subject:text {html {size 60}}} + {reason:text(textarea),optional {label "[_ dotlrn-ecommerce.Reason]"} {html {rows 10 cols 60}}} + } -on_request { + switch $filter_member_state { + "request approval" - + "request approved" { + set email_type "prereq reject" + } + default { + set email_type "application reject" + } + } + + set reason_email [lindex [callback dotlrn::default_member_email -community_id $filter_community_id -to_user 0 -type $email_type] 0] + set reason [lindex $reason_email 2] + set subject [lindex $reason_email 1] + } + } + + if { [parameter::get -parameter AllowRejectWithoutEmail -default 0] } { + ad_form \ + -extend \ + -name confirm \ + -form { + {submit1:text(submit) {label "[_ dotlrn-ecommerce.lt_Reject_and_Send_Email]"}} + {submit2:text(submit) {label "[_ dotlrn-ecommerce.Reject_Only]"}} + } + } else { + ad_form -extend -name confirm -form { + {reject:text(submit) {label "[_ dotlrn-ecommerce.Reject]"}} + } + } + + ad_form -extend -name confirm -form { + } -on_submit { + + db_foreach applications_to_approve [subst { + select rel_id as _rel_id, user_id, r.community_id, member_state, s.section_id, o.creation_user as patron_id + from dotlrn_member_rels_full r, dotlrn_ecommerce_section s, acs_objects o + where r.community_id = s.community_id + and r.rel_id = o.object_id + and rel_id in ([join $rel_id ,]) + and r.member_state = :filter_member_state + and r.community_id = :filter_community_id + }] { + + dotlrn_community::membership_reject -community_id $community_id -user_id $user_id + + if {$email_reg_info_to == "participant"} { + set email_user_id $user_id + } else { + set email_user_id $patron_id + } + + if { ! [exists_and_equal submit2 "[_ dotlrn-ecommerce.Reject_Only]"] } { + + set to_email [cc_email_from_party $email_user_id] + set actor_email [cc_email_from_party $actor_id] + set community_name [dotlrn_community::get_community_name $community_id] + + switch $filter_member_state { + "request approval" - + "request approved" { + set email_type "prereq reject" + set type prereq + } + "needs approval" - + "waitinglist approved" { + set email_type "application reject" + set type full + } + default { + set email_type "application reject" + set type payment + } + } + + array set vars [lindex [callback dotlrn::member_email_var_list -community_id $filter_community_id -to_user $email_user_id -type $type] 0] + set email_vars [lang::message::get_embedded_vars $reason] + foreach var [concat $email_vars] { + if {![info exists vars($var)]} { + set vars($var) "" + } + } + set var_list [array get vars] + set reason "[lang::message::format $reason $var_list]" + + dotlrn_community::send_member_email -community_id $community_id -to_user $email_user_id -type $email_type -override_email $reason -override_subject $subject + } + + dotlrn_ecommerce::section::flush_cache -user_id $user_id $section_id + } + + # Redirect to myself, if there's nothing left to do, we'll go + # back to return_url + ad_returnredirect [export_vars -base [ad_conn url] { rel_id:multiple return_url }] + ad_script_abort + } +} \ No newline at end of file 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.39 -r1.40 --- openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 24 Sep 2005 21:49:08 -0000 1.39 +++ openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 1 Oct 2005 21:35:14 -0000 1.40 @@ -57,12 +57,12 @@ set actions "" -set bulk_actions "" +set bulk_actions [list [_ dotlrn-ecommerce.Approve] application-bulk-approve [_ dotlrn-ecommerce.Approve] "[_ dotlrn-ecommerce.Reject] / [_ dotlrn-ecommerce.Cancel]" application-bulk-reject "[_ dotlrn-ecommerce.Reject] / [_ dotlrn-ecommerce.Cancel]"] if {[parameter::get -parameter AllowApplicationBulkEmail -default 0]} { set actions [list "[_ dotlrn-ecommerce.View_previously_email]" "sent-emails" "[_ dotlrn-ecommerce.View_previously_email]"] - set bulk_actions [list "[_ dotlrn-ecommerce.Email_applicants]" "email-applicants" "[_ dotlrn-ecommerce.Email_applicants]"] -} + lappend bulk_actions "[_ dotlrn-ecommerce.Email_applicants]" "email-applicants" "[_ dotlrn-ecommerce.Email_applicants]" +} set elements {section_name { label "[_ dotlrn-ecommerce.Section]" @@ -127,7 +127,11 @@ display_template { [_ dotlrn-ecommerce.View] + +
+ [_ dotlrn-ecommerce.incomplete]
+
N/A @@ -184,6 +188,7 @@ -pass_properties { admin_p return_url _type } \ -actions $actions \ -bulk_actions $bulk_actions \ + -bulk_action_export_vars { return_url } \ -elements $elements \ -filters [subst { type { @@ -240,7 +245,7 @@ set general_comments_url [apm_package_url_from_key "general-comments"] -db_multirow -extend { approve_url reject_url asm_url section_edit_url person_url register_url comments comments_text_plain comments_truncate add_comment_url target} applications applications [subst { +db_multirow -extend { approve_url reject_url asm_url section_edit_url person_url register_url comments comments_text_plain comments_truncate add_comment_url target } applications applications [subst { select person__name(r.user_id) as person_name, member_state, r.community_id, r.user_id as applicant_user_id, s.section_name, t.course_name, s.section_id, r.rel_id, e.phone, o.creation_user as patron_id, (select count(*) from (select * @@ -250,7 +255,7 @@ and rr.rel_id <= r.rel_id and rr.community_id = r.community_id and rr.member_state = r.member_state - order by o.creation_date) r) as number, s.product_id, m.session_id + order by o.creation_date) r) as number, s.product_id, m.session_id, m.completed_datetime from dotlrn_member_rels_full r left join (select * @@ -259,9 +264,10 @@ from ec_addresses group by user_id)) e on (r.user_id = e.user_id) - left join (select * - from dotlrn_ecommerce_application_assessment_map - where session_id in (select max(session_id) + left join (select m.*, s.completed_datetime + from dotlrn_ecommerce_application_assessment_map m, as_sessions s + where m.session_id = s.session_id + and m.session_id in (select max(session_id) from dotlrn_ecommerce_application_assessment_map group by rel_id)) m on (r.rel_id = m.rel_id),