Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
recipient.php
1<?php
10
12use Bitrix\Sender\Connector\Base as ConnectorBase;
15
16Loc::loadMessages(__FILE__);
17
18class Recipient extends ConnectorBase
19{
23 public function getName()
24 {
25 return Loc::getMessage('sender_connector_recipient_name1');
26 }
27
31 public function getCode()
32 {
33 return "recipient_list";
34 }
35
39 public function getData()
40 {
41 $mailingId = $this->getFieldValue('MAILING_ID', 0);
42 $send = $this->getFieldValue('SEND', null);
43 $read = $this->getFieldValue('READ', null);
44 $click = $this->getFieldValue('CLICK', null);
45 $unsub = $this->getFieldValue('UNSUB', null);
46
47 $filter = array(
48 '=POSTING.MAILING_ID' => $mailingId,
49 );
50
51 if($send=='Y')
52 $filter['!STATUS'] = PostingRecipientTable::SEND_RESULT_NONE;
53 elseif($send=='N')
54 $filter['=STATUS'] = PostingRecipientTable::SEND_RESULT_NONE;
55
56 if($read=='Y')
57 $filter['=IS_READ'] = 'Y';
58 elseif($read=='N')
59 $filter['=IS_READ'] = 'N';
60
61 if($click=='Y')
62 $filter['=IS_CLICK'] = 'Y';
63 elseif($click=='N')
64 $filter['=IS_CLICK'] = 'N';
65
66 if($unsub=='Y')
67 $filter['=IS_UNSUB'] = 'Y';
68 elseif($unsub=='N')
69 $filter['=IS_UNSUB'] = 'N';
70
71 return PostingRecipientTable::getList(array(
72 'select' => array('NAME' => 'CONTACT.NAME', 'EMAIL' => 'CONTACT.CODE'),
73 'filter' => $filter,
74 'group' => array('NAME', 'EMAIL'),
75 ));
76 }
77
82 public function getForm()
83 {
84 $mailingInput = '<select name="'.$this->getFieldName('MAILING_ID').'">';
85 $mailingDb = MailingTable::getList(array(
86 'select' => array('ID','NAME',),
87 'order' => array('NAME' => 'ASC', 'ID' => 'DESC')
88 ));
89 while($mailing = $mailingDb->fetch())
90 {
91 $inputSelected = ($mailing['ID'] == $this->getFieldValue('MAILING_ID') ? 'selected' : '');
92 $mailingInput .= '<option value="'.$mailing['ID'].'" '.$inputSelected.'>';
93 $mailingInput .= htmlspecialcharsbx($mailing['NAME']);
94 $mailingInput .= '</option>';
95 }
96 $mailingInput .= '</select>';
97
98
99 $booleanValues = array(
100 '' => Loc::getMessage('sender_connector_recipient_all'),
101 'Y' => Loc::getMessage('sender_connector_recipient_y'),
102 'N' => Loc::getMessage('sender_connector_recipient_n'),
103 );
104
105
106 $sentInput = '<select name="'.$this->getFieldName('SEND').'">';
107 foreach($booleanValues as $k => $v)
108 {
109 $inputSelected = ($k == $this->getFieldValue('SEND') ? 'selected' : '');
110 $sentInput .= '<option value="'.$k.'" '.$inputSelected.'>';
111 $sentInput .= htmlspecialcharsbx($v);
112 $sentInput .= '</option>';
113 }
114 $sentInput .= '</select>';
115
116
117 $readInput = '<select name="'.$this->getFieldName('READ').'">';
118 foreach($booleanValues as $k => $v)
119 {
120 $inputSelected = ($k == $this->getFieldValue('READ') ? 'selected' : '');
121 $readInput .= '<option value="'.$k.'" '.$inputSelected.'>';
122 $readInput .= htmlspecialcharsbx($v);
123 $readInput .= '</option>';
124 }
125 $readInput .= '</select>';
126
127
128 $clickInput = '<select name="'.$this->getFieldName('CLICK').'">';
129 foreach($booleanValues as $k => $v)
130 {
131 $inputSelected = ($k == $this->getFieldValue('CLICK') ? 'selected' : '');
132 $clickInput .= '<option value="'.$k.'" '.$inputSelected.'>';
133 $clickInput .= htmlspecialcharsbx($v);
134 $clickInput .= '</option>';
135 }
136 $clickInput .= '</select>';
137
138
139 $unsubInput = '<select name="'.$this->getFieldName('UNSUB').'">';
140 foreach($booleanValues as $k => $v)
141 {
142 $inputSelected = ($k == $this->getFieldValue('UNSUB') ? 'selected' : '');
143 $unsubInput .= '<option value="'.$k.'" '.$inputSelected.'>';
144 $unsubInput .= htmlspecialcharsbx($v);
145 $unsubInput .= '</option>';
146 }
147 $unsubInput .= '</select>';
148
149
150 return '
151 <table>
152 <tr>
153 <td>'.Loc::getMessage('sender_connector_recipient_mailing').'</td>
154 <td>'.$mailingInput.'</td>
155 </tr>
156 <tr>
157 <td>'.Loc::getMessage('sender_connector_recipient_sent').'</td>
158 <td>'.$sentInput.'</td>
159 </tr>
160 <tr>
161 <td>'.Loc::getMessage('sender_connector_recipient_read').'</td>
162 <td>'.$readInput.'</td>
163 </tr>
164 <tr>
165 <td>'.Loc::getMessage('sender_connector_recipient_click').'</td>
166 <td>'.$clickInput.'</td>
167 </tr>
168 <tr>
169 <td>'.Loc::getMessage('sender_connector_recipient_unsub').'</td>
170 <td>'.$unsubInput.'</td>
171 </tr>
172 </table>
173 ';
174 }
175}
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