<?$rsUser = CUser::GetByID(self::$userId); // Получаем из ID текущего пользователя всю контактную информацию
$arUser = $rsUser->Fetch();
$section_name = CCalendarSect::GetByID($_POST['section']);
$location_name = CCalendar::GetTextLocation($_POST['location']);
?>
<!-- Получение списка пользователей и их данных для отправки SMS -->
<?foreach($_POST['EVENT_DESTINATION'] as $codez):$userU = CCalendar::GetDestinationUsers($codez);?>
<?endforeach;?>
<?foreach($userU as $ID):?>
<?$FetchUser = CUser::GetByID($ID);$smsUser = $FetchUser->Fetch();?>
<?if($smsUser['PERSONAL_MOBILE']):?>
<?$all_names=($smsUser['LAST_NAME'].' '.$smsUser['NAME']);$notif.=($all_names.', ');?>
<?endif?>
<?if($smsUser['PERSONAL_MOBILE'] == ""):?>
<?$no_all_names=($smsUser['LAST_NAME'].' '.$smsUser['NAME']);$no_notif.=($no_all_names.', ');?>
<?endif?>
<?if($smsUser['PERSONAL_MOBILE']);$sendmobiles=$smsUser['PERSONAL_MOBILE'];$all_phones.=($sendmobiles.',');?>
<?endforeach;?>
<?$startdatez = date_create(self::Date($_POST['from_ts'])); // установка форматов времени и даты
$startdate = date_format($startdatez, 'd-m-y');
$starttime = date_format($startdatez, 'H:i');
$stopdatez = date_create(self::Date($_POST['to_ts']));
$stoptime = date_format($stopdatez, 'd-m-y H:i');
$desctext = preg_replace("#\[img\](.+?)\[/img\]#ie", "", $_POST['desc']); // очистка html trash-тегов в доп.описании
$desctext = preg_replace("#\[url(.+?)\](.*?)\[/url\]#is", "\\2", $desctext);
$desctext = preg_replace("#\[video(.+?)\](.+?)\[/video\]#ie", "", $desctext);
$desctext = preg_replace("#^(.+?)<cut[\s]*(/>|>).*?$#is", "\\1", $desctext);
$desctext = preg_replace("#^(.+?)\[cut[\s]*(/\]|\]).*?$#is", "\\1", $desctext);
$desctext = str_replace(array("'",'"'),' ',$desctext);
$desctext = preg_replace("#(\[|<)(/?)(b|u|i|list|td|tr|div|span|code|quote|url|img|color|font|/*)(.*?)(\]|>)#is", "", $desctext);
$desctext = ('Инфо:'.' '.$desctext.'.');
?>
<?if($_POST['meeting_text']): $welcome=$_POST['meeting_text']; else: $welcome="Внимание!"; endif?>
<?if($section_name['NAME']); $place=$section_name['NAME']; // присвоение переменным информации для отправки в смс
if($_POST['name']);$target=$_POST['name'];
if($location_name['NEW']);$more_location=$location_name['NEW'];
$organizer=('Организатор: '.$arUser['LAST_NAME'].' '.$arUser['NAME']);
if($arUser['WORK_DEPARTMENT'] && $arUser['WORK_POSITION']);$organizer_titul=($arUser['WORK_DEPARTMENT'].' '.$arUser['WORK_POSITION']);
if($arUser['EMAIL']);$organizer_mail=$arUser['EMAIL'];
if($arUser['PERSONAL_MOBILE']);$organizer_mobile=('тел:'.' '.$arUser['PERSONAL_MOBILE']);
?>
<?
$delsymbols = array("+", "(", ")", "-", " ", "%20"); // Подготовка вывода номеров
$all_phones = str_replace($delsymbols, "", "$all_phones");
if ($all_phones{strlen($all_phones)-1} == ',') {
$all_phones = substr($all_phones,0,-1);
}?>
<?if($notif !=""):?><?$notif = substr($notif,0,-2); // удаление лишнего на конце списка уведомленных
$notif = ('Уведомлены: '.$notif);?><?endif?>
<?if($no_notif !=""):?><?$no_notif = substr($no_notif,0,-2); // удаление лишнего на конце списка НЕ уведомленных
$no_notif = ('Не указан мобильный: '.$no_notif);
?><?endif?>
<?$smsmessage = ($welcome." ".$startdate." ".в." ".$starttime." ".$place." ".$target." ".$morelocation." ".$desctext." ".$organizer." ".$organizer_titul." ".$organizer_mobile.". ".$notif)?>
<?$archive = ($welcome."<br /><br />".$startdate." ".в." ".$starttime."<br />".$place."<br />".$target."<br />".$morelocation."<br /><br />".$desctext."<br /><br />".$notif)?>
<?$Csmsmessage = preg_replace("/%/", "%25", $smsmessage); // Подготовка текста сообщения к отправке
$Csmsmessage = preg_replace("/\n/", "%0d", $Csmsmessage);
//$Csmsmessage = preg_replace("/$/", "%23", $Csmsmessage);
$Csmsmessage = preg_replace("/&/", "%26", $Csmsmessage);
$Csmsmessage = preg_replace("/\s/", "%20", $Csmsmessage);
$Csmsmessage = preg_replace("/ /", "%20", $Csmsmessage);
$Csmsmessage = ereg_replace(" ", "%20", $Csmsmessage);
$Csmsmessage = ereg_replace("!", "%21", $Csmsmessage);?>
<? /* echo $smsmessage */ ?>
<!-- HTTP запрос на СМС-сервер -->
<?if($notif):?>
<?$url = "http://.... ...tel=$all_phones&adr=SH&mes=$Csmsmessage";
file_get_contents($url);
$trueID = CUtil::PhpToJSObject($Res['id']);
$delsymbols = array("'"); // Подготовка вывода присвоенного ID
$trueID = str_replace($delsymbols, "", "$trueID");?>
<?
CModule::IncludeModule("iblock");
$el = new CIBlockElement;
$PROP = array();
$PROP['ACTIVATOR_ID'] = $arUser['ID'];
$PROP['ACTIVATOR'] = ($arUser['LAST_NAME'].' '.$arUser['NAME'].' '.$arUser['SECOND_NAME']);
$PROP['IDM'] = $trueID;
$arLoadProductArray = Array(
"IBLOCK_ID" => "36",
"NAME" => $trueID,
"PREVIEW_TEXT" => $archive,
"PROPERTY_VALUES"=> $PROP,
);
$el->Add($arLoadProductArray);
?>
<sc ript>
var smsusers = ' <?php echo $notif;?> ';
var no_smsusers = ' <?php echo $no_notif;?> ';
alert('Обратите внимание!\n\n'+smsusers+'\n\n'+no_smsusers)
</sc ript>
<?endif?>
<?if($notif ==""):?>
<sc ript>
alert('Внимание!\n\nНет данных для корректной отправки сообщений')
</sc ript>
<?endif?>
|