Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sendersendcounter.php
1<?php
9namespace Bitrix\Main\Mail;
10
12
14{
15 public const DEFAULT_LIMIT = 250;
22 public function get($email)
23 {
24 $counter = 0;
25 $date = new Type\Date();
26
27 $res = Internal\SenderSendCounterTable::getList(array(
28 "filter" => array(
29 "=DATE_STAT" => $date,
30 "=EMAIL" => $email,
31 )
32 ));
33
34 if($cnt = $res->fetch())
35 {
36 $counter = $cnt["CNT"];
37 }
38
39 return $counter;
40 }
41
48 public function getMonthly($email)
49 {
50 $counter = 0;
51 $date = new Type\Date(date("01.m.Y"), "d.m.Y");
52
53 $res = Internals\SenderSendCounterTable::getList(array(
54 "select" => array(
55 new \Bitrix\Main\Entity\ExpressionField('CNT', 'SUM(CNT)'),
56 ),
57 "filter" => array(
58 ">=DATE_STAT" => $date,
59 "=EMAIL" => $email,
60 )
61 ));
62
63 if($cnt = $res->fetch())
64 {
65 $counter = $cnt["CNT"];
66 }
67
68 return $counter;
69 }
70
75 public function increment($email, $increment = 1)
76 {
77 $insert = array(
78 "DATE_STAT" => new Type\Date(),
79 "EMAIL" => $email,
80 "CNT" => $increment,
81 );
82 $update = array(
83 "CNT" => new \Bitrix\Main\DB\SqlExpression("?# + ?i", "CNT", $increment),
84 );
85
86 Internal\SenderSendCounterTable::mergeData($insert, $update);
87 }
88}