Index: openacs-4/packages/invoices/www/invoice-reports.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-reports.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/invoices/www/invoice-reports.tcl 6 Sep 2005 23:02:05 -0000 1.1
+++ openacs-4/packages/invoices/www/invoice-reports.tcl 13 Sep 2005 20:56:28 -0000 1.2
@@ -8,6 +8,7 @@
organization_id
{last_years:optional "5"}
{year:optional ""}
+ {day:optional ""}
{month:optional ""}
{new_clients_p ""}
{account_manager_p ""}
@@ -21,17 +22,102 @@
set page_title "[_ invoices.iv_reports]"
set context [list $page_title]
-set year_p 0
-set month_p 0
-set day_p 0
+# For to choose how many last years we want to show
+ad_form -name aggregate -form {
+ {organization_id:text(hidden)
+ {value $organization_id}
+ }
+ {day:text(hidden)
+ {value $day}
+ }
+ {month:text(hidden)
+ {value $month}
+ }
+ {year:text(hidden)
+ {value $year}
+ }
+ {new_clients_p:text(hidden)
+ {value $new_clients_p}
+ }
+ {account_manager_p:text(hidden)
+ {value $account_manager_p}
+ }
+ {last_years:text(text),optional
+ {label "[_ invoices.last_years]:"}
+ {value $last_years}
+ {html {size 2}}
+ {help_text { [_ invoices.aggregate_iv_from] }}
+ }
+}
+# We select wich inlcude we want according to the values present on the
+# variables year and month
+set include_src "/packages/invoices/lib/report-year"
+if { ![empty_string_p $year] } {
+ set include_src "/packages/invoices/lib/report-month"
+}
+
if { ![empty_string_p $year] && ![empty_string_p $month]} {
- set day_p 1
-} elseif { ![empty_string_p $year] } {
- set month_p 1
-} else {
- set year_p 1
+ set include_src "/packages/invoices/lib/report-day"
}
+# We create 3 multirows for the years, months and days
+multirow create years year year_url
+multirow create months month month_url
+multirow create days day day_url
+set actual_year [string range [dt_sysdate] 0 3]
+set url [export_vars -base invoice-reports {organization_id month day last_years new_clients_p account_manager_p}]
+for { set i $last_years } { $i > 0 } { set i [expr $i - 1] } {
+ set myear [expr $actual_year - $i]
+ set url [export_vars -base invoice-reports {organization_id {year $myear} month day last_years new_clients_p account_manager_p}]
+ multirow append years $myear "$myear"
+}
+
+# We always look for 5 years from actual year
+for { set i $actual_year } { $i < [expr $actual_year + 6] } { incr i} {
+ set url [export_vars -base invoice-reports {organization_id {year $i} month day last_years new_clients_p account_manager_p}]
+ multirow append years $i "$i"
+}
+
+if { [exists_and_not_null year] } {
+ set url [export_vars -base invoice-reports {organization_id last_years new_clients_p account_manager_p month day}]
+ multirow append years "clear" "(Clear)"
+}
+
+for { set i 1 } { $i < 13 } { incr i } {
+ set short_month [template::util::date::monthName $i short]
+ # Dates format has a 0 before the number for months that
+ # are lower than 10
+ if { $i < 10 } {
+ set m "0$i"
+ } else {
+ set m $i
+ }
+ set url [export_vars -base invoice-reports {organization_id year {month $m} last_years new_clients_p account_manager_p day}]
+ multirow append months $m "$short_month"
+}
+
+if { [exists_and_not_null month] } {
+ set url [export_vars -base invoice-reports {organization_id year last_years new_clients_p account_manager_p day}]
+ multirow append months "clear" "(Clear)"
+}
+
+for { set i 1 } { $i < 32 } { incr i } {
+ # Dates format has a 0 before the number for days that
+ # are lower than 10
+ if { $i < 10 } {
+ set d "0$i"
+ } else {
+ set d $i
+ }
+ set url [export_vars -base invoice-reports {organization_id year month {day $d} last_years new_clients_p account_manager_p}]
+ multirow append days $d "$d"
+}
+
+if { [exists_and_not_null day] } {
+ set url [export_vars -base invoice-reports {organization_id year month last_years new_clients_p account_manager_p}]
+ multirow append days "clear" "(Clear)"
+}
+
ad_return_template