• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to do a Calculation using date

How to do a Calculation using date 10 years 2 months ago #30474

  • RPPEO
  • RPPEO's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 68
  • Thank you received: 6
Good morning.

I'm trying to create a form for inputting a hours worked during a one week pay period. I've been successful getting just about everything I need configured, however providing the date for each day of the week has been a challenge.

What I would like to do is use two calendar values to set the start and end of the pay period. This is done. Now I'd like the form to fill in the table values for the dates from Sunday-Saturday. This would be a {startofpayperiod:value} for Sunday, Monday would be +1, Tuesday +2, Wednesday +3, etc Saturday would be {endofpayperiod:value}.

So the question is can this be done? I would prefer to show the columns Day, Date and Hours in a table format on the form, however if it's not possible to dynamically fill in the date values, if I can add them to the final email or PDF that would be useful as well.

Thank you for any assistance.
Cheers.

Niall
The administrator has disabled public write access.

How to do a Calculation using date 10 years 2 months ago #30476

  • RPPEO
  • RPPEO's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 68
  • Thank you received: 6
I have been playing with the example JS posted to calculate the number of days between to dates, so far no luck. :(
The administrator has disabled public write access.

How to do a Calculation using date 10 years 2 months ago #30561

  • RPPEO
  • RPPEO's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 68
  • Thank you received: 6
This is what finally worked:
if(isset($_POST['form'])){
$_POST['form']['monday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 1 days'));
}
if(isset($_POST['form'])){
$_POST['form']['tuesday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 2 days'));
}
if(isset($_POST['form'])){
$_POST['form']['wednesday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 3 days'));
}
if(isset($_POST['form'])){
$_POST['form']['thursday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 4 days'));
}
if(isset($_POST['form'])){
$_POST['form']['friday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 5 days'));
}
if(isset($_POST['form'])){
$_POST['form']['saturday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 6 days'));
}
The administrator has disabled public write access.

How to do a Calculation using date 10 years 1 month ago #30592

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
if (isset($_POST['form'])){}
is not needed in this case. Your code could be just this:

$_POST['form']['monday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 1 days'));
$_POST['form']['tuesday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 2 days'));
$_POST['form']['wednesday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 3 days'));
$_POST['form']['thursday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 4 days'));
$_POST['form']['friday_date'] = date('m/d/Y',strtotime($_POST['form']['week_start'].' + 5 days'));
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

How to do a Calculation using date 10 years 1 month ago #30593

  • RPPEO
  • RPPEO's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 68
  • Thank you received: 6
Interesting, the code I posted works fine on the dev site, but neither format works on the live site. The monday_date:value is not displayed on View Submissions just the place holder is seen for example: {monday_date:value}

Been working on this for 2 hours, saw the suggestion, still scratching my head.

Any thoughts?

Got to have those hidden fields to hold the values. :OOPS:
Last Edit: 10 years 1 month ago by RPPEO.
The administrator has disabled public write access.

How to do a Calculation using date 10 years 1 month ago #30609

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Make sure you are using the correct name for the form-fields, i would recommend using the back-up / restore functionality to migrate the form (instead of manually creating it).

Backup / Restore functionality is described here:
https://www.rsjoomla.com/support/documentation/view-article/1285-backup--restore.html
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!