Bitrix24 customization example - tasks list grouping by responsible person
Dmitry Davydov 4 April 2017
The following is a guest post by Julia Bedrosova, one of the leading Bitrix24 consulting and customization providers at Upwork.
One of our customers asked us to add a tasks list grouping by responsible person feature in Bitrix24. It is also required to be able to change a responsible person by simple dragging tasks to the appropriate group. This customer has self-hosted Bitrix24, so we were able to add a required functionality.
Tasks list in Bitrix24 may be sorted and filtered by responsible person, but the customer was not satisfied with these both options, he would like to have an ability to group tasks list by responsible person as additional grouping level.
First, we copy the component (tasks.list) in our own namespace. At the component code (component.php file) we find a place, where an array with sorting condition are formed. It is $arOrders array. We change the $arOrders array to make sort by responsible person ID in first priority:
So, instead sorting by responsible person ID (this column are in the «b_tasks» table and available for sorting) Bitrix sorted our data by responsible person’s last name.
The system does not take into account the fact that the last name may be not specified. We have just such a case. All the responsible persons, whose tasks was "mixed", have not specified last names.
After we sorted the tasks in the required order, we also need some additional data about the responsible persons. In the code, that generates an array with tasks data, we find responsible person`s ID and make a request to select person's name, last name and login (we need to know login if the last name is not specified).
Next, we add request results to the $arResult array. Then we can work with component's templates.
Bitrix24 standard task list component has two views: list view and Gantt chart. It was necessary to change both. Both views already contained a grouping by projects. In accordance with the client's requirement, we add one more level of grouping - grouping by ID of the responsible person.