8namespace Bitrix\Sender\Connector\Filter;
10use Bitrix\Main\Application;
11use Bitrix\Main\Type\Date;
12use Bitrix\Main\UI\Filter\Options as FilterOptions;
13use Bitrix\Main\UI\Filter\AdditionalDateType;
14use Bitrix\Main\UserFieldTable;
30 $result = FilterOptions::fetchDateFieldValue(
31 $this->
getId() .
'_datesel',
35 $allowYearName = $this->getAllowYearName();
46 if (!$this->isCustomDate())
52 foreach([
'days',
'month',
'year'] as
$key)
54 $fieldKey = $this->
getId() .
'_' . $key;
75 $from = $this->isMoreThanDaysAgo() ? null : $this->
getFrom();
76 $to = $this->isAfterDays() ? null : $this->
getTo();
80 if ($this->isAllowYears())
82 $filter[
">=$filterKey"] = $from;
86 $filter[] = $this->getFilterYearLess(
'FROM', $from,
">=");
91 if ($this->isAllowYears())
97 $filter[] = $this->getFilterYearLess(
'TO', $to,
"<=", $from);
102 $fieldId = $this->
getId();
103 $filterKey = $this->
getId() .
'_EXPR_DAYS';
110 'name' => $filterKey,
111 'expression' =>
"EXTRACT(DAY from %s)",
112 'buildFrom' => [$fieldId],
118 $fieldId = $this->
getId();
119 $filterKey = $this->
getId() .
'_EXPR_MONTHS';
126 'name' => $filterKey,
127 'expression' =>
"EXTRACT(MONTH from %s)",
128 'buildFrom' => [$fieldId],
134 $fieldId = $this->
getId();
135 $filterKey = $this->
getId() .
'_EXPR_YEARS';
142 'name' => $filterKey,
143 'expression' =>
"EXTRACT(YEAR from %s)",
144 'buildFrom' => [$fieldId],
179 return $this->getCustomDateData(
'days');
189 return $this->getCustomDateData(
'month');
199 return $this->getCustomDateData(
'year');
202 private function getCustomDateData(
$key)
204 $value = $this->getDateDataByKey(
$key);
205 if (!$value || !is_array($value))
219 private function isMoreThanDaysAgo()
224 private function isAfterDays()
229 private function getDateDataByKey(
$key)
233 if (!is_array($value) ||
count($value) === 0)
238 if (empty($value[
$key]))
246 private function getDate(
$defaultValue =
null, $isFrom =
true)
250 if (!is_array($value) ||
count($value) === 0)
256 FilterOptions::calcDates(
$name, $value, $calcData);
268 private function isCustomDate()
273 private function isAllowYears()
275 if (!isset($this->data[
'allow_years_switcher']) || !$this->data[
'allow_years_switcher'])
280 return !empty($this->data[
'value'][$this->getAllowYearName()]);
283 private function getAllowYearName()
285 return $this->
getId() .
'_allow_year';
288 private function getFilterYearLess($tag, $value, $operation =
"=", $fromValue =
null)
291 $date =
new Date($value);
294 $dateFrom =
new Date($fromValue);
295 if ($dateFrom->getTimestamp() > $date->getTimestamp())
301 $fieldId = $this->
getId();
302 $expressionFieldName = $fieldId .
"_YEAR_LESS_" . $tag;
306 $uf = explode(
'.', $filterKey);
307 foreach ($uf as $item)
309 if (mb_strpos($item,
'UF_') !== 0)
314 $userField = UserFieldTable::getRow([
315 'select' => [
'USER_TYPE_ID',
'MULTIPLE'],
316 'filter' => [
'=FIELD_NAME' => $item]
318 if (!$userField || $userField[
'USER_TYPE_ID'] !=
'date')
322 if ($userField[
'MULTIPLE'] !=
'Y')
327 $filterKey .=
'_SINGLE';
331 $sqlHelper = Application::getConnection()->getSqlHelper();
333 $charDate = $sqlHelper->getConcatFunction(
334 "(EXTRACT(YEAR from %s) $addOneYear)",
335 "'-{$date->format('m')}-{$date->format('d')}'"
337 $sqlDate = $sqlHelper->getDatetimeToDateFunction($charDate);
339 return (
new RuntimeFilter())
341 "=$expressionFieldName",
345 'name' => $expressionFieldName,
346 'expression' =>
"case when %s $operation $sqlDate then 1 else 0 end",
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
getValue($defaultValue=null)
getFrom($defaultValue=null)
getTo($defaultValue=null)
fetchFieldValue($filterFields)
applyFilter(array &$filter=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"