Hi Steve,
It is still a little difficult to offer good advice because the question is a little open-ended.Ê The way I look at this problem is in 2 parts:
1. Data entry
2. Generating reports
On which of these two areas are you looking for advice.Ê Looks like you have already created your table structure, and I'm assuming that you know the data that you are modeling better than I, so there isn't alot of advice I can give on the first section, other than answering more specific technical questions on how to achieve objectives (relating to data entry).
As for generating reports.Ê The Dataface search/find features allow you to search for records based on various criteria but it doesn't show you any totals.
If you simply want to get the totals for some columns of a table, you could just add a block after the result list, generate some totals there and display them.
e.gÊ Here is an untested (i.e. it will probably give you errors at first that you'll have to iron out) function that is meant to display totals for all integer and float columns in the current table's found set.Ê This function is meant to be added to a delegate class.Ê The title of the function indicates that its output is to be placed in a block named after_result_list.Ê The result list (the list view) template has a block by this name so the contents will be placed after the list in list view.
function block__after_result_list(){
ÊÊÊ $app =& Dataface_Application::getInstance();
ÊÊÊ $query = & $app->getQuery();
ÊÊÊ $table =& Dataface_Table::loadTable($query['-table']);
ÊÊÊ
ÊÊÊ
ÊÊÊ $columns = array();
ÊÊÊ foreach ( array_keys($table->fields(false,true)) as $field ){
ÊÊÊ ÊÊÊ if ( $table->isInt($field) or $table->isFloat($field) ){
ÊÊÊ ÊÊÊ ÊÊÊ $columns[] = "sum(`$field`) as `$field`";
ÊÊÊ ÊÊÊ }
ÊÊÊ }
ÊÊÊ
ÊÊÊ $qb = new Dataface_QueryBuilder($query['-table'], $query);
ÊÊÊ $orig_select = $qb->select();
ÊÊÊ
ÊÊÊ $sql = "select ".implode(', ', $columns)." ".substr($orig_select, strpos($orig_select, 'from'));
ÊÊÊ
ÊÊÊ $res = df_query($sql);
ÊÊÊ echo "
Totals:
ÊÊÊ
ÊÊÊ ÊÊÊ ";
ÊÊÊ foreach ($columns as $column){
ÊÊÊ ÊÊÊ $field = $table->getField($column);
ÊÊÊ ÊÊÊ echo "".$field['widget']['label']." | ";
ÊÊÊ }
ÊÊÊ echo "
ÊÊÊ ";
ÊÊÊ
ÊÊÊ while ($row = mysql_fetch_assoc($res) ){
ÊÊÊ ÊÊÊ echo "";
ÊÊÊ ÊÊÊ foreach ($columns as $column){
ÊÊÊ ÊÊÊ ÊÊÊ echo "".htmlspecialchars($row[$column])." | ";
ÊÊÊ ÊÊÊ }
ÊÊÊ ÊÊÊ echo "
";
ÊÊÊ }
ÊÊÊ echo "
";
ÊÊÊ
ÊÊÊ @mysql_free_result($res);
}
If you need more advanced reporting, you may want to create a custom action.Ê See the getting started tutorial for information on creating custom actions.
-Steve