\Bitrix\Main\Loader::includeModule('crm');
$rs = Bitrix\Crm\Timeline\Entity\TimelineTable::getList(array(
'order' => array("ID" => "DESC"),
'filter' => array('=TYPE_ID' => 7),
'select'=>array("ID", "BINDINGS")
));
while($ar = $rs->Fetch())
{
echo '<pre>';
print_r($ar);
echo '</pre>';
}
Array
(
[ID] => 1537
[CRM_TIMELINE_ENTITY_TIMELINE_BINDINGS_OWNER_ID] => 1537
[CRM_TIMELINE_ENTITY_TIMELINE_BINDINGS_ENTITY_TYPE_ID] => 1
[CRM_TIMELINE_ENTITY_TIMELINE_BINDINGS_ENTITY_ID] => 134
[CRM_TIMELINE_ENTITY_TIMELINE_BINDINGS_IS_FIXED] =>
)
$rs = Bitrix\Crm\Timeline\Entity\TimelineTable::getList(array(
'order' => array("ID" => "DESC"),
'filter' => array('=TYPE_ID' => 7)
));
while($ar = $rs->Fetch())
{
echo '<pre>';
print_r($ar);
echo '</pre>';
}
Array
(
[ID] => 263472
[TYPE_ID] => 7
[TYPE_CATEGORY_ID] => 0
[CREATED] => Bitrix\Main\Type\DateTime Object
(
[value:protected] => DateTime Object
(
[date] => 2019-03-18 15:26:16.000000
[timezone_type] => 3
[timezone] => Europe/Moscow
)
)
[AUTHOR_ID] => 14
[ASSOCIATED_ENTITY_ID] => 0
[ASSOCIATED_ENTITY_TYPE_ID] => 0
[COMMENT] => повторное обращение
[SETTINGS] => Array
(
[HAS_FILES] => N
)
)
$arr = [
[
'ID' => '105653877',
'CABLAB_NAME' => 'Участок',
'DEPARTMENT_NAME' => 'Отдел',
'DEPARTMENT_KIND' => '6405222',
'EMPLOYER_ID' => '78621962',
'EMPLOYER_NAME' => 'Иванов И. И.',
'SERVICE_ID' => '',
'SERVICE_NAME' => '',
'DEVICE_NAME' => '',
'DAY_NUMBER' => '1',
'HOURS_BEGIN' => '08',
'MINS_BEGIN' => '00',
'HOURS_END' => '14',
'MINS_END' => '00',
'TIME_BEGIN_S' => '08:00',
'TIME_END_S' => '14:00',
'TIME_TYPE' => '6338504',
'TIME_TYPE_CODE' => '1',
'RCOUNT' => '1',
'RCOUNTMAX' => '',
'TIME_OR_COUNT' => '0',
'RTIME_PRIM' => '15',
'SORT_F' => '2',
'ONLY_VIEW' => '0',
],
[
'ID' => '105653877',
'CABLAB_NAME' => 'Участок',
'DEPARTMENT_NAME' => 'Отдел',
'DEPARTMENT_KIND' => '6405222',
'EMPLOYER_ID' => '78621962',
'EMPLOYER_NAME' => 'Иванов И. И.',
'SERVICE_ID' => '',
'SERVICE_NAME' => '',
'DEVICE_NAME' => '',
'DAY_NUMBER' => '3',
'HOURS_BEGIN' => '08',
'MINS_BEGIN' => '00',
'HOURS_END' => '14',
'MINS_END' => '00',
'TIME_BEGIN_S' => '08:00',
'TIME_END_S' => '14:00',
'TIME_TYPE' => '6338504',
'TIME_TYPE_CODE' => '1',
'RCOUNT' => '1',
'RCOUNTMAX' => '',
'TIME_OR_COUNT' => '0',
'RTIME_PRIM' => '15',
'SORT_F' => '2',
'ONLY_VIEW' => '0',
],
[
'ID' => '105653877',
'CABLAB_NAME' => 'Участок',
'DEPARTMENT_NAME' => 'Отдел',
'DEPARTMENT_KIND' => '6405222',
'EMPLOYER_ID' => '78621962',
'EMPLOYER_NAME' => 'Иванов И. И.',
'SERVICE_ID' => '',
'SERVICE_NAME' => '',
'DEVICE_NAME' => '',
'DAY_NUMBER' => '5',
'HOURS_BEGIN' => '08',
'MINS_BEGIN' => '00',
'HOURS_END' => '14',
'MINS_END' => '00',
'TIME_BEGIN_S' => '08:00',
'TIME_END_S' => '14:00',
'TIME_TYPE' => '6338504',
'TIME_TYPE_CODE' => '1',
'RCOUNT' => '1',
'RCOUNTMAX' => '',
'TIME_OR_COUNT' => '0',
'RTIME_PRIM' => '15',
'SORT_F' => '2',
'ONLY_VIEW' => '0',
]
];
$new_arr = [];
foreach ($arr as $index => $item) {
$id = $item['ID'];
$new_arr[$id] = $new_arr[$id] ?? $item;
$day = $item['DAY_NUMBER'];
$days = explode(', ', $new_arr[$id]['DAY_NUMBER']);
if (!in_array($day, $days))
$days[] = $day;
sort($days);
$new_arr[$id]['DAY_NUMBER'] = implode(', ', $days);
}