CBPAllTaskService::MarkCompleted: Bitrix method

      
<?php 
//  CBPAllTaskService :: MarkCompleted()
//  /dist/bitrix/modules/bizproc/classes/general/taskservice.php:21

    
public function MarkCompleted($taskId$userId$status CBPTaskUserStatus::Ok)
    {
        global 
$DB;

        
$taskId = (int)$taskId;
        if (
$taskId <= 0)
            throw new 
Exception("id");
        
$userId = (int)$userId;
        if (
$userId <= 0)
            throw new 
Exception("userId");
        
$status = (int)$status;

        
$DB->Query("UPDATE b_bp_task_user SET STATUS = ".$status.", DATE_UPDATE = ".$DB->CurrentTimeFunction()." WHERE TASK_ID = ".$taskId." AND USER_ID = ".$userIdtrue);

        
CUserCounter::Decrement($userId'bp_tasks''**');

        
self::onTaskChange(
            
$taskId,
            [
                
'USERS_STATUSES' => [$userId => $status],
                
'COUNTERS_DECREMENTED' => [$userId]
            ],
            
CBPTaskChangedStatus::Update
        
);
        foreach (
GetModuleEvents("bizproc""OnTaskMarkCompleted"true) as $arEvent)
        {
            
ExecuteModuleEventEx($arEvent, array($taskId$userId$status));
        }
    }