Можно было скопировать модуль календаря и переписать его (что было бы по золотым правилам битрикса), но уж очень много мест правок, поэтому поправила ядро
Список правок:
1. правим компонент bitrix/components/bitrix/main.ui.filter/class.php
метод prepareFields стр. 1041
после строчки
$sourceFields = $this->arParams["FILTER"]; |
if($this->arParams["FILTER_ID"]=='calendar-filter-personal'){ $sourceFields["LOCATION"] = array( "id"=>"LOCATION", "name"=>"Место", "type"=>"list", "params"=> array( "multiple" => "N", ), "items" => array() ); $arLocations = CCalendarLocation::getList(); foreach ($arLocations as $key => $arLocation) { sourceFields["LOCATION"]["items"][$arLocation["ID"]]=$arLocation["NAME"]; } } |
метод getFilterData() стр. 488
после строчек
$fields = CalendarFilter::resolveFilterFields(CalendarFilter::getFilterId(CCalendar::GetType(), CCalendar::GetOwnerId(), CCalendar::GetCurUserId())); $parseRecursion = false; $counters = false; |
if (isset($fields['fields']['LOCATION'])){ $arFilter = array(); $arFilter['LOCATION'] = $fields['fields']['LOCATION']; } else{ $arFilter = array( 'OWNER_ID' => CCalendar::GetOwnerId(), 'CAL_TYPE' => CCalendar::GetType() ); } |
метод getAvailableFields() стр. 30
добавляем еще в массив LOCATION
$fields = array( 'CREATED_BY', 'ATTENDEES', 'IS_MEETING', 'IS_RECURSIVE', 'MEETING_STATUS', 'DATE_FROM', 'DATE_TO', 'LOCATION' //кастомизация ); |
метод GetList() стр. 659
после строчек
elseif($n == 'TO_LIMIT') { $ts = CCalendar::Timestamp($val, false); if ($ts > 0) $arSqlSearch[] = "CE.DATE_FROM_TS_UTC<=".($ts + 86399); } |
Место в таблице хранится и как "название" и как "calendar_idLocat_somevalue" |
elseif($n == 'LOCATION'){ $arLocations = CCalendarLocation::getList(); foreach ($arLocations as $arLocation) { if($arLocation["ID"]==$val){ $arSqlSearch[] = '((CE.LOCATION IN (\''.$arLocation["NAME"].'\')) OR (CE.LOCATION LIKE \'calendar_'.$val.'_%\'))'; break; } } } |
пока оставлю тут:
задача менять по месту проведения календарь
/bitrix/js/main/core/core.js
говнокод, переделать надо
function onCustomEvent
if(eventName == "onSelectInputChanged"){ if((eventName == "onSelectInputChanged")&&(typeof eventObject.input.className != 'undefined') && (eventObject.input.className == "calendar-field calendar-field-select")){ if(eventParams[1]=="Переговорная"){ let inputSection = document.querySelector('form[name="calendar_entry_edit"] input[name="section"]'); if(inputSection.value != 307){ inputSection.value = 307; let section = document.querySelector('form[name="calendar_entry_edit"] [data-bx-block-placeholer="section"] .calendar-field-select span'); section.innerHTML = 'Переговорная'; section.setAttribute("title",'Переговорная'); let sectionIcon = document.querySelector('form[name="calendar_entry_edit"] [data-bx-block-placeholer="section"] .calendar-field-select .calendar-field-select-icon'); sectionIcon.style.backgroundColor = "#0092cc"; } } } } |
value: function emit(eventName, event) { EventEmitter.emit(this, eventName, event); if((eventName == "onChange") && (event instanceof BaseEvent) && (event.type == "bx.calendar.compacteventform:onchange")){ let locationId = event.target.locationSelector.getTextValue(); if((locationId == "calendar_231")&&(event.target.sectionValue != 307)){ let sectList = event.target.sectionSelector.sectionList; let section; for (var i = sectList.length - 1; i >= 0; i--) { section = sectList[i]; if(section.data.ID == 307){ event.target.sectionSelector.selectCallback(section); event.target.sectionSelector.updateValue(); event.target.userPlannerSelector.refreshPlanner(); break; } } } if((event.target.sectionValue == 307)&&(locationId != "calendar_231")){ let locationList = event.target.locationList; let location; for (var i = locationList.length - 1; i >= 0; i--) { event.target.locationSelector.setValue("calendar_231"); // event.target.locationSelector.updateValue(); event.target.userPlannerSelector.refreshPlanner(); } } } return this; } |