Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MixedDateTimeTypesSearchFormAttributeMappingRules.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
48  public static function resolveAttributesAndRelations($attributeName, & $attributeAndRelations, $value)
49  {
50  assert('is_string($attributeName)');
51  assert('$attributeAndRelations == "resolveEntireMappingByRules"');
52  assert('empty($value) || $value == null || is_array($value)');
53  $delimiter = FormModelUtil::DELIMITER;
54  $parts = explode($delimiter, $attributeName);
55  if (count($parts) != 2)
56  {
57  throw new NotSupportedException();
58  }
59  list($realAttributeName, $type) = $parts;
60  if (isset($value['type']) && $value['type'] != null)
61  {
62  if ($value['type'] == self::TYPE_YESTERDAY ||
63  $value['type'] == self::TYPE_TODAY ||
64  $value['type'] == self::TYPE_TOMORROW ||
65  $value['type'] == self::TYPE_ON)
66  {
67  $dateValue = static::resolveValueDataIntoUsableValue($value);
70  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
71  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
72  }
73  elseif ($value['type'] == self::TYPE_AFTER)
74  {
75  $dateValue = static::resolveValueDataIntoUsableValue($value);
77  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue));
78  }
79  elseif ($value['type'] == self::TYPE_BEFORE)
80  {
81  $dateValue = static::resolveValueDataIntoUsableValue($value);
83  $attributeAndRelations = array(array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue));
84  }
85  elseif ($value['type'] == self::TYPE_BETWEEN)
86  {
87  $firstDateValue = static::resolveValueDataForBetweenIntoUsableFirstDateValue($value);
88  $secondDateValue = static::resolveValueDataForBetweenIntoUsableSecondDateValue($value);
89  if ($firstDateValue == null)
90  {
91  $greaterThanValue = null;
92  }
93  else
94  {
96  }
97  if ($secondDateValue == null)
98  {
99  $lessThanValue = null;
100  }
101  else
102  {
103  $lessThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($secondDateValue);
104  }
105  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
106  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
107  }
108  elseif ($value['type'] == self::TYPE_NEXT_7_DAYS)
109  {
110  $today = static::calculateNewDateByDaysFromNow(0);
111  $todayPlusSevenDays = static::calculateNewDateByDaysFromNow(7);
113  $lessThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($todayPlusSevenDays);
114  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
115  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
116  }
117  elseif ($value['type'] == self::TYPE_LAST_7_DAYS)
118  {
119  $today = static::calculateNewDateByDaysFromNow(0);
120  $todayMinusSevenDays = static::calculateNewDateByDaysFromNow(-7);
121  $greaterThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($todayMinusSevenDays);
123  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
124  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
125  }
126  elseif ($value['type'] == self::TYPE_LAST_30_DAYS)
127  {
128  $today = static::calculateNewDateByDaysFromNow(0);
129  $todayMinusThirtyDays = static::calculateNewDateByDaysFromNow(-30);
130  $greaterThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($todayMinusThirtyDays);
132  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
133  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
134  }
135  elseif ($value['type'] == self::TYPE_THIS_MONTH)
136  {
137  $firstDateValue = DateTimeUtil::getFirstDayOfAMonthDate();
138  $secondDateValue = DateTimeUtil::getLastDayOfAMonthDate();
139  $greaterThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($firstDateValue);
140  $lessThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($secondDateValue);
141  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
142  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
143  }
144  elseif ($value['type'] == self::TYPE_LAST_MONTH)
145  {
146  $firstDateValue = DateTimeUtil::getFirstDayOfLastMonthDate();
147  $secondDateValue = DateTimeUtil::getLastDayOfLastMonthDate();
148  $greaterThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($firstDateValue);
149  $lessThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($secondDateValue);
150  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
151  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
152  }
153  elseif ($value['type'] == self::TYPE_NEXT_MONTH)
154  {
155  $firstDateValue = DateTimeUtil::getFirstDayOfNextMonthDate();
156  $secondDateValue = DateTimeUtil::getLastDayOfNextMonthDate();
157  $greaterThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($firstDateValue);
158  $lessThanValue = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($secondDateValue);
159  $attributeAndRelations = array(array($realAttributeName, null, 'greaterThanOrEqualTo', $greaterThanValue, true),
160  array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue, true));
161  }
162  elseif ($value['type'] == self::TYPE_BEFORE_TODAY)
163  {
164  $today = static::calculateNewDateByDaysFromNow(0);
166  $attributeAndRelations = array(array($realAttributeName, null, 'lessThanOrEqualTo', $lessThanValue));
167  }
168  else
169  {
170  throw new NotSupportedException();
171  }
172  }
173  else
174  {
175  $attributeAndRelations = array(array($realAttributeName, null, null, 'resolveValueByRules'));
176  }
177  }
178  }
179 ?>
static convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($dateValue)
static resolveAttributesAndRelations($attributeName, &$attributeAndRelations, $value)
static convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($dateValue)
Generated on Tue Jul 7 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.