Incorrect parsing of time and date in nested form

eddydeniro
Posts: 174
Joined: 23 Feb 2021, 16:31
Name: Edi Supriyadi
Location: BDG Indonesia

Incorrect parsing of time and date in nested form

Post by eddydeniro »

Hi Sergey,

I still get incorrect value from time or date field in nested form.

Steps to reproduce:
1. Make entity and subentity, create time and date fields in subentity
2. Put subentity in nested form with field display "In a new window"
3. Create one record in main entity and two records or more in subentity
4. In the first save, they will be parsed correctly. Try to edit one record of subentity, and any other records will break.

When I captured the values of $app_subentity_form_items in class subentity_form, here's what I got :

Code: Select all

Array
(
//24: fieldtype_nested_form
    [24] => Array
        (
            [1] => Array
                (
                    [25] => 2021-11-26 //25: fieldtype_input_date
                    [26] => 13:45 //26: fieldtype_time
                )

            [2] => Array
                (
                    [25] => 1637859600
                    [26] => 743
                )

      )
I edited only first row and they have different format. When the function process parsed them, the second will break.

Code: Select all

//fieldtype_input_date->process()
//$value = (int)get_date_timestamp($options['value']);
$value = (int)get_date_timestamp(1637859600); //saved as 209093675820 in table and displayed back as "8595-11-30"

//fieldtype_time->process()
$value = explode(':',743);
$hours = (int)$value[0]; //743
$minutes = (int)$value[1]; 
return ($hours*60)+$minutes; //saved as 44580 in table and displayed back as "743:00"
Here's what I do as temporary workaround:

Code: Select all

//fieldtype_input_date->process()
//checking before conversion
$value = !is_numeric($options['value']) ? (int)get_date_timestamp($options['value']) : (int)$options['value'];

//fieldtype_time->process()
//prevent double parsing

$value = explode(':',$value);
if(count($value)>1)
{
	$hours = (int)$value[0];
	$minutes = (int)$value[1];
			
	return ($hours*60)+$minutes;  
} 

User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Incorrect parsing of time and date in nested form

Post by support »

Can't reproduce this issue on 3.0. Did test on 3.0?
eddydeniro
Posts: 174
Joined: 23 Feb 2021, 16:31
Name: Edi Supriyadi
Location: BDG Indonesia

Re: Incorrect parsing of time and date in nested form

Post by eddydeniro »

Yes, I'm using V3, fresh install.
Here's the screenshot:
RukovoditelErrorTimeDateV3Beta1.png
Note: I changed Est. Time field into Time type.
support wrote: 26 Nov 2021, 09:17 Can't reproduce this issue on 3.0. Did test on 3.0?
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Incorrect parsing of time and date in nested form

Post by support »

Can you send me database, please. I will check with your configuration.
eddydeniro
Posts: 174
Joined: 23 Feb 2021, 16:31
Name: Edi Supriyadi
Location: BDG Indonesia

Re: Incorrect parsing of time and date in nested form

Post by eddydeniro »

Ok, I've sent it via PM.
Thanks
support wrote: 26 Nov 2021, 12:11 Can you send me database, please. I will check with your configuration.
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Incorrect parsing of time and date in nested form

Post by support »

It's strange, but I still can't reproduce this issue. I have added project and tasks, edit task and everything looks ok for me.
Can you try setup personal demo, it's 3.0 at the moment and might we can reproduce issue in it
https://www.rukovoditel.net/demo.php
eddydeniro
Posts: 174
Joined: 23 Feb 2021, 16:31
Name: Edi Supriyadi
Location: BDG Indonesia

Re: Incorrect parsing of time and date in nested form

Post by eddydeniro »

Here's the result of my personal demo.
The result is as same as in my localhost.
RukovoditelErrorTimeDateV3Beta1-atPersonalDemo.png
Created 1 project with two tasks, saved. Everything ok.
Then I edited the Task 1, saved.
Then when I open again the project form, that's what I got.
Before it breaks, the Task 2 was 14:00 (Est. Time), 11/29/2021 (Start Date), and 11/30/2021 (End Date).
support wrote: 26 Nov 2021, 16:42 It's strange, but I still can't reproduce this issue. I have added project and tasks, edit task and everything looks ok for me.
Can you try setup personal demo, it's 3.0 at the moment and might we can reproduce issue in it
https://www.rukovoditel.net/demo.php
eddydeniro
Posts: 174
Joined: 23 Feb 2021, 16:31
Name: Edi Supriyadi
Location: BDG Indonesia

Re: Incorrect parsing of time and date in nested form

Post by eddydeniro »

Now if you edit the Task 2 only via sub form, I'm pretty sure the Task 1 will break.
eddydeniro wrote: 26 Nov 2021, 17:09 Here's the result of my personal demo.
The result is as same as in my localhost.
RukovoditelErrorTimeDateV3Beta1-atPersonalDemo.png
Created 1 project with two tasks, saved. Everything ok.
Then I edited the Task 1, saved.
Then when I open again the project form, that's what I got.
Before it breaks, the Task 2 was 14:00 (Est. Time), 11/29/2021 (Start Date), and 11/30/2021 (End Date).
support wrote: 26 Nov 2021, 16:42 It's strange, but I still can't reproduce this issue. I have added project and tasks, edit task and everything looks ok for me.
Can you try setup personal demo, it's 3.0 at the moment and might we can reproduce issue in it
https://www.rukovoditel.net/demo.php
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Incorrect parsing of time and date in nested form

Post by support »

Finally I have found this issue. I have added fix for v3 (this is similar code that you did)
Files from archive replace in includes\classes\fieldstypes\
Attachments
fieldstypes_date_fix.zip
(7.36 KiB) Downloaded 66 times
eddydeniro
Posts: 174
Joined: 23 Feb 2021, 16:31
Name: Edi Supriyadi
Location: BDG Indonesia

Re: Incorrect parsing of time and date in nested form

Post by eddydeniro »

Perfect!
Now everything works.
Thanks Sergey
Post Reply