1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

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

Discussion in 'Professional Support' started by bea, Jul 21, 2018.

  1. bea

    bea Active Member

    Level: Community
    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
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  3. bea

    bea Active Member

    Level: Community
    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;
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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 (Text):

    return $shiftorder . ' ' . $shift . ' ' . $date . ' ' . $machine . ' ' . $total;
     
    ... or look at the query itself ...

    Code (Text):

    //$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
     
  5. bea

    bea Active Member

    Level: Community
    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: Jul 22, 2018
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  7. bea

    bea Active Member

    Level: Community
    Hi Hugh,
    date is correct (local) in form and detailed view. Just with on load it switch to the other date-t
    Cheersime.
     
  8. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     

Share This Page