How to add a number in a field to a calc for checkboxes?

annasweb

Member
It took a while for me to work with the support team and understand how to get my points for checked boxes to calculate. I now need to know how to add a number that is in a field to these checkbox calculations. Currently I have what's in blue below and am wondering if I would just add the red part to make this work.

$chbox = $data['gromsterz___select_badges_raw'];
$chbox_count = 0;
if (!empty($chbox)) {
if (!is_array($chbox)) {
$chbox = json_decode($chbox);
}
$chbox_count1 = count($chbox);
}

$chbox = $data['gromsterz___trick_badges_raw'];
$chbox_count = 0;
if (!empty($chbox)) {
if (!is_array($chbox)) {
$chbox = json_decode($chbox);
}
$chbox_count2 = count($chbox);
}

$field = $data['gromsterz___bonus_points_raw'];
$field_count = 0;
if (!empty($field)) {
if (!is_array($field)) {
$field = json_decode($field);
}
$field_count1 = count($field);
}

return $chbox_count1 * 25 + $chbox_count2 * 100 + $field;


I think I have something coded wrong in the red part.

Thanks,
Anna
 
Can anyone tell me the right way to do this? Using my details in red I don't seem to get the number in my Bonus Points adding into my total points.

Thanks,
Anna
 
I was able to get the number to add into the row, however, now the total of the column is off by the number - it isn't adding the number into the column total.

I used this:

$chbox = $data['gromsterz___select_badges_raw'];
$chbox_count = 0;
if (!empty($chbox)) {
if (!is_array($chbox)) {
$chbox = json_decode($chbox);
}
$chbox_count1 = count($chbox);
}

$chbox = $data['gromsterz___tech_badges_raw'];
$chbox_count = 0;
if (!empty($chbox)) {
if (!is_array($chbox)) {
$chbox = json_decode($chbox);
}
$chbox_count2 = count($chbox);
}

$chbox = $data['gromsterz___bonus_badges_raw'];
$chbox_count = 0;
if (!empty($chbox)) {
if (!is_array($chbox)) {
$chbox = json_decode($chbox);
}
$chbox_count3 = count($chbox);
}

$chbox = $data['gromsterz___trick_badges_raw'];
$chbox_count = 0;
if (!empty($chbox)) {
if (!is_array($chbox)) {
$chbox = json_decode($chbox);
}
$chbox_count4 = count($chbox);
}

$val = $data['gromsterz___bonus_points_raw'];

return $chbox_count1 * 25 + $chbox_count2 * 25 + $chbox_count3 * 25 + $chbox_count4 * 100 + $val;

I need to know how to have the column recognize that the bonus points are included into the members row and should be added into the column total.

Any suggestions on how to make this work is appreciated.

Thanks,
Anna
 
Can you put:

PHP:
var_dump($data);exit;

... as the first line of your calc, submit the form, and paste the debug output here?

You may need to add that line to your cals after you load your form, so it doesn't short circuit the loading.

-- hugh
 
Hugh,

Thanks for the help. I added it to the calc, created a new member from the form giving the member bonus points and the Points col. did indeed calculate those points properly. On the two members that have bonus points and they are not adding into the col total, but their row total is in that same column, they were existing members and I clicked on their names to edit their info and added the bonus points. Not sure why they wouldn't add in but maybe you have an idea.

I don't see any debug output 0n then page. Do I need to enable the debug in global configs for joomla?

Anna
 
Hugh,
I added 2 more members and the bonus points seem to be adding just fine into the column total. I will delete the bonus points for the 2 problem members and add them back into their records. Maybe these were done before I added the $val to the calc.

On the list when there are no bonus points for a member, a "0" is shown. That is the default on the form. Is there a way to show nothing on the form and the column if the member has no bonus points?


Anna
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top