Calculated $ Value at Top of List

guyfromnola

New Member
Not sure this has really been posed anywhere else in the forum (not that that I could find, anyway). However, if it is, please feel free to send me there.

I have a need to show at the top of my list (somewhere/somehow) a calculated $ value. Each record in my list has a status field that shows a record as being Pending, Active, or Expired. When someone adds a new record, it defaults to Pending status. For each record that is added I want the calculated value to reflect how many Pending records there are, multiplied by $5 to show a total amount due. For instance, if someone adds 3 new records, they are all pending and will show $15 at the top of the list until payment is received and processed. Then, as records are set to Active status, that calculated amount is deducted by $5 for each record that is activated, noting that if they don't provide payment in full, there will still be a partial balance shown as due in the calculated field. Is this something that is easy to achieve, or at least remotely doable? If so, any assistance would be appreciated. I'm not a huge coder, but can follow steps/directions pretty well if there is a go-by, of sorts.
 
Probably easiest to do that with your own little custom module with some PHP embedded in it with Sourcerer.

Is your list pre-filtered?

-- hugh
 
Then yes, some PHP embedded either in a module you display on the page, or directly in your list intro, using Sourcerer (from Regular Labs). Something like ...

Code:
{source}
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT (*) AS total')->from('yourtable')->where('user_id = ' . (int)JFactory::getUser()->get('id'))->where('status = "pending"');
$db->setQuery($query);
$total = $db->loadResult();
echo "Total: " . $total;
?>
{/source}

Change the table and field names, etc to suit.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top