Skip to content

Instantly share code, notes, and snippets.

@alexbabintsev
Created October 15, 2020 11:16
Show Gist options
  • Save alexbabintsev/da67e4f620817f3055c6244cef70eb96 to your computer and use it in GitHub Desktop.
Save alexbabintsev/da67e4f620817f3055c6244cef70eb96 to your computer and use it in GitHub Desktop.
\Bitrix\Main\EventManager::getInstance()->addEventHandler('sale', 'OnSaleAdminOrderList', 'OnSaleAdminOrderListHandler');
function OnSaleAdminOrderListHandler(\Bitrix\Main\Event $event)
{
$getListParams = $event->getParameters();
if ($_REQUEST['by'] == 'USER_STATUS') {
$getListParams['order']['USER_GROUP.GROUP_ID'] = $_REQUEST['order'];
$getListParams['runtime']['USER_GROUP'] = array(
'data_type' => 'Bitrix\Main\UserGroupTable',
'reference' => array(
'=this.USER_ID' => 'ref.USER_ID'
),
'join_type' => 'inner'
);
}
$result = new \Bitrix\Main\EventResult(\Bitrix\Main\EventResult::SUCCESS, $getListParams);
return $result;
}
\Bitrix\Main\EventManager::getInstance()->addEventHandler('main', 'OnAdminListDisplay', 'OnAdminListDisplayHandler');
function OnAdminListDisplayHandler(&$list)
{
if ($list->table_id == 'tbl_sale_order') {
$list->aVisibleHeaders['USER_STATUS'] = array(
'id' => 'USER_STATUS',
'content' => 'Статус клиента',
'sort' => 'USER_STATUS',
'default' => true,
'align' => 'left',
);
$list->arVisibleColumns[] = 'USER_STATUS';
define('OLD_GROUP_ID', 21);
define('NEW_GROUP_ID', 22);
foreach ($list->aRows as &$row) {
$arGroups = \Bitrix\Main\UserTable::getUserGroupIds($row->arRes['USER_ID']);
if (in_array(NEW_GROUP_ID, $arGroups)) {
$row->addField('USER_STATUS', 'Новый');
} elseif (in_array(OLD_GROUP_ID, $arGroups)) {
$row->addField('USER_STATUS', 'Старый');
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment