From 97739b7c870577abaca8356447c6365be0b410d5 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 12 Apr 2022 16:55:14 -0400 Subject: [PATCH] Create gpcld-auto-rule-groups.php --- .../gpcld-auto-rule-groups.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 gp-conditional-logic-dates/gpcld-auto-rule-groups.php diff --git a/gp-conditional-logic-dates/gpcld-auto-rule-groups.php b/gp-conditional-logic-dates/gpcld-auto-rule-groups.php new file mode 100644 index 000000000..ba071802e --- /dev/null +++ b/gp-conditional-logic-dates/gpcld-auto-rule-groups.php @@ -0,0 +1,48 @@ +conditionalLogic ) || $field->conditionalLogic['logicType'] !== 'all' ) { + continue; + } + + $start_time_rule = null; + + foreach ( $field->conditionalLogic['rules'] as &$rule ) { + + if ( $start_time_rule ) { + $start_time = strtotime( $start_time_rule['value'] ); + $end_time = strtotime( $rule['value'] ); + if ( $rule['operator'] === '<' && $start_time > $end_time ) { + $rule['gpcldBaseDate'] = 1; + } + $start_time_rule = null; + } else if ( $rule['fieldId'] === '_gpcld_current_time' && $rule['operator'] === '>' ) { + $start_time_rule = $rule; + } + + } + + } + + return $form; +} );