CBPTaskService :: GetList: Bitrix method

      
<?php 
//  CBPTaskService :: GetList()
//  /dist/bitrix/modules/bizproc/classes/mysql/taskservice.php:138

    
public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy false$arNavStartParams false$arSelectFields = array())
    {
        global 
$DB;

        if (
count($arSelectFields) <= 0)
            
$arSelectFields = array("ID""WORKFLOW_ID""ACTIVITY""ACTIVITY_NAME""MODIFIED""OVERDUE_DATE""NAME""DESCRIPTION""PARAMETERS");

        static 
$arFields = array(
            
"ID" => Array("FIELD" => "T.ID""TYPE" => "int"),
            
"WORKFLOW_ID" => Array("FIELD" => "T.WORKFLOW_ID""TYPE" => "string"),
            
"ACTIVITY" => Array("FIELD" => "T.ACTIVITY""TYPE" => "string"),
            
"ACTIVITY_NAME" => Array("FIELD" => "T.ACTIVITY_NAME""TYPE" => "string"),
            
"MODIFIED" => Array("FIELD" => "T.MODIFIED""TYPE" => "datetime"),
            
"OVERDUE_DATE" => Array("FIELD" => "T.OVERDUE_DATE""TYPE" => "datetime"),
            
"NAME" => Array("FIELD" => "T.NAME""TYPE" => "string"),
            
"DESCRIPTION" => Array("FIELD" => "T.DESCRIPTION""TYPE" => "string"),
            
"PARAMETERS" => Array("FIELD" => "T.PARAMETERS""TYPE" => "string"),
            
"IS_INLINE" => Array("FIELD" => "T.IS_INLINE""TYPE" => "string"),
            
"DELEGATION_TYPE" => Array("FIELD" => "T.DELEGATION_TYPE""TYPE" => "int"),
            
"STATUS" => Array("FIELD" => "T.STATUS""TYPE" => "int"),
            
'DOCUMENT_NAME' => Array("FIELD" => "T.DOCUMENT_NAME""TYPE" => "string"),
            
"USER_ID" => Array("FIELD" => "TU.USER_ID""TYPE" => "int""FROM" => "INNER JOIN b_bp_task_user TU ON (T.ID = TU.TASK_ID)"),
            
"USER_STATUS" => Array("FIELD" => "TU.STATUS""TYPE" => "int""FROM" => "INNER JOIN b_bp_task_user TU ON (T.ID = TU.TASK_ID)"),
            
"WORKFLOW_TEMPLATE_ID" => Array("FIELD" => "WS.WORKFLOW_TEMPLATE_ID""TYPE" => "int""FROM" => "INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)"),
            
"MODULE_ID" => Array("FIELD" => "WS.MODULE_ID""TYPE" => "string""FROM" => "INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)"),
            
"ENTITY" => Array("FIELD" => "WS.ENTITY""TYPE" => "string""FROM" => "INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)"),
            
"DOCUMENT_ID" => Array("FIELD" => "WS.DOCUMENT_ID""TYPE" => "string""FROM" => "INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)"),
            
"WORKFLOW_TEMPLATE_NAME" => Array("FIELD" => "WT.NAME""TYPE" => "string",
                                            
"FROM" => array("INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)",
                                                
"INNER JOIN b_bp_workflow_template WT ON (WS.WORKFLOW_TEMPLATE_ID = WT.ID)")),
            
"WORKFLOW_TEMPLATE_TEMPLATE_ID" => Array("FIELD" => "WS.WORKFLOW_TEMPLATE_ID""TYPE" => "int",
                                                    
"FROM" => array("INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)")),
            
'WORKFLOW_STATE' => array("FIELD" => "WS.STATE_TITLE""TYPE" => "string""FROM" => "INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)"),
            
'WORKFLOW_STARTED' => array("FIELD" => "WS.STARTED""TYPE" => "datetime""FROM" => "INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)"),
            
'WORKFLOW_STARTED_BY' => array("FIELD" => "WS.STARTED_BY""TYPE" => "int""FROM" => "INNER JOIN b_bp_workflow_state WS ON (T.WORKFLOW_ID = WS.ID)"),
        );

        
$arSqls CBPHelper::PrepareSql($arFields$arOrder$arFilter$arGroupBy$arSelectFields);

        
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%"""$arSqls["SELECT"]);

        if (
is_array($arGroupBy) && count($arGroupBy)==0)
        {
            
$strSql =
                
"SELECT ".$arSqls["SELECT"]." ".
                
"FROM b_bp_task T ".
                
"    ".$arSqls["FROM"]." ";
            if (
strlen($arSqls["WHERE"]) > 0)
                
$strSql .= "WHERE ".$arSqls["WHERE"]." ";
            if (
strlen($arSqls["GROUPBY"]) > 0)
                
$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";

            
$dbRes $DB->Query($strSqlfalse"File: ".__FILE__."<br>Line: ".__LINE__);
            if (
$arRes $dbRes->Fetch())
                return 
$arRes["CNT"];
            else
                return 
False;
        }

        
$strSql =
            
"SELECT ".$arSqls["SELECT"]." ".
            
"FROM b_bp_task T ".
            
"    ".$arSqls["FROM"]." ";
        if (
strlen($arSqls["WHERE"]) > 0)
            
$strSql .= "WHERE ".$arSqls["WHERE"]." ";
        if (
strlen($arSqls["GROUPBY"]) > 0)
            
$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
        if (
strlen($arSqls["ORDERBY"]) > 0)
            
$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";

        if (
is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0)
        {
            
$strSql_tmp =
                
"SELECT COUNT('x') as CNT ".
                
"FROM b_bp_task T ".
                
"    ".$arSqls["FROM"]." ";
            if (
strlen($arSqls["WHERE"]) > 0)
                
$strSql_tmp .= "WHERE ".$arSqls["WHERE"]." ";
            if (
strlen($arSqls["GROUPBY"]) > 0)
                
$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";

            
$dbRes $DB->Query($strSql_tmpfalse"File: ".__FILE__."<br>Line: ".__LINE__);
            
$cnt 0;
            if (
strlen($arSqls["GROUPBY"]) <= 0)
            {
                if (
$arRes $dbRes->Fetch())
                    
$cnt $arRes["CNT"];
            }
            else
            {
                
$cnt $dbRes->SelectedRowsCount();
            }

            
$dbRes = new CDBResult();
            
$dbRes->NavQuery($strSql$cnt$arNavStartParams);
        }
        else
        {
            if (
is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0)
                
$strSql .= "LIMIT ".intval($arNavStartParams["nTopCount"]);
            
$dbRes $DB->Query($strSqlfalse"File: ".__FILE__."<br>Line: ".__LINE__);
        }

        
$dbRes = new CBPTaskResult($dbRes);
        return 
$dbRes;
    }