+@title@
+"@title@"
+
+@content;noquote@
\ No newline at end of file
Index: openacs-4/packages/scholarship-fund/www/export-confirm.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/scholarship-fund/www/export-confirm.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/scholarship-fund/www/export-confirm.tcl 14 Aug 2005 12:38:52 -0000 1.1
@@ -0,0 +1,39 @@
+ad_page_contract {
+ Confirmation page to export and mark exported
+
+ @author Hamilton Chua (hamilton.chua@gmail.com)
+ @creation-date 2005-08-14
+
+} {
+ { fund_id:integer,multiple,optional }
+ { all 0 }
+ { mark 0 }
+}
+
+set title "Export"
+set package_id [ad_conn package_id]
+set package_url [apm_package_url_from_id $package_id]
+set user_id [ad_conn user_id]
+set qstring ""
+set content ""
+
+# check permissions
+permission::require_permission \
+ -object_id $package_id \
+ -party_id $user_id \
+ -privilege "read"
+
+# let's check first if there are unmarked items for export
+if { [db_string "count_transferred" "select count(*) from scholarship_fund where export_p = 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 records have been MARKED transferred.
There are no scholarship fund records for transfer."
+}
+append content "
Go back to Scholarship Fund administration."
\ No newline at end of file
Index: openacs-4/packages/scholarship-fund/www/export-sch.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/scholarship-fund/www/export-sch.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/scholarship-fund/www/export-sch.adp 14 Aug 2005 12:38:52 -0000 1.1
@@ -0,0 +1,4 @@
+
+@title@
+
+
\ No newline at end of file
Index: openacs-4/packages/scholarship-fund/www/export-sch.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/scholarship-fund/www/export-sch.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/scholarship-fund/www/export-sch.tcl 14 Aug 2005 12:38:52 -0000 1.1
@@ -0,0 +1,75 @@
+ad_page_contract {
+
+ Generate a CSV of the given fund_id
+
+ @author Hamilton Chua (hamilton.chua@gmail.com)
+ @creation-date 2005-08-14
+
+} {
+ {fund_id:integer,multiple,optional}
+ {all 0}
+ {mark 0}
+}
+
+set title "Export Scholarship Funds"
+set context $title
+
+# generate list of exp_item_id's for export
+if { [exists_and_not_null fund_id] } {
+ for {set i 0} {$i < [llength $fund_id]} {incr i} {
+ set id_$i [lindex $fund_id $i]
+ lappend bind_id_list ":id_$i"
+ }
+}
+
+# use list template to create list of scholarship funds
+
+template::list::create \
+ -name scholarship_funds \
+ -multirow scholarship_funds \
+ -key fund_id \
+ -selected_format csv \
+ -formats {
+ csv { output csv }
+ } -elements {
+ sch_fund {
+ label "Fund"
+ }
+ account_code {
+ label "Account Code"
+ }
+ description {
+ label "Description"
+ }
+ }
+
+# build the multirow
+
+set query "select fund_id, description, account_code, export_p from scholarship_fundx where export_p = false"
+
+# 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 {
+#}
+
+
+db_multirow scholarship_funds get_sch_funds $query { }
+
+if { $mark == 1 } {
+ db_dml "mark_exported" "update scholarship_fund set exported_p = 't'"
+}
+
+# change headers to output csv
+set outputheaders [ns_conn outputheaders]
+ns_set cput $outputheaders "Content-Disposition" "attachment; filename=scholarship_fund.csv"
+template::list::write_output -name scholarship_funds
Index: openacs-4/packages/scholarship-fund/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/scholarship-fund/www/index.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/scholarship-fund/www/index.tcl 5 Aug 2005 03:35:11 -0000 1.4
+++ openacs-4/packages/scholarship-fund/www/index.tcl 14 Aug 2005 12:38:52 -0000 1.5
@@ -30,7 +30,10 @@
-party_id $user_id \
-privilege "admin"]
-set actions [list "Add Fund" fund-add-edit "Add a new scholarship fund"]
+set actions [list "Add Fund" fund-add-edit "Add a new scholarship fund" \
+ "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"]
+
db_multirow -extend { one_url edit_url delete_url } funds get_funds "" {
set one_url [export_vars -base one-fund {item_id}]
set edit_url [export_vars -base fund-add-edit {item_id}]