Поддержка серверов

CSaleOrder::GetHistoryList: метод Битрикс

Постоянная ссылка: http://bxapi.ru/src/?id=179993

//    CSaleOrder::GetHistoryList()
//    /bitrix/modules/sale/general/order.php:2830

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

        if (array_key_exists("H_DATE_INSERT_FROM", $arFilter))
        {
            $val = $arFilter["H_DATE_INSERT_FROM"];
            unset($arFilter["H_DATE_INSERT_FROM"]);
            $arFilter[">=H_DATE_INSERT"] = $val;
        }
        if (array_key_exists("H_DATE_INSERT_TO", $arFilter))
        {
            $val = $arFilter["H_DATE_INSERT_TO"];
            unset($arFilter["H_DATE_INSERT_TO"]);
            $arFilter["<=H_DATE_INSERT"] = $val;
        }

        if (!$arSelectFields || count($arSelectFields) <= 0 || in_array("*", $arSelectFields))
        {
            $arSelectFields = array(
                "ID",
                "H_USER_ID",
                "H_DATE_INSERT",
                "H_ORDER_ID",
                "H_CURRENCY",
                "PERSON_TYPE_ID",
                "PAYED",
                "DATE_PAYED",
                "EMP_PAYED_ID",
                "CANCELED",
                "DATE_CANCELED",
                "REASON_CANCELED",
                "MARKED",
                "DATE_MARKED",
                "REASON_MARKED",
                "DEDUCTED",
                "DATE_DEDUCTED",
                "REASON_UNDO_DEDUCTED",
                "RESERVED",
                "STATUS_ID",
                "DATE_STATUS",
                "PRICE_DELIVERY",
                "ALLOW_DELIVERY",
                "DATE_ALLOW_DELIVERY",
                "PRICE",
                "CURRENCY",
                "DISCOUNT_VALUE",
                "USER_ID",
                "PAY_SYSTEM_ID",
                "DELIVERY_ID",
                "PS_STATUS",
                "PS_STATUS_CODE",
                "PS_STATUS_DESCRIPTION",
                "PS_STATUS_MESSAGE",
                "PS_SUM",
                "PS_CURRENCY",
                "PS_RESPONSE_DATE",
                "TAX_VALUE",
                "STAT_GID",
                "SUM_PAID",
                "PAY_VOUCHER_NUM",
                "PAY_VOUCHER_DATE",
                "AFFILIATE_ID",
                "DELIVERY_DOC_NUM",
                "DELIVERY_DOC_DATE"
            );
        }

        $arFields = array(
                "ID" => array("FIELD" => "V.ID", "TYPE" => "int"),
                "H_ORDER_ID" => array("FIELD" => "V.H_ORDER_ID", "TYPE" => "int"),
                "H_USER_ID" => array("FIELD" => "V.H_USER_ID", "TYPE" => "int"),
                "H_DATE_INSERT" => array("FIELD" => "V.H_DATE_INSERT", "TYPE" => "datetime"),
                "H_CURRENCY" => array("FIELD" => "V.H_CURRENCY", "TYPE" => "string"),
                "PERSON_TYPE_ID" => array("FIELD" => "V.PERSON_TYPE_ID", "TYPE" => "int"),
                "PAYED" => array("FIELD" => "V.PAYED", "TYPE" => "char"),
                "DATE_PAYED" => array("FIELD" => "V.DATE_PAYED", "TYPE" => "datetime"),
                "EMP_PAYED_ID" => array("FIELD" => "V.EMP_PAYED_ID", "TYPE" => "int"),
                "CANCELED" => array("FIELD" => "V.CANCELED", "TYPE" => "char"),
                "DATE_CANCELED" => array("FIELD" => "V.DATE_CANCELED", "TYPE" => "datetime"),
                "REASON_CANCELED" => array("FIELD" => "V.REASON_CANCELED", "TYPE" => "string"),
                "MARKED" => array("FIELD" => "V.MARKED", "TYPE" => "char"),
                "DATE_MARKED" => array("FIELD" => "V.DATE_MARKED", "TYPE" => "datetime"),
                "REASON_MARKED" => array("FIELD" => "V.REASON_MARKED", "TYPE" => "string"),
                "DEDUCTED" => array("FIELD" => "V.DEDUCTED", "TYPE" => "char"),
                "DATE_DEDUCTED" => array("FIELD" => "V.DATE_DEDUCTED", "TYPE" => "datetime"),
                "REASON_DEDUCTED" => array("FIELD" => "V.REASON_UNDO_DEDUCTED", "TYPE" => "string"),
                "RESERVED" => array("FIELD" => "V.RESERVED", "TYPE" => "char"),
                "STATUS_ID" => array("FIELD" => "V.STATUS_ID", "TYPE" => "char"),
                "DATE_STATUS" => array("FIELD" => "V.DATE_STATUS", "TYPE" => "datetime"),
                "PAY_VOUCHER_NUM" => array("FIELD" => "V.PAY_VOUCHER_NUM", "TYPE" => "string"),
                "PAY_VOUCHER_DATE" => array("FIELD" => "V.PAY_VOUCHER_DATE", "TYPE" => "date"),
                "PRICE_DELIVERY" => array("FIELD" => "V.PRICE_DELIVERY", "TYPE" => "double"),
                "ALLOW_DELIVERY" => array("FIELD" => "V.ALLOW_DELIVERY", "TYPE" => "char"),
                "DATE_ALLOW_DELIVERY" => array("FIELD" => "V.DATE_ALLOW_DELIVERY", "TYPE" => "datetime"),
                "PRICE" => array("FIELD" => "V.PRICE", "TYPE" => "double"),
                "CURRENCY" => array("FIELD" => "V.CURRENCY", "TYPE" => "string"),
                "DISCOUNT_VALUE" => array("FIELD" => "V.DISCOUNT_VALUE", "TYPE" => "double"),
                "SUM_PAID" => array("FIELD" => "V.SUM_PAID", "TYPE" => "double"),
                "USER_ID" => array("FIELD" => "V.USER_ID", "TYPE" => "int"),
                "PAY_SYSTEM_ID" => array("FIELD" => "V.PAY_SYSTEM_ID", "TYPE" => "int"),
                "DELIVERY_ID" => array("FIELD" => "V.DELIVERY_ID", "TYPE" => "string"),
                "PS_STATUS" => array("FIELD" => "V.PS_STATUS", "TYPE" => "char"),
                "PS_STATUS_CODE" => array("FIELD" => "V.PS_STATUS_CODE", "TYPE" => "string"),
                "PS_STATUS_DESCRIPTION" => array("FIELD" => "V.PS_STATUS_DESCRIPTION", "TYPE" => "string"),
                "PS_STATUS_MESSAGE" => array("FIELD" => "V.PS_STATUS_MESSAGE", "TYPE" => "string"),
                "PS_SUM" => array("FIELD" => "V.PS_SUM", "TYPE" => "double"),
                "PS_CURRENCY" => array("FIELD" => "V.PS_CURRENCY", "TYPE" => "string"),
                "PS_RESPONSE_DATE" => array("FIELD" => "V.PS_RESPONSE_DATE", "TYPE" => "datetime"),
                "TAX_VALUE" => array("FIELD" => "V.TAX_VALUE", "TYPE" => "double"),
                "AFFILIATE_ID" => array("FIELD" => "V.AFFILIATE_ID", "TYPE" => "int"),
                "DELIVERY_DOC_NUM" => array("FIELD" => "V.DELIVERY_DOC_NUM", "TYPE" => "string"),
                "DELIVERY_DOC_DATE" => array("FIELD" => "V.DELIVERY_DOC_DATE", "TYPE" => "date"),
        );

        $arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);

        $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
        $strSql = "SELECT ".$arSqls["SELECT"]." FROM b_sale_order_history V ";

        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($arGroupBy) && count($arGroupBy) == 0)
        {
            $dbRes = $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__);
            if ($arRes = $dbRes->Fetch())
                return $arRes["CNT"];
            else
                return false;
        }

        if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0 )
        {
            $strSql_tmp = "SELECT COUNT('x') as CNT FROM b_sale_order_history V ";
            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_tmp, false, "File: ".__FILE__."
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
        {
            $strSql = $DB->TopSql($strSql, $arNavStartParams["nTopCount"]);
            $dbRes = $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__);
        }

        return $dbRes;
    }

Блог разработчика

9 Августа 2016 ResizeImageGet и простой водяной знак налету

Сегодня поговорим о том как проще всего воткнуть водяной знак на картинки в Битрикс. Например, на все изображения каталога.

21 Июля 2016 Добавление вкладки в CRM коробки Битрикс24

В этом посте я покажу, как легко и просто добавить вкладку в сущность CRM. И не просто добавить, а вывести там свой контент.

21 Июля 2016 Как просто обращаться из коробки Битрикс24 на сайт на базе Битрикс

К примеру вам хочется внутренним скриптом дернуть с сайта-магазина информацию, которая там, в свою очередь, закрыта некоторыми правами. Например, админскими. Можно конечно мутить свой REST, или иной формат общения, но проще всего воспользоваться штатным инструментом:

Текст сообщения*
Загрузить изображение