Guide 16 - Totals group on List pages |
5/23/2021 6:35:58 PM |
PHPRunner Tips and Tricks | |
fhumanes author
They consulted me how to make totalizations by groups, on the LIST pages and facilitated links on how to do it in versions of Phprunner, 6, 7 and 8. We were not able to find references of the same topic in versions 10 of Phprunner. I was spinning, without wanting to modify the template of the page (as it was done in previous versions) and in the end I have found a very easy solution, based on obtaining the totalizations and the registry where you have to put it in SQL. Objective Produce column totalizations when you change group on a List page Technical solution Demo: https://fhumanes.com/ruptura
If you want to see the coding and dispose of a complete example, access my site to download it. |
|
fhumanes author 5/23/2021 | |
It has some limitations, for example, that you can not let the user order the columns, as it requires them to be ordered in a special way. The "secret" is that the data when executing the SQL has already calculated the total and the line where the total must be printed. In this example, the data is obtained: The record data. SELECT To get the total, this Select is executed. SELECT factura_idfactura factura_idfactura_t1, sum(Valor) Total FROM linea_factura group by factura_idfactura To know which line you have to "print" the total. SELECT factura_idfactura factura_idfactura_t2, max(idlinea_factura) idlinea_factura_t2 FROM linea_factura group by factura_idfactura Thus, uniting everything, this is the resulting query. SELECT
In the idfacture column we put the group check so that the value of the column is not repeated. In the value column we put the value field and that of the total. For one on top of another, we include this value in the CUSTOM CSS field of each of them. :host { We have the last one and it is to indicate the total field when and how it should be printed. We use a CUSTOM visualization and include this code. if ( $data['idlinea_factura_t2'] == NULL){ What it does is:
And that's how easy it has been left. For any questions or problems, please get in touch via email fernandohumanes@gmail.com. |