"Y", "GROUPS_ID" => Array(5)]; if(isset($_REQUEST['q'])) { $t = trim($_REQUEST['q']); if($t) $fil['WORK_COMPANY'] = "%" . $t . "%"; } if(isset($_REQUEST['ex'])) { $ex = trim($_REQUEST['ex']); if($ex == 1) $fil['>=UF_CONTRACT_TO'] = ConvertTimeStamp(time(), "SHORT"); if($ex == 2) $fil['<=UF_CONTRACT_TO'] = ConvertTimeStamp(time(), "SHORT"); } $rows = CUser::GetList(($by='WORK_COMPANY'), ($order='asc'), $fil, ['SELECT' => array('*', "UF_*")]); while($row = $rows->Fetch()) { $h = []; $h['id'] = (int)$row['ID']; $h['name'] = $row['NAME'] . ($row['LAST_NAME'] ? ' ' . $row['LAST_NAME'] : ''); $h['companyname'] = $row['WORK_COMPANY']; $h['phone'] = trim($row['WORK_PHONE']); $h['address'] = $row['PERSONAL_STREET']; $h['email'] = $row['EMAIL']; $h['visit'] = $row['LAST_ACTIVITY_DATE']; $h['is_own'] = Service::IsAdminEngineer(); if(!$h['is_own']) $h['is_own'] = ($row['UF_ENGINEER'] == $USER->GetId()); $v = $row['LAST_ACTIVITY_DATE'] ? ConvertTimeStamp(strtotime($row['LAST_ACTIVITY_DATE']) + 2*60*60, 'FULL') : null; $h['visit_title'] = $v; if($h['visit_title']) { $time = explode(':', explode(' ', $h['visit_title'])[1]); $h['visit'] = explode(' ', $h['visit_title'])[0] . ' ' . $time[0] . ':' . $time[1]; } $h['tel'] = preg_replace('%([^\+0-9]+)%ui', '', $h['phone']); $h['closest_date'] = Register::GetNearClientService($h['id']); $h['contract_date'] = $row['UF_CONTRACT_TO']; $h['contract_style'] = $h['counter_style'] = $h['signal_style'] = $h['map_style'] = ''; $h['contract_date_s'] = $row['UF_CONTRACT_TO'] ? MakeTimeStamp($row['UF_CONTRACT_TO']) : 0; if($h['contract_date_s']) { if(($h['contract_date_s'] - time()) < 0) $h['contract_style'] = 'cntDanger'; else if(($h['contract_date_s'] - time()) < 24*24*60) $h['contract_style'] = 'cntWarning'; } $h['counter_date'] = '-'; $h['signal_date'] = '-'; $h['map_date'] = '-'; $times = Service::GetObjectTimes($h['id']); if($times['counter']) { $h['counter_date'] = $times['counter']['counter']; $h['counter_style'] = $times['counter']['counter_style']; } if($times['signal']) { $h['signal_date'] = $times['signal']['signal']; $h['signal_style'] = $times['signal']['signal_style']; } if($times['map']) { $h['map_date'] = $times['map']['map']; $h['map_style'] = $times['map']['map_style']; } $arResult['users'][] = $h; } $this->IncludeComponentTemplate();