Ajax calc with 'on load' - value disapears in detailed view

bea

Active Member
Hi,
I noticed today, that my value of my calc elements disappears in detailed view, when I use calc 'on load'.
In form everything looks fine.

Cheers,
Bianka

ps: Joomla 3.8.8, Fabrik 3.8.1
 
What's your calc code?

It could be because data is sometimes formatted differently in details view.

I should probably make that a multiple choice, so rather than Yes/No, make it Form Only / Form & Details / No

But lets look at your code first.

-- hugh
 
Hi Hugh,
here is my code of one element:

PHP:
$shiftorder = '{fab_cp1_line_tour___shiftorder_raw}';
$shift = '{fab_cp1_line_tour___shift_raw}';
$date ='{fab_cp1_line_tour___date_raw}';
$machine ='{fab_cp1_line_tour___machine_raw}';
$myDb = FabrikWorker::getDbo(false, 2);
$myQuery = $myDb->getQuery(true);
$myQuery
    ->select('losses2_stops')
    ->from('bde_daten')
    ->where('shiftorder= ' . $myDb->quote($shiftorder))
    ->where('shift= ' . $myDb->quote($shift))
    ->where('date= ' . $myDb->quote($date))
    ->where('machine= ' . $myDb->quote($machine));
$myDb->setQuery($myQuery);
$total = $myDb->loadResult();
return $total;
 
Yeah, depending what element types those are, they may be arrays.

As it's rather hard to do the usual var_dump($whatever);exit; thing for calcs, what I usually do to test that is include the value I want to see in the return ...

Code:
return $shiftorder . ' ' . $shift . ' ' . $date . ' ' . $machine . ' ' . $total;

... or look at the query itself ...

Code:
//$total=$myDb->loadResult();
return (string)$myQuery;

(comment out the query in case it's blowing up)

The returned debug values should then just show in the calc display on the form. That should show you if you are getting what you expect.

-- hugh
 
Hi Hugh,

the results in form are correct
return $shiftorder . ' ' . $shift . ' ' . $date . ' ' . $machine . ' ' . $total;
1 3 2018-07-21 00:00:00 7 19

return (string)$myQuery;
SELECT losses2_stops FROM bde_daten WHERE shiftorder= '1' AND shift= '3' AND date= '2018-07-21 00:00:00' AND machine= '7'

in detailed view the date time is wrong:
1 Nacht 2018-07-20 22:00:00 Cetec 1000

I have no idea to solve this....

In detailed view the date and time shows first the correct date and time and the it jumps to previous day at 22:00:00.
 
Last edited:
That looks like a time zone difference.

In the actual date display in details view, I presume the date/time is correct? You are only seeing the TZ shift from your calc?

-- hugh
 
Hi Hugh,
date is correct (local) in form and detailed view. Just with on load it switch to the other date-t
Cheersime.
 
Yeah, I think that's one of those chicken and egg things. The calc code runs before the date element has had a chance to tweak the TZ.

I'll do some testing, see if that's fixable. We do have a "preProcess" phase, which is supposed to get elements to do any massaging of data, before the calc runs. But it's possible the date element may not implement it.

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

Thank you.

Members online

No members online now.
Back
Top