Bitrix24: Blogs
  • 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:

    $arOrder = array_merge(array("RESPONSIBLE_ID" => "ASC";), $arOrder);
    For our surprise, after sorting, some tasks were placed in the wrong order: some tasks of one responsible person were mixed with tasks of another responsible person.

    We began to clear up this problem and found such code in the CTask::GetList method:
    foreach ($arOrder as $by => $order)
    {
     ……
     switch ($by)
    {
     ……
     case 'responsible_id':
     $arSqlOrder[] = " RESPONSIBLE_LAST_NAME ".$order." ";
     $needle = 'RESPONSIBLE_LAST_NAME';
       break;
     ……
     }
    ……
    }
    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.

    Customization of both component templates required us to significant changes in the Javascript code, we will not describe it in details, just show the final result (click images to view animation):

    418d1ff374688679f5fd06060354d871.gife7176647da393f6d126de0386a0ca1ac.gif
    Tags: customization, project management, tasks
2,000,000+
organizations
are already using Bitrix24