• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Clac not giving correct answer for only 1 block?

bespokeappstt

Hubstaff freelancer
I am using the calc element to calculate the number of days a resource is out and if it's returned late calculate the number of days it late. If it isn't returned, then calculate the number of days it overdue to be in. The following calculations work just fine:
  1. days overdue if it was returned late
  2. do nothing if the schedule has it out
  3. days overdue if it's late and hasn't been returned.
1 and 2 work fine but I don't know why 3 is giving a huge minus figure. Here is the calc block
Code:
$date1 = time();
$date2 = strtotime('{rad_rentals___due_date_out_raw}');
$date3 = strtotime('{rad_rentals___due_date_in_raw}');
$date4 = strtotime('{rad_rentals___actual_date_in_raw}');
if(($date1 > $date3) && ($date4==0)){
   return ceil(($date1 - $date3) / 86400);  //gives a huge minus figure
}elseif(($date1 > $date3) && ($date4!=0)){
   return ceil(($date4 - $date3) / 86400); //this is fine
} else {
 return 0 ; //this is fine
}

This is what the output looks like
upload_2021-8-17_15-0-29.png

For the first row of data. If today is August 17 2021 then days overdue should be 2 not -738415, because the due date in is August 16 2021. I am troubleshooting a 'php form plugin' code block on serial right now but that shouldn't affect this. It should say 2 for the first row of data. It's possible I have a timezone issue to get around when performing arithmetic between time() and strtotiime() but I'm not sure how to do that.
 
Last edited:
Sorry, but neither Fabrik (J! 2.5 / F 3.0 or whichever) nor its calc element -- but generic PHP and math.
So, with all respect, please understand if you won't find anyone here in the Fabrik support forums taking the time and effort to dig into such generic topic for a specific use case.
There are other forums on the Interwebs for this, and/or people for hire.
 
I understand. I'll leave it open for a bit longer, 2 weeks and then close. Meanwhile I'll troubleshoot and if I get the answer I'll post.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top