require '../../init.php';
$client_id = $_REQUEST['client_id'];
$clientsList = Service::GetClientList();
$links = [];
$month = $_REQUEST['month'];
if(strlen($month) == 1)
$month = '0'.$month;
$time_begin = date('Y').'-'.$month.'-01 00:00:00';
$number_month = cal_days_in_month(CAL_GREGORIAN, $month, date('Y'));
$time_end = date('Y').'-'.$month.'-' . $number_month . ' 23:59:59';
$time_begin = strtotime($time_begin . "-2 hours");
$time_end = strtotime($time_end . "-2 hours");
foreach($clientsList as $key=>$client) {
$props = [];
$equip = Service::GetEquipmentList($key);
$user_info = Service::GetUserInfo($key );
if($time_begin > $user_info['contract_to_s'])
$contract_end = true;
else
$contract_end = false;
if(!$contract_end) {
$months = array(
'01' => 'январь',
'02' => 'февраль',
'03' => 'март',
'04' => 'апрель',
'05' => 'май',
'06' => 'июнь',
'07' => 'июль',
'08' => 'август',
'09' => 'сентябрь',
'10' => 'октябрь',
'11' => 'ноябрь',
'12' => 'декабрь'
);
$months2 = array(
'01' => 'январе',
'02' => 'феврале',
'03' => 'марте',
'04' => 'апреле',
'05' => 'мае',
'06' => 'июне',
'07' => 'июле',
'08' => 'августе',
'09' => 'сентябре',
'10' => 'октябре',
'11' => 'ноябре',
'12' => 'декабре'
);
$curMonth = $months[$month] . ' ' . date('Y');
$curMonth2 = $months2[$month] . ' ' . date('Y');
$props['PERIOD'] = $curMonth;
$props['PERIOD2'] = $curMonth2;
$props['CLIENT_NAME'] = $user_info['fullname'];
$props['ADDRESS'] = "
";
foreach($equip as $k=>$eq) {
$e = Service::GetEquip($k);
$addr = $e['ADDRESS']['VALUE'];
$props['ADDRESS'] .= $addr . '
' . Service::GetEquipInfo($k)['name'];
if($eq != end($equip)) {
$props['ADDRESS'] .= '
';
}
}
$props['LINK'] = 'https://ttepla.com/service/summary_act/?id=' . $key . '&m='.$month;
$props['ENGI'] = $user_info['main_engineer']['fullname'];
$props['TEL'] = $user_info['main_engineer']['tel'];
$props['EMAIL'] = $user_info['email'];
// $props['EMAIL'] = 'ebelinsky@arteast.ru';
$links[] = $user_info['email'];
$dop_emails = '';
foreach($user_info['dop_emails'] as $de) {
$dop_emails .= $de . ',';
}
$props['DOP_EMAILS'] = $dop_emails;
CEvent::Send('SVODNIY_OTCHET', 's1', $props);
}
}