Forums: How to perform calculations between totals on the List page - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to perform calculations between totals on the List page

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 15495
  • Joined: 03-February 03

Posted 30 July 2015 - 07:51 PM

Q: I have two totals on the List page. I need to divide one total by another and display result next to them on the same page.

A: Here is how we can do this.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

Posted Image

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

Posted Image

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

Posted Image
Best regards,
Sergey Kornilov
0

#2 User is offline   Alain 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 31
  • Joined: 12-February 17

Posted 24 November 2017 - 12:36 PM

Very useful but seem to be not working when $credit and $debit are set as currency

any idea??

View Postadmin, on 30 July 2015 - 07:51 PM, said:

Q: I have two totals on the List page. I need to divide one total by another and display result next to them on the same page.

A: Here is how we can do this.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

Posted Image

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

Posted Image

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

Posted Image

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic