Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
contact.php
1<?php
10
16use Bitrix\Sender\Recipient\Type as RecipientType;
17
18Loc::loadMessages(__FILE__);
19
21{
25 public function getName()
26 {
27 return Loc::getMessage('SENDER_INTEGRATION_SENDER_CONNECTOR_CONTACT_NAME1');
28 }
29
33 public function getCode()
34 {
35 return "contact_list";
36 }
37
43 public function getDataCountByType()
44 {
45 $listId = $this->getFieldValue('LIST_ID', null);
46 if (!$listId)
47 {
48 return array();
49 }
50
51 $query = ContactTable::query();
52 $query->addSelect('TYPE_ID');
53 $query->addSelect(new Entity\ExpressionField('CNT', 'COUNT(TYPE_ID)'));
54 $query->addFilter('=CONTACT_LIST.LIST_ID', $listId);
55 $query->addGroup('TYPE_ID');
56 $list = $query->exec();
57
58 $result = array();
59 foreach ($list as $item)
60 {
61 $typeName = RecipientType::getCode($item['TYPE_ID']);
62 $result[$typeName] = $item['CNT'];
63 }
64
65 return $result;
66 }
67
72 public function getData()
73 {
74 $listId = $this->getFieldValue('LIST_ID', null);
75 if (!$listId)
76 {
77 return array();
78 }
79
80 $resultDb = ContactTable::getList(
81 [
82 'select' => ['NAME', 'TYPE_ID', 'CODE', 'USER_ID'],
83 'filter' => [
84 '=CONTACT_LIST.LIST_ID' => $listId
85 ]
86 ]
87 );
88 $resultDb->addFetchDataModifier(
89 function ($data)
90 {
91 $row = array(
92 'NAME' => $data['NAME'],
93 'USER_ID' => $data['USER_ID'],
94 );
95
96 $key = RecipientType::getCode($data['TYPE_ID']);
97 $row[$key] = $data['CODE'];
98
99 return $row;
100 }
101 );
102
103 return $resultDb;
104 }
105
111 public static function getUiFilterFields()
112 {
113 $list = array();
114
115 $list[] = array(
116 "id" => "LIST_ID",
117 "name" => Loc::getMessage('SENDER_INTEGRATION_SENDER_CONNECTOR_CONTACT_FILTER_LIST_ID'),
118 "type" => "list",
119 "items" => ListTable::getList(array('select' => array('VALUE' => 'ID', 'NAME')))->fetchAll(),
120 "default" => true
121 );
122
123 return $list;
124 }
125}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
getFieldValue($name, $defaultValue=null)
Definition base.php:195