Sub-totalling with List Builder
set groupby "stage_description"
2. Add a new groupby section to end of the list. "type multivar" just tells List Builder to tell ad_page_contract that the groupby is not a multiple element. All the curly brackets are unfortunately needed – the first list element is the text which is displayed in front of each group; you can put HTML tags and more in here. The second list element tells List Builder that we are grouping by stage_description – this seems repetitive so maybe there’s a better way to do this, but I can't see any issues with it. You can also have an orderby clause in here if you need one.
-groupby {
type multivar
values {
{ {[_ payment.Financial_Stage]} { {groupby stage_description} } }
}
}
3. Modify the financial_amount element to add aggregation information. aggregate can be one of “sum”, “average” or “count”. The aggregate_group_label allows you to put some text and a currency symbol before each sub-total. aggregate_label does the same for the grand total.
financial_amount {
label "[_ payment.Amount]"
aggregate "sum"
aggregate_group_label "[_ payment.Sub-Total]: [lc_get -locale $locale currency_symbol]"
aggregate_label "[_ payment.Grand-Total]: [lc_get -locale $locale currency_symbol]"
}
4. Gotchas to look out for:
you need to use the -pass_properties section to allow List Builder to see program variables outside the list scope e.g. $locale.
List builder doesn't differentiate between currency and numbers – it just treats the aggregated column as a number. However, it does use the acs-lang formatting when displaying (specifically lc_numeric), which should be good enough for most cases. You need to do your own formatting on the individual line items. Here's how to use display_eval to format the financial_amount element:
display_eval {[lc_monetary -label_p "t" $financial_amount $locale ]}
Noquoting can be painful but the following workaround should suffice – note the triple underscore:
display_template {@financial.financial_amount___display;noquote@}
Our finished example:
-elements {
stage_description {
label "[_ payment.Financial_Stages]"
}
financial_amount {
label "[_ payment.Amount]"
aggregate "sum"
aggregate_group_label "[_ payment.Sub-Total]: [lc_get -locale $locale currency_symbol]"
aggregate_label "[_ payment.Grand-Total]: [lc_get -locale $locale currency_symbol]"
display_eval {[lc_monetary -label_p "t" $financial_amount $locale ]}
display_template {@financial.financial_amount___display;noquote@}
}
}
-groupby {
type multivar
values {
{ {[_ payment.Financial_Stage]} { {groupby stage_description} } }
}
}
A good example from OpenACS CVS:
04:48 PM, 14 Mar 2007 by Brian Fenton Permalink | Comments (0)
How-To: Add an Autosuggest Text Field
Assumptions:
This is somewhat similar to Ryan Gallimore's smart search widget. The differences are:
Steps:
{tags:text,optional {html {size 50 id autosuggest_box}}....
set ah_sources [ah::js_sources -source "autosuggest"]
set query "select username, email from cc_users"
set ah_suggestions_array [ah::generate_autosuggest_array -sql_query $sql_query]
or
set array_list {{apple red} {banana yellow} {orange orange}}
set ah_suggestions_array [ah::generate_autosuggest_array -array_list $array_list]
<property name="header_stuff">
@ah_sources;noquote@
<script type="text/javascript">
@ah_suggestions_array;noquote@
</script>
</property>
window.onload=loadAutoSuggest();
Some nice things to do
10:53 AM, 30 Oct 2006 by Deds Castillo Permalink | Comments (0)
large pg_dumps [openacs.org]
pg_dump yourdb | split -b 1024m - yourdb_
which will create 1Gb files called yourdb_aa, yourdb_ab, yourdb_ac etc.
Then you can import them using cat:
cat yourdb_* | psql yourdb
05:51 PM, 09 Mar 2006 by Rocael Hernández Rizzardini Permalink | Comments (0)
September 2013 | ||||||
S | M | T | W | T | F | S |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||