129 $type = DateType::NONE,
136 $allowYearsSwithcer =
false,
140 if (!is_bool($enableTime))
145 if (!is_array($exclude))
150 $selectParams = array(
"isMulti" =>
false);
165 $sourceMonths = range(1, 12);
167 $currentMonthNumber = $date->format(
"n");
169 $currentMonthType = array();
171 foreach($sourceMonths as $key => $month)
176 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_MONTH_".$month)
179 if ($currentMonthNumber == $month)
181 $currentMonthType = array(
183 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_MONTH_".$month)
189 $sourceQuarters = range(1, 4);
191 $quarterNumber = Quarter::getCurrent();
192 $currentQuarterType = array();
194 foreach($sourceQuarters as $key => $quarter)
196 $quarter = (
string)$quarter;
200 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_QUARTER_".$quarter)
203 if ($quarterNumber == $quarter)
205 $currentQuarterType = array(
207 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_QUARTER_".$quarter)
212 $sourceSubtypes = DateType::getList();
214 $subtypeType = array();
216 foreach ($sourceSubtypes as $key => $subtype)
218 if (!in_array($subtype, $exclude))
221 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_SUBTYPE_".$subtype),
225 if ($subtype == $type)
227 $subtypeType = array(
228 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_SUBTYPE_".$subtype),
235 if (is_array($include))
237 foreach ($include as $key => $item)
239 if ($item === AdditionalDateType::CUSTOM_DATE)
242 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_SUBTYPE_".$item),
243 "VALUE" => AdditionalDateType::CUSTOM_DATE,
244 "DECL" => static::customDate(array(
"id" =>
$name,
"name" => $label))
248 if ($item === AdditionalDateType::NEXT_DAY ||
249 $item === AdditionalDateType::PREV_DAY ||
250 $item === AdditionalDateType::MORE_THAN_DAYS_AGO ||
251 $item === AdditionalDateType::AFTER_DAYS)
254 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER_FIELD_SUBTYPE_".$item),
261 $currentYear = (int) $date->format(
"Y");
262 $sourceYears = range($currentYear+5, $currentYear-20);
264 $currentYearType = array();
266 foreach ($sourceYears as $key => $year)
275 if ($year == $currentYear)
277 $currentYearType = array(
284 $yearsSwitcher = static::select(
288 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_YEARS_SWITCHER_YES"),
292 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_YEARS_SWITCHER_NO"),
300 "ID" =>
"field_".
$name,
301 "TYPE" => Type::DATE,
303 "SUB_TYPE" => $subtypeType,
304 "SUB_TYPES" => $subtypes,
305 "MONTH" => $currentMonthType,
307 "QUARTER" => $currentQuarterType,
308 "QUARTERS" => $quarters,
309 "YEAR" => $currentYearType,
312 "PLACEHOLDER" => $placeholder,
314 "ENABLE_TIME" => $enableTime,
315 "SELECT_PARAMS" => $selectParams,
316 "YEARS_SWITCHER" => $allowYearsSwithcer ? $yearsSwitcher : null
334 $type = NumberType::SINGLE,
343 $selectParams = array(
"isMulti" =>
false);
354 $sourceSubtypes = NumberType::getList();
356 foreach ($sourceSubtypes as $key => $subtype)
358 if (!is_array($exclude) || !in_array($subtype, $exclude))
361 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER__NUMBER_".$key),
365 if ($subtype == $type)
368 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER__NUMBER_".$key),
375 if (is_array($include))
377 $additionalSubtypes = AdditionalNumberType::getList();
378 foreach ($additionalSubtypes as $key => $subtype)
380 if (in_array($subtype, $include))
383 "NAME" => static::getMessage($messages,
"MAIN_UI_FILTER__NUMBER_".$key),
391 "ID" =>
"field_".$name,
392 "TYPE" => Type::NUMBER,
394 "SUB_TYPE" => $subtypeType,
395 "SUB_TYPES" => $subtypes,
398 "PLACEHOLDER" => $placeholder,
399 "SELECT_PARAMS" => $selectParams
464 $defaultValues = array(
470 $days = static::getDaysList();
471 $daysDate =
new Date();
472 $today = (int) $daysDate->format(
"d");
473 $yesterday = (int) $daysDate->add(
"-1 days")->format(
"d");
474 $tomorrow = (int) $daysDate->add(
"2 days")->format(
"d");
475 $additionalDays = array(
477 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_TODAY"),
481 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_YESTERDAY"),
482 "VALUE" => $yesterday
485 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_TOMORROW"),
492 $days = array_merge($additionalDays, $days);
494 $months = static::getMonthsList();
495 $monthsDate =
new Date();
496 $currentMonth = (int) $monthsDate->format(
"n");
497 $lastMonth = (int) $monthsDate->add(
"-1 month")->format(
"n");
498 $nextMonth = (int) $monthsDate->add(
"2 month")->format(
"n");
499 $additionalMonths = array(
501 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_CURRENT_MONTH"),
502 "VALUE" => $currentMonth
505 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_LAST_MONTH"),
506 "VALUE" => $lastMonth
509 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_NEXT_MONTH"),
510 "VALUE" => $nextMonth
516 $months = array_merge($additionalMonths, $months);
518 $years = static::getYearsList();
519 $yearsDate =
new Date();
520 $currentYear = (int) $yearsDate->format(
"Y");
521 $lastYear = (int) $yearsDate->add(
"-1 year")->format(
"Y");
522 $nextYear = (int) $yearsDate->add(
"2 year")->format(
"Y");
523 $additionalYears = array(
525 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_CURRENT_YEAR"),
526 "VALUE" => $currentYear
529 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_LAST_YEAR"),
533 "NAME" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_SUBTYPE_CUSTOM_DATE_NEXT_YEAR"),
540 $years = array_merge($additionalYears, $years);
543 "ID" =>
"field_".$options[
"id"],
544 "TYPE" => Type::CUSTOM_DATE,
545 "NAME" => $options[
"id"],
546 "VALUE" => $defaultValues,
547 "LABEL" => $options[
"name"],
552 "MONTHS_PLACEHOLDER" =>
Loc::getMessage(
"MAIN_UI_FILTER_FIELD_MONTHS"),
631 public static function destSelector(
$name, $label =
"", $placeholder =
"", $multiple =
false, $params = array(), $lightweight =
false, $filterName =
'')
633 \CJSCore::init(array(
'socnetlogdest'));
638 "ID" =>
"field_".
$name.($filterName <>
'' ?
'_'.$filterName :
''),
639 "TYPE" => Type::DEST_SELECTOR,
646 "MULTIPLE" => $multiple,
647 "PLACEHOLDER" => $placeholder
653 $optionsList = array(
654 'multiple' => ($multiple ?
'Y' :
'N'),
655 'eventInit' =>
'BX.Filter.DestinationSelector:openInit',
656 'eventOpen' =>
'BX.Filter.DestinationSelector:open',
657 'context' => ($params[
'context'] ??
'FILTER_'.
$name),
658 'popupAutoHide' =>
'N',
660 'userNameTemplate' => \CUtil::jSEscape(\CSite::getNameFormat()),
661 'useClientDatabase' => (isset($params[
'useClientDatabase']) && $params[
'useClientDatabase'] ==
'N' ?
'N' :
'Y'),
663 'enableUsers' => (!isset($params[
'enableUsers']) || $params[
'enableUsers'] !=
'N' ?
'Y' :
'N'),
664 'enableDepartments' => (!isset($params[
'enableDepartments']) || $params[
'enableDepartments'] !=
'N' ?
'Y' :
'N'),
665 'allowAddUser' =>
'N',
666 'allowAddCrmContact' =>
'N',
667 'allowAddSocNetGroup' =>
'N',
668 'allowSearchCrmEmailUsers' =>
'N',
669 'allowSearchNetworkUsers' =>
'N',
670 'useNewCallback' =>
'Y',
671 'focusInputOnSelectItem' =>
'N',
672 'focusInputOnSwitchTab' =>
'N',
673 'landing' => (isset($params[
'landing']) && $params[
'landing'] ==
'Y' ?
'Y' :
'N'),
676 if (!empty($params[
'contextCode']))
678 $optionsList[
'contextCode'] = $params[
'contextCode'];
679 unset($params[
'contextCode']);
682 if (isset($params[
'context']))
684 unset($params[
'context']);
686 if (isset($params[
'enableUsers']))
688 unset($params[
'enableUsers']);
690 if (isset($params[
'enableDepartments']))
692 unset($params[
'enableDepartments']);
695 $optionsList = array_merge($optionsList, $params);
697 $APPLICATION->includeComponent(
698 "bitrix:main.ui.selector",
701 'API_VERSION' => (!empty($params[
'apiVersion']) && intval($params[
'apiVersion']) >= 2 ? intval($params[
'apiVersion']) : 2),
703 'ITEMS_SELECTED' => array(),
705 'select' =>
'BX.Filter.DestinationSelectorManager.onSelect.bind(null, \''.(isset($params[
'isNumeric']) && $params[
'isNumeric'] ==
'Y' ?
'Y' :
'N').
'\', \
''.($params[
'prefix'] ??
'').
'\')
',
707 'openDialog
' => 'BX.Filter.DestinationSelectorManager.onDialogOpen
',
708 'closeDialog
' => 'BX.Filter.DestinationSelectorManager.onDialogClose
',
710 'closeSearch
' => 'BX.Filter.DestinationSelectorManager.onDialogClose
',
712 'OPTIONS
' => $optionsList,
716 array("HIDE_ICONS" => "Y")
719 $field["HTML"] = ob_get_clean();