Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
posting.php
1<?php
9
10use Bitrix\Main;
12
31class PostingTable extends Main\Entity\DataManager
32{
33 const STATUS_NEW = 'N';
34 const STATUS_PART = 'P';
35 const STATUS_SENT = 'S';
37 const STATUS_ABORT = 'A';
38
44 public static function getTableName()
45 {
46 return 'b_sender_posting';
47 }
48
54 public static function getMap()
55 {
56 return array(
57 'ID' => array(
58 'data_type' => 'integer',
59 'primary' => true,
60 'autocomplete' => true,
61 ),
62 'CAMPAIGN_ID' => array(
63 'data_type' => 'integer',
64 'required' => true,
65 'column_name' => 'MAILING_ID',
66 ),
67 'LETTER_ID' => array(
68 'data_type' => 'integer',
69 'required' => true,
70 'column_name' => 'MAILING_CHAIN_ID',
71 ),
72 'DATE_CREATE' => array(
73 'data_type' => 'datetime',
74 'required' => true,
75 'default_value' => new Main\Type\DateTime(),
76 ),
77 'DATE_UPDATE' => array(
78 'data_type' => 'datetime',
79 'required' => true,
80 'default_value' => new Main\Type\DateTime(),
81 ),
82 'STATUS' => array(
83 'data_type' => 'string',
84 'required' => true,
85 'default_value' => self::STATUS_NEW,
86 ),
87 'DATE_SEND' => array(
88 'data_type' => 'datetime',
89 ),
90 'DATE_PAUSE' => array(
91 'data_type' => 'datetime',
92 ),
93 'DATE_SENT' => array(
94 'data_type' => 'datetime',
95 ),
96 'COUNT_READ' => array(
97 'data_type' => 'integer',
98 'default_value' => 0
99 ),
100 'COUNT_CLICK' => array(
101 'data_type' => 'integer',
102 'default_value' => 0
103 ),
104 'COUNT_UNSUB' => array(
105 'data_type' => 'integer',
106 'default_value' => 0
107 ),
108 'COUNT_SEND_ALL' => array(
109 'data_type' => 'integer',
110 'default_value' => 0
111 ),
112 'COUNT_SEND_NONE' => array(
113 'data_type' => 'integer',
114 'default_value' => 0
115 ),
116 'COUNT_SEND_ERROR' => array(
117 'data_type' => 'integer',
118 'default_value' => 0
119 ),
120 'COUNT_SEND_SUCCESS' => array(
121 'data_type' => 'integer',
122 'default_value' => 0
123 ),
124 'COUNT_SEND_DENY' => array(
125 'data_type' => 'integer',
126 'default_value' => 0
127 ),
128 'LETTER' => array(
129 'data_type' => LetterTable::class,
130 'reference' => array('=this.LETTER_ID' => 'ref.ID'),
131 ),
132 'MAILING' => array(
133 'data_type' => Sender\MailingTable::class,
134 'reference' => array('=this.CAMPAIGN_ID' => 'ref.ID'),
135 ),
136 'MAILING_CHAIN' => array(
137 'data_type' => Sender\MailingChainTable::class,
138 'reference' => array('=this.LETTER_ID' => 'ref.ID'),
139 ),
140 'POSTING_RECIPIENT' => array(
141 'data_type' => Posting\RecipientTable::class,
142 'reference' => array('=this.ID' => 'ref.POSTING_ID'),
143 ),
144 'POSTING_READ' => array(
145 'data_type' => Posting\ReadTable::class,
146 'reference' => array('=this.ID' => 'ref.POSTING_ID'),
147 ),
148 'POSTING_CLICK' => array(
149 'data_type' => Posting\ClickTable::class,
150 'reference' => array('=this.ID' => 'ref.POSTING_ID'),
151 ),
152 'POSTING_UNSUB' => array(
153 'data_type' => Posting\UnsubTable::class,
154 'reference' => array('=this.ID' => 'ref.POSTING_ID'),
155 ),
156 );
157 }
158
166 public static function onDelete(Main\Entity\Event $event)
167 {
168 $result = new Main\Entity\EventResult;
169 $data = $event->getParameters();
170
171
172 $listId = array();
173 if(array_key_exists('ID', $data['primary']))
174 {
175 $listId[] = $data['primary']['ID'];
176 }
177 else
178 {
179 $filter = array();
180 foreach($data['primary'] as $primKey => $primVal)
181 {
182 $filter[$primKey] = $primVal;
183 }
184
185 $tableDataList = static::getList(array(
186 'select' => array('ID'),
187 'filter' => $filter
188 ));
189 while($tableData = $tableDataList->fetch())
190 {
191 $listId[] = $tableData['ID'];
192 }
193
194 }
195
196 foreach($listId as $primaryId)
197 {
198 $primary = array('POSTING_ID' => $primaryId);
199 Sender\PostingReadTable::deleteList($primary);
200 Sender\PostingClickTable::deleteList($primary);
201 Sender\PostingUnsubTable::deleteList($primary);
202 Sender\PostingRecipientTable::deleteList($primary);
203 }
204
205
206 return $result;
207 }
208}
static onDelete(Main\Entity\Event $event)
Definition posting.php:166