Plugin: Column Totals
2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 10, 2017 (RSS)
By Toledoh - July 6, 2017
Hi Guys,
This isn't for a set project - I was just wondering if it's something I could play with, with some forum direction, or whether it would be something harder than that.
I'd like to have a plugin where you can define the table/s and field/s, then in the list viewer it adds a total for that field for all returned records.
ie. If I had a section "Invoices" and in that had fields "Outstanding" and "Total". I would have an array within the plugin that would be something like:
$GLOBALS['columnTotalsPlugin'] = 'invoices'; // tablename of the section/s where totals will appear.
$GLOBALS['columnTotalsPlugin'] = 'outstanding,total'; // fieldname/s of the fields that will be calculated.
Then the plugin would add a tfoot section with totals in the appropriate cells. Maybe some error checking to ensure that the fields are in the correct format?
Just an idea at this stage - but happy to take it offline.
Cheers,
Tim (toledoh.com.au)
By Dave - July 10, 2017
Hey Tim,
Yea, that's a neat idea. The trick would be finding a plugin hook that let us get all the returned record nums. It might be easiest to hard code it to start. The MySQL might be something like this:
SELECT SUM(outstanding) WHERE num IN (1,4,8,123)
Also you'd need to figure out the html to add the tfoot.
interactivetools.com