AddEventHandler main OnBeforeEventSend Array SMMainClass OnBeforeEvent

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?
AddEventHandler("main", "OnBeforeEventSend", Array("SMMainClass", "OnBeforeEventSendHandler"));
class SMMainClass
{
function OnBeforeEventSendHandler($arFields, $arTemplate)
{
switch($arTemplate["ID"])
{
case ORDER_CALLBACK_MAIL_TMP:
$email = "";
$emailCopy = "";
switch($arFields["SUBJECT_TREATMENT"])
{
case "Автомобили":
case "Силовая техника":
case "Другая тема вопросов":
$email = "info@sun-master.ru";
$emailCopy = "";
break;
case "Сервисное обслуживание":
$email = "service@sun-master.ru";
$emailCopy = "info@sun-master.ru";
break;
}
if($email <> "")
{
$arTemplate["EMAIL_TO"] = $email;
}
if($emailCopy <> "")
{
$arTemplate["CC"] = $emailCopy;
}
break;
case TEST_DRIVE_MAIL_TMP:
$arTemplate["EMAIL_TO"] = "info@sun-master.ru";
$arTemplate["CC"] = "";
break;
case ENTRY_SERVICE_MAIL_TMP:
$arTemplate["EMAIL_TO"] = "service@sun-master.ru";
$arTemplate["CC"] = "info@sun-master.ru";
break;
}
}
}
?>