Hi,
I have a content type with many fields to build a table to add value for each day of the month in order to build a table report.
The fields are text fields to enter numbers of product done for each day and called: Stage1Day1, Stage1Day2, Stage1Day3 ....
I also have one text field where a total is entered and called: TotalQuantity
Since it's a production report. I need to have a balance and a percentage of completion.
balance = total - (sum of all fields)
completion = ((sum of all fields) / TotalQuantity) * 100
And i display the completion using round($completion) to have round number used to create a progress bar.
I'm able to "echo" all these fields in my template and also make the calculation in item view. Everything is working: the balance is correct and my progress bar as well.
But I have errors when in category view.
I placed the fields in renderonly. And in my template I use
Code:
<?php echo $item->fields['Stage1Day1']->display; ?>
to display the fields. All good up to now.
But when I do my caculation to get the balance and progress i get "Undefined variable:" and "Trying to get property of non-object". And no calculation is done.
This is what i use to make the calculation. Which is the same concept that I use in item view.
Code:
$mytotal = $item->fields['Stage1Day1']->display + $item->fields['Stage1Day2']->display + $item->fields['Stage1Day3']->display + $item->fields['Stage1Day4']->display + $item->fields['Stage1Day5']->display + $item->fields['Stage1Day6']->display + $item->fields['Stage1Day7']->display + $item->fields['Stage1Day8']->display + $item->fields['Stage1Day9']->display + $item->fields['Stage1Day10']->display + $item->fields['Stage1Day11']->display + $item->fields['Stage1Day12']->display + $item->fields['Stage1Day13']->display + $item->fields['Stage1Day14']->display + $item->fields['Stage1Day15']->display + $item->fields['Stage1Day16']->display + $item->fields['Stage1Day17']->display + $item->fields['Stage1Day18']->display + $item->fields['Stage1Day19']->display + $item->fields['Stage1Day20']->display + $item->fields['Stage1Day21']->display + $item->fields['Stage1Day22']->display + $item->fields['Stage1Day23']->display + $item->fields['Stage1Day24']->display + $item->fields['Stage1Day25']->display + $item->fields['Stage1Day26']->display + $item->fields['Stage1Day27']->display + $item->fields['Stage1Day28']->display + $item->fields['Stage1Day29']->display + $item->fields['Stage1Day30']->display + $item->fields['Stage1Day31']->display;
I even tried to first set them as variable like so:
Code:
$Stage1Day1 = $item->fields['Stage1Day1']->display;
$Stage1Day2 = $item->fields['Stage1Day2']->display;
....
and then add the variable like to:
Code:
$mytotal = $Stage1Day1 + $Stage1Day2 + $Stage1Day3 ....
Does anyone have an idea why it's not working.
I wonder if it has nothing to do with the one of the fix showing on github for FC v3.0.9-dev2: "Fixed fieldgroup field mixing field values in category view when custom HTML parameter is used".
I should add that I have other sets of similar fields for different stages. But of course, they have a different field name.
thank you in advance.