This topic is locked
[SOLVED]

 Calculating Two Totals on list page

7/28/2015 2:24:48 AM
PHPRunner General questions
B
BDWMQ8 author

I am a newbie to php

With my PHPRunner 8.0 I need to have in the 'list page' one total which is not the count/sum/average of the above records, but a division of two other totals next to it (I need it to calculate the ratio of total Contacts to total sales). I have tried a php snippet and looked all over for what i think should be a simple solution but dont seem to be able to find anything that works.

I would appreciate help with this one.

Thanks

Alan

admin 7/28/2015

In BeforeDisplay event of this page you can access those totals variables and perform calculations.

  1. Create we are going to add a custom variable to this page


2. To do so we need to switch to HTML mode and insert {$mytotal} placeholder


3. Now we add the following in BeforeDisplay event of this page:

$credit = strip_tags($xt->getvar("Credit_total"));

$debit = strip_tags($xt->getvar("Debit_total"));

if ($debit!=0)

$xt->assign("mytotal",$credit/$debit);


4. And this is how it looks in generated application

B
BDWMQ8 author 7/29/2015

Thanks so much for this - easy when you know how!

Best

Alan