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.5 -r1.6 --- openacs-4/packages/dotlrn-ecommerce/www/application-approve.tcl 20 Jul 2005 19:03:35 -0000 1.5 +++ openacs-4/packages/dotlrn-ecommerce/www/application-approve.tcl 23 Jul 2005 13:30:54 -0000 1.6 @@ -12,6 +12,7 @@ community_id:integer,notnull user_id:integer,notnull {type full} + {return_url "applications"} } -properties { } -validate { } -errors { @@ -31,7 +32,14 @@ } set actor_id [ad_conn user_id] +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 + if { $user_id == $actor_id } { db_dml approve_request { update membership_rels @@ -44,11 +52,13 @@ and r.object_id_two = :user_id and m.member_state = :old_member_state) } - ad_returnredirect applications + + ad_returnredirect $return_url } else { if { $type == "prereq" } { ad_form \ -name email_form \ + -export { application_type } \ -form { {user_id:text(hidden)} {community_id:text(hidden)} @@ -86,7 +96,7 @@ -body $body } \ -after_submit { - ad_returnredirect applications + ad_returnredirect $return_url } } else { db_dml approve_request { @@ -106,8 +116,6 @@ 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 - if {![dotlrn_community::send_member_email -community_id $community_id -to_user $user_id -type "on approval"]} { acs_mail_lite::send \ -to_addr $applicant_email \ @@ -116,7 +124,7 @@ -body [subst "[_ dotlrn-ecommerce.lt_Your_application_to_j]"] } - ad_returnredirect applications + ad_returnredirect $return_url } } 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.5 -r1.6 --- openacs-4/packages/dotlrn-ecommerce/www/application-reject.tcl 20 Jul 2005 17:52:37 -0000 1.5 +++ openacs-4/packages/dotlrn-ecommerce/www/application-reject.tcl 23 Jul 2005 13:30:54 -0000 1.6 @@ -13,6 +13,7 @@ user_id:integer,notnull {type full} {send_email_p 1} + {return_url "applications"} } -properties { } -validate { } -errors { @@ -22,7 +23,7 @@ if { !$send_email_p || $user_id == $actor_id } { dotlrn_community::membership_reject -community_id $community_id -user_id $user_id - ad_returnredirect applications + ad_returnredirect $return_redirect } else { # Send email to applicant switch $type { @@ -72,6 +73,6 @@ -body $body } \ -after_submit { - ad_returnredirect applications + ad_returnredirect $return_url } } 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.2 -r1.3 --- openacs-4/packages/dotlrn-ecommerce/www/applications.adp 16 Jul 2005 12:51:06 -0000 1.2 +++ openacs-4/packages/dotlrn-ecommerce/www/applications.adp 23 Jul 2005 13:30:54 -0000 1.3 @@ -1,35 +1,6 @@ - Pending Applications - {Pending Applications} + #dotlrn-ecommerce.lt_Waiting_List_and_Prer# + {#dotlrn-ecommerce.lt_Waiting_List_and_Prer#} - - - 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_Approved_Applications#

-

- - + + \ 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.7 -r1.8 --- openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 21 Jul 2005 17:16:37 -0000 1.7 +++ openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 23 Jul 2005 13:30:54 -0000 1.8 @@ -1,305 +1,232 @@ -# packages/dotlrn-ecommerce/www/admin/applications.tcl +# packages/dotlrn-ecommerce/www/applications2.tcl ad_page_contract { + List of pending and approved applications - @author Roel Canicula (roelmc@pldtdsl.net) - @creation-date 2005-06-23 - @arch-tag: 47e50b22-750a-4337-98ed-747058310624 + @creation-date 2005-07-23 + @arch-tag: 7d7789ef-523a-40dc-aa32-c650e19ece40 @cvs-id $Id$ } { - {type "pending"} + type:optional + orderby:optional } -properties { } -validate { } -errors { } 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"] +set package_id [ad_conn package_id] +set admin_p [permission::permission_p -object_id $package_id -privilege "admin"] +set return_url [ad_return_url] - -if { $type == "pending" } { - template::list::create \ - -name "applications" \ - -multirow "applications" \ - -no_data "No pending applications" \ - -page_flush_p 1 \ - -elements { - section_name { - label "Section" - display_template { - @applications.course_name@: @applications.section_name@ - } - html { nowrap } - } - person_name { - label "Participant" - } - member_state { - label "Member Request" - display_template { - - User is in waiting list - - - User has submitted an application and is waiting for approval - - } - } - assessment_result { - label "Application" - display_template { - - View - - - N/A - - } - html { align center } - } - actions { - label "" - display_template { - Approve - Reject - } - html { align center } - } - } - - db_multirow -extend { approve_url reject_url asm_url } applications applications { - select person__name(user_id) as person_name, member_state, r.community_id, user_id as applicant_user_id, s.section_name, t.course_name - from dotlrn_member_rels_full r, dotlrn_ecommerce_section s, dotlrn_catalogi t - where r.community_id = s.community_id - and s.course_id = t.item_id - and member_state in ('needs approval', 'awaiting payment') - } { - if { $member_state == "needs approval" } { - set list_type full - } elseif { $member_state == "awaiting payment" } { - set list_type payment - } - - set approve_url [export_vars -base application-approve { community_id {user_id $applicant_user_id} {type $list_type} }] - set reject_url [export_vars -base application-reject { community_id {user_id $applicant_user_id} {type $list_type} }] - - # 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 = :applicant_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 "approved_applications" \ - -multirow "approved_applications" \ - -no_data "No approved applications" \ - -page_flush_p 1 \ - -elements { - section_name { - label "Section" - display_template { - @approved_applications.course_name@: @approved_applications.section_name@ - } - html { nowrap } - } - 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 approved_applications { - select person__name(r.user_id) as person_name, r.community_id, r.user_id as applicant_user_id, e.phone, s.section_name, t.course_name - 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_ecommerce_section s, dotlrn_catalogi t - where r.community_id = s.community_id - and s.course_id = t.item_id - and member_state in ('waitinglist approved', 'payment received') - } { - set reject_url [export_vars -base application-reject { community_id {user_id $applicant_user_id} {send_email_p 0} }] - } +if { [exists_and_not_null type] } { + set _type $type +} else { + set _type all } template::list::create \ - -name "for_approval" \ - -multirow "for_approval" \ - -no_data "No requests for approval" \ + -name "applications" \ + -multirow "applications" \ + -no_data "[_ dotlrn-ecommerce.No_applications]" \ -page_flush_p 1 \ + -pass_properties { admin_p return_url _type } \ -elements { section_name { - label "Section" + label "[_ dotlrn-ecommerce.Section]" display_template { - @for_approval.course_name@: @for_approval.section_name@ + + @applications.course_name@: @applications.section_name@ + + + @applications.course_name@: @applications.section_name@ + } - html { nowrap } } + number { + label "[_ dotlrn-ecommerce.lt_Number_in_Waiting_Lis]" + html { align center } + hide_p {[ad_decode $_type "waitinglist approved" 1 "request approved" 1 "payment received" 1 "all" 0 0]} + display_template { + + @applications.number@ + + } + } person_name { - label "Participant" + label "[_ dotlrn-ecommerce.Participant]" + display_template { + + @applications.person_name@ + + + @applications.person_name@ + + } } member_state { - label "Member Request" + label "[_ dotlrn-ecommerce.Member_Request]" display_template { - User is holding a spot and waiting for approval + + [_ dotlrn-ecommerce.lt_User_is_in_waiting_li] + + + [_ dotlrn-ecommerce.lt_User_has_submitted_an] + } } assessment_result { - label "Application" + label "[_ dotlrn-ecommerce.Application]" display_template { - - View + + [_ dotlrn-ecommerce.View] N/A } html { align center } } + phone { + label "[_ dotlrn-ecommerce.Phone_Number]" + hide_p {[ad_decode $_type "waitinglist approved" 0 "request approved" 0 "payment received" 0 "all" 0 1]} + } actions { label "" display_template { - Approve - Reject + + [_ dotlrn-ecommerce.Approve] + [_ dotlrn-ecommerce.Reject] + + + [_ dotlrn-ecommerce.Cancel] + } - html { align center } + html { width 125 align center nowrap } } - } - -if { $admin_p } { - set user_clause "" -} else { - set user_clause { - and c.community_id in (select community_id - from dotlrn_member_rels_full - 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 person__name(user_id) as person_name, - member_state, - r.community_id, - user_id, - r.rel_id, - s.section_name, - t.course_name - from dotlrn_member_rels_full r, dotlrn_ecommerce_section s, dotlrn_catalogi t - where r.community_id = s.community_id - and s.course_id = t.item_id - and member_state = 'request approval' - - $user_clause -}] { - 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 - (select a.* - from as_assessmentsi a, - cr_items i - where a.assessment_id = i.latest_revision) a, - as_sessions ss - - 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 - - limit 1 - }] } { - 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 { - section_name { - label "Section" - display_template { - @approved_applications_prereq.course_name@: @approved_applications_prereq.section_name@ + } -filters { + type { + label "[_ dotlrn-ecommerce.Type_of_Request]" + values { + {"[_ dotlrn-ecommerce.In_Waiting_List]" "needs approval"} + {"[_ dotlrn-ecommerce.lt_Approved_Waiting_List]" "waitinglist approved"} + {"[_ dotlrn-ecommerce.For_PreReq_Approval]" "request approval"} + {"[_ dotlrn-ecommerce.Applications]" "awaiting payment"} + {"[_ dotlrn-ecommerce.lt_Approved_PreReq_Appli]" "request approved"} + {"[_ dotlrn-ecommerce.lt_Approved_Applications]" "payment received"} } - html { nowrap } + where_clause { member_state = :type } } - person_name { - label "Participant" + } -orderby { + section_name { + label "[_ dotlrn-ecommerce.Section_1]" + orderby "lower(s.section_name)" } - phone { - label "Phone Number" + number { + label "[_ dotlrn-ecommerce.lt_Number_in_Waiting_Lis]" + orderby "lower(s.section_name), number" } - actions { - label "" - display_template { - Cancel - } - html { align center } + person_name { + label "[_ dotlrn-ecommerce.Participant]" + orderby "lower(person__name(r.user_id))" } + member_state { + label "[_ dotlrn-ecommerce.Member_Request]" + } } -db_multirow -extend { approve_url reject_url asm_url } approved_applications_prereq approved_applications_prereq { - select person__name(r.user_id) as person_name, r.community_id, r.user_id as applicant_user_id, e.phone, (current_timestamp - o.creation_date)::interval as elapsed_time, s.section_name, t.course_name - from acs_objects o, dotlrn_member_rels_full r +db_multirow -extend { approve_url reject_url asm_url section_edit_url person_url } 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, + (select count(*) + from (select * + from dotlrn_member_rels_full rr, + acs_objects o + where rr.rel_id = o.object_id + 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 + 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_ecommerce_section s, dotlrn_catalogi t - where o.object_id = r.rel_id - and r.community_id = s.community_id + where r.community_id = s.community_id and s.course_id = t.item_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} }] + and member_state in ('needs approval', 'waitinglist approved', 'request approval', 'request approved', 'awaiting payment', 'payment received') + [template::list::filter_where_clauses -and -name applications] + [template::list::orderby_clause -name applications -orderby] +}] { + set list_type [ad_decode $member_state "needs approval" full "request approval" prereq "awaiting payment" payment] + + set approve_url [export_vars -base application-approve { community_id {user_id $applicant_user_id} {type $list_type} }] + set reject_url [export_vars -base application-reject { community_id {user_id $applicant_user_id} {type $list_type} }] + + if { $member_state == "needs approval" || + $member_state == "awaiting payment" || + $member_state == "waitinglist approved" || + $member_state == "payment received" + } { + # 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 = :applicant_user_id + + order by creation_datetime desc + + limit 1 + }] } { + set asm_url [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]asm-admin/results-session" { session_id }] + } + + } elseif { $member_state == "request approval" || + $member_state == "request approved" } { + + # Get associated assessment + set assessment_id [parameter::get -parameter ApplicationAssessment -default ""] + + if { [db_0or1row assessment { + select ss.session_id + + from (select a.* + from as_assessmentsi a, + cr_items i + where a.assessment_id = i.latest_revision) a, + as_sessions ss + + 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 + + limit 1 + }] } { + set asm_url [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]asm-admin/results-session" { session_id }] + } + } + + set section_edit_url [export_vars -base admin/one-section { section_id return_url }] + set person_url [export_vars -base /acs-admin/users/one { {user_id $applicant_user_id} }] }