Index: openacs-4/packages/ecommerce/www/admin/customer-service/statistics.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/customer-service/statistics.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/ecommerce/www/admin/customer-service/statistics.adp	24 Aug 2008 21:51:19 -0000	1.1
@@ -0,0 +1,24 @@
+<master>
+  <property name="doc(title)">@title;noquote@</property>
+  <property name="context">@context;noquote@</property>
+<h2>@title@</h2>
+
+<h3>Issues by Issue Type</h3>
+ <ul>
+  @issues_type_counts_html;noquote@
+ </ul>
+
+<h3>Interactions by Originator</h3>
+ <ul>
+  @actions_by_originator_html;noquote@
+ </ul>
+
+<h3>Interactions by Customer Service Rep</h3>
+ <ul>
+  @actions_by_cs_rep_html;noquote@
+ </ul>
+
+<h3>Actions by Info Used</h3>
+ <ul>
+  @info_used_query_html;noquote@
+ </ul>
Index: openacs-4/packages/ecommerce/www/admin/customer-service/statistics.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/customer-service/statistics.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/ecommerce/www/admin/customer-service/statistics.tcl	9 Mar 2004 00:59:47 -0000	1.4
+++ openacs-4/packages/ecommerce/www/admin/customer-service/statistics.tcl	24 Aug 2008 21:51:19 -0000	1.5
@@ -1,30 +1,17 @@
 # statistics.tcl
-
 ad_page_contract {
     @author
     @creation-date
     @cvs-id $Id$
     @author ported by Jerry Asher (jerry@theashergroup.com)
 } {
 }
-# 
+ 
 ad_require_permission [ad_conn package_id] admin
 
-set page_title "Statistics and Reports"
+set title "Statistics and Reports"
+set context [list [list index "Customer Service"] $title]
 
-append doc_body "[ad_admin_header $page_title]
-<h2>$page_title</h2>
-
-[ad_context_bar [list "../index.tcl" "Ecommerce([ec_system_name])"] [list "index.tcl" "Customer Service Administration"] $page_title]
-
-<hr>
-
-<h3>Issues by Issue Type</h3>
-<ul>
-"
-
-
-
 set important_issue_type_list [db_list get_issue_type_list "select picklist_item from ec_picklist_items where picklist_name='issue_type' order by sort_key"]
 
 # for sorting
@@ -33,9 +20,9 @@
     set issue_type_decode [db_map initial_issue_type_decode_bit]
     set issue_type_counter 0
     foreach issue_type $important_issue_type_list {
-	#append issue_type_decode "'[DoubleApos $issue_type]',$issue_type_counter,"
-	append issue_type_decode [db_map middle_issue_type_decode_bit]
-	incr issue_type_counter
+        #append issue_type_decode "'[DoubleApos $issue_type]',$issue_type_counter,"
+        append issue_type_decode [db_map middle_issue_type_decode_bit]
+        incr issue_type_counter
     }
     #append issue_type_decode "$issue_type_counter)"
     append issue_type_decode [db_map end_issue_type_decode_bit]
@@ -49,81 +36,55 @@
 #where ec_customer_service_issues.issue_id=ec_cs_issue_type_map.issue_id(+)
 #group by issue_type
 #order by decode(issue_type,null,1,0) $issue_type_decode"
-
 set other_issue_type_count 0
+set issues_type_counts_html ""
 db_foreach get_issues_type_counts $sql {
-    
-    if { [lsearch $important_issue_type_list $issue_type] != -1 } {
-	append doc_body "<li>$issue_type: <a href=\"issues?view_issue_type=[ns_urlencode $issue_type]\">$n_issues</a>\n"
+<    if { [lsearch $important_issue_type_list $issue_type] != -1 } {
+        append issues_type_counts_html "<li>$issue_type: <a href=\"issues?view_issue_type=[ns_urlencode $issue_type]\">$n_issues</a></li>\n"
     } elseif { ![empty_string_p $issue_type] } {
-	set other_issue_type_count [expr $other_issue_type_count + $n_issues]
+        set other_issue_type_count [expr $other_issue_type_count + $n_issues]
     } else {
-	if { $other_issue_type_count > 0 } {
-	    append doc_body "<li>all others: <a href=\"issues?view_issue_type=[ns_urlencode "all others"]\">$other_issue_type_count</a>\n"
-	}
-	if { $n_issues > 0 } {
-	    append doc_body "<li>none: <a href=\"issues?view_issue_type=uncategorized\">$n_issues</a>\n"
-	}
+        if { $other_issue_type_count > 0 } {
+            append issues_type_counts_html "<li>all others: <a href=\"issues?view_issue_type=[ns_urlencode "all others"]\">$other_issue_type_count</a></li>\n"
+        }
+        if { $n_issues > 0 } {
+            append issues_type_counts_html "<li>none: <a href=\"issues?view_issue_type=uncategorized\">$n_issues</a></li>\n"
+        }
     }
 }
 
-append doc_body "</ul>
-
-<h3>Interactions by Originator</h3>
-
-<ul>
-"
-
 set sql [db_map get_actions_by_originator_sql]
 #set sql "select interaction_originator, count(*) as n_interactions
 #from ec_customer_serv_interactions
 #group by interaction_originator
 #order by decode(interaction_originator,'customer',0,'rep',1,'automatic',2)"
-
+set actions_by_originator_html ""
 db_foreach get_actions_by_originator $sql {
-    
-    append doc_body "<li>$interaction_originator: <a href=\"interactions?view_interaction_originator=[ns_urlencode $interaction_originator]\">$n_interactions</a>\n"
+    append actions_by_originator_html "<li>$interaction_originator: <a href=\"interactions?view_interaction_originator=[ns_urlencode $interaction_originator]\">$n_interactions</a></li>\n"
 }
 
-append doc_body "</ul>
-
-<h3>Interactions by Customer Service Rep</h3>
-
-<ul>
-"
-
 set sql [db_map get_actions_by_cs_rep_sql]
-#set sql "
-#  select customer_service_rep, first_names, last_name, count(*) as n_interactions
+#set sql "select customer_service_rep, first_names, last_name, count(*) as n_interactions
 #    from ec_customer_serv_interactions, cc_users
 #   where ec_customer_serv_interactions.customer_service_rep=cc_users.user_id
 #group by customer_service_rep, first_names, last_name
 #order by count(*) desc"
-
+set actions_by_cs_rep_html ""
 db_foreach get_actions_by_cs_rep $sql {
-    
-    append doc_body "<li><a href=\"[ec_acs_admin_url]users/one?user_id=$customer_service_rep\
-\">$first_names $last_name</a>: <a href=\"interactions?view_rep=$customer_service_rep\">$n_interactions</a>\n"
+    append actions_by_cs_rep_html "<li><a href=\"[ec_acs_admin_url]users/one?user_id=$customer_service_rep\
+\">$first_names $last_name</a>: <a href=\"interactions?view_rep=$customer_service_rep\">$n_interactions</a></li>\n"
 }
 
-append doc_body "</ul>
-
-<h3>Actions by Info Used</h3>
-
-<ul>
-"
-
 set important_info_used_list [db_list get_important_info_list "select picklist_item from ec_picklist_items where picklist_name='info_used' order by sort_key"]
-
 # for sorting
 if { [llength $important_info_used_list] > 0 } {
     #set info_used_decode ", decode(info_used,"
     set info_used_decode [db_map initial_info_used_decode_bit]
     set info_used_counter 0
     foreach info_used $important_info_used_list {
-	#append info_used_decode "'[DoubleApos $info_used]',$info_used_counter,"
-	append info_used_decode [db_map middle_info_used_decode_bit]
-	incr info_used_counter
+        #append info_used_decode "'[DoubleApos $info_used]',$info_used_counter,"
+        append info_used_decode [db_map middle_info_used_decode_bit]
+        incr info_used_counter
     }
     #append info_used_decode "$info_used_counter)"
     append info_used_decode [db_map end_info_used_decode_bit]
@@ -137,28 +98,20 @@
 #where ec_customer_service_actions.action_id=ec_cs_action_info_used_map.action_id(+)
 #group by info_used
 #order by decode(info_used,null,1,0) $info_used_decode"
-
+set info_used_query_html ""
 set other_info_used_count 0
 db_foreach get_info_used_query $sql {
-    
     if { [lsearch $important_info_used_list $info_used] != -1 } {
-	append doc_body "<li>$info_used: <a href=\"actions?view_info_used=[ns_urlencode $info_used]\">$n_issues</a>\n"
+        append info_used_query_html "<li>$info_used: <a href=\"actions?view_info_used=[ns_urlencode $info_used]\">$n_issues</a></li>\n"
     } elseif { ![empty_string_p $info_used] } {
-	set other_info_used_count [expr $other_info_used_count + $n_actions]
+        set other_info_used_count [expr $other_info_used_count + $n_actions]
     } else {
-	if { $other_info_used_count > 0 } {
-	    append doc_body "<li>all others: <a href=\"actions?view_info_used=[ns_urlencode "all others"]\">$other_info_used_count</a>\n"
-	}
-	if { $n_issues > 0 } {
-	    append doc_body "<li>none: <a href=\"actions?view_info_used=none\">$n_actions</a>\n"
-	}
+        if { $other_info_used_count > 0 } {
+            append info_used_query_html "<li>all others: <a href=\"actions?view_info_used=[ns_urlencode "all others"]\">$other_info_used_count</a></li>\n"
+        }
+        if { $n_issues > 0 } {
+            append info_used_query_html "<li>none: <a href=\"actions?view_info_used=none\">$n_actions</a></li>\n"
+        }
     }
 }
 
-append doc_body "</ul>
-[ad_admin_footer]
-"
-
-
-
-doc_return  200 text/html $doc_body