Index: openacs-4/packages/expenses/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/expenses/tcl/apm-callback-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/expenses/tcl/apm-callback-procs.tcl 31 May 2005 22:07:20 -0000 1.1
+++ openacs-4/packages/expenses/tcl/apm-callback-procs.tcl 2 Jun 2005 10:43:55 -0000 1.2
@@ -7,6 +7,8 @@
@cvs-id $Id$
}
+namespace eval expenses { }
+
ad_proc -private expenses::package_mount {
-package_id
-node_id
Index: openacs-4/packages/expenses/tcl/expenses-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/expenses/tcl/expenses-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/expenses/tcl/expenses-procs.tcl 31 May 2005 22:07:20 -0000 1.1
+++ openacs-4/packages/expenses/tcl/expenses-procs.tcl 2 Jun 2005 10:43:55 -0000 1.2
@@ -36,4 +36,18 @@
db_dml "mark_exported" "update expenses set exp_exported = 't'"
}
+ad_proc list_expense_codes {
+ {-id:required }
+} {
+ HAM (hamilton.chua@gmail.com)
+ Return comma separated list of expense codes given an expense id
+} {
+ set expense_codes ""
+ set categories [category::get_mapped_categories $id]
+ foreach category_id $categories {
+ append expense_codes "[category::get_name $category_id]"
+ }
+ return [join $expense_codes ", "]
+}
+
}
\ No newline at end of file
Index: openacs-4/packages/expenses/www/admin/export-confirm.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/expenses/www/admin/export-confirm.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/expenses/www/admin/export-confirm.tcl 31 May 2005 22:07:21 -0000 1.1
+++ openacs-4/packages/expenses/www/admin/export-confirm.tcl 2 Jun 2005 10:43:56 -0000 1.2
@@ -15,15 +15,8 @@
set package_id [ad_conn package_id]
set package_url [apm_package_url_from_id $package_id]
set qstring ""
+set content ""
-set content "
Click the download link to start downloading the exported records in CSV format.
"
-set qstring "all=$all&mark=$mark"
-
-if { [exists_and_not_null exp_id] } {
- set exp_id_string [join $exp_id "&exp_id="]
- append qstring "&exp_id=$exp_id_string"
-}
-
#if { $all == 1 } {
# set qstring "all=1&"
#} else {
@@ -35,5 +28,17 @@
# }
#}
-append content "
Download CSV."
+# let's check first if there are unmarked items for export
+if { [db_string "count_transferred" "select count(*) from expenses where exp_exported = false"] > 0 } {
+ append content "Click the download link to start downloading the exported records in CSV format.
"
+ set qstring "all=$all&mark=$mark"
+
+ if { [exists_and_not_null exp_id] } {
+ set exp_id_string [join $exp_id "&exp_id="]
+ append qstring "&exp_id=$exp_id_string"
+ }
+ append content "
Download CSV."
+} else {
+ append content "
Sorry, but all expense records have been MARKED transferred.
There are no expense records for transfer."
+}
append content "
Go back to Expense Tracking Administration."
\ No newline at end of file
Index: openacs-4/packages/expenses/www/admin/export-expenses.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/expenses/www/admin/export-expenses.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/expenses/www/admin/export-expenses.tcl 31 May 2005 22:07:21 -0000 1.1
+++ openacs-4/packages/expenses/www/admin/export-expenses.tcl 2 Jun 2005 10:43:56 -0000 1.2
@@ -49,31 +49,39 @@
community_id {
label "Community"
}
+ expense_codes {
+ label "Expense Codes"
+ }
}
# build the multirow
-set query "select exp_id, exp_amount, exp_date, exp_expense, user_id, community_id from expenses"
+set query "select exp_id, exp_amount, exp_date, exp_expense, user_id, community_id from expenses where exp_exported = false"
-if { $all == 0 } {
- set items_for_export [join $bind_id_list ","]
- append query " where exp_id in ( $items_for_export )"
+# Save for Later in case we want
+# to bring back selective exports
+
+#if { $all == 0 } {
+# set items_for_export [join $bind_id_list ","]
+# append query " and exp_id in ( $items_for_export )"
# mark id's as exported only if $mark ==1
- if { $mark == 1 } {
- foreach id $exp_id {
- expenses::mark_exported -id $id
- }
- }
-} else {
- if { $mark == 1 } {
- expenses::mark_all_exported
- # db_dml "mark_all_exported" "update expenses set exp_exported = 't'"
- }
-}
+# if { $mark == 1 } {
+# foreach id $exp_id {
+# expenses::mark_exported -id $id
+# }
+# }
+#} else {
+#}
-db_multirow expenses get_expenses $query
+db_multirow -extend {expense_codes} expenses get_expenses $query {
+ set expense_codes [expenses::list_expense_codes -id $exp_id]
+}
+if { $mark == 1 } {
+ expenses::mark_all_exported
+}
+
# change headers to output csv
set outputheaders [ns_conn outputheaders]
ns_set cput $outputheaders "Content-Disposition" "attachment; filename=expenses.csv"
Index: openacs-4/packages/expenses/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/expenses/www/admin/index.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/expenses/www/admin/index.tcl 31 May 2005 22:07:21 -0000 1.1
+++ openacs-4/packages/expenses/www/admin/index.tcl 2 Jun 2005 10:43:56 -0000 1.2
@@ -22,7 +22,7 @@
-multirow expenses \
-key exp_id \
-actions {
- "Export All and MARK ALL Transferred" "export-confirm?all=1&mark=1" "Export All Expenses"
+ "Export All Non-Transferred and MARK ALL Transfered" "export-confirm?all=1&mark=1" "Export All Expenses"
"Export All but DO NOT MARK Transferred" "export-confirm?all=1&mark=0" "Export Expenses"
} -elements {
exp_date {
@@ -41,7 +41,7 @@
label "Course/Section"
}
exp_exported {
- label "Exported"
+ label "Transferred"
display_template {
Yes
@@ -51,6 +51,9 @@
}
}
+ expense_codes {
+ label "Expense Codes"
+ }
} -orderby {
exp_date { orderby exp_date }
exp_amount { orderby exp_amount }
@@ -60,9 +63,11 @@
set orderby_clause "[template::list::orderby_clause -name expenses -orderby]"
-db_multirow -extend {course} expenses get_expenses { } {
+db_multirow -extend {course expense_codes} expenses get_expenses { } {
# retrieve course/section for this expense
- db_0or1row "section_info" "select section_name, course_id from dotlrn_ecommerce_section where community_id =:community_id"
- set course_name [db_string "getcoursename" "select course_name from dotlrn_catalog where course_id = (select latest_revision from cr_items where item_id =:course_id)"]
- set course "$course_name/$section_name"
+ if { [db_0or1row "section_info" "select section_name, course_id from dotlrn_ecommerce_section where community_id =:community_id"] } {
+ set course_name [db_string "getcoursename" "select course_name from dotlrn_catalog where course_id = (select latest_revision from cr_items where item_id =:course_id)"]
+ set course "$course_name/$section_name"
+ set expense_codes [expenses::list_expense_codes -id $exp_id]
+ }
}
\ No newline at end of file