WHERE (ev.value IS NULL OR ev.value = '') AND u.active = 1 ";
/*
SELECT distinct u.id, access_date FROM user u LEFT JOIN extra_field_values ev ON u.id = ev.item_id AND field_id = 44 INNER JOIN track_e_lastaccess a ON (a.access_user_id = u.id) WHERE (ev.value IS NULL OR ev.value = '') AND access_date > '2019-11-01';
*/
$result = Database::query($sql);
$students = Database::store_result($result);
foreach ($students as $student) {
@ -37,19 +35,30 @@ foreach ($students as $student) {
$lastDate = api_get_utc_datetime($lastDate);
if ($date3Months > $lastDate) {
$userReportList[$studentId]['message'] = "User# $studentId to be disabled. Case 1. Last connection: $lastDate - 3 months: $date3Months ";
if ($test === false) {
UserManager::disable($studentId);
$disabledUser = api_get_user_info($studentId);
$userReportList[$studentId]['message'] = "User# $studentId (".$disabledUser['username'].") to be disabled. Case 1. Last connection: $lastDate - 3 months: $date3Months ";
$userReportList[$studentId]['message'] .= $newLine.'Mail will be send to: '.$disabledUser['username'].$newLine.'Subject: '.$subject.$newLine.'Content: '.$content.$newLine;
$userReportList[$studentId]['message'] = "User# $studentId (".$disabledUser['username'].") to be disabled. Case 3. Last connection: $lastDate - 6 months: $date6Months ";
$userReportList[$studentId]['message'] .= $newLine.'Mail will be send to: '.$disabledUser['username'].$newLine.'Subject: '.$subject.$newLine.'Content: '.$content.$newLine;
$userReportList[$studentId]['message'] = "User# $studentId (".$disabledUser['username'].") to be disabled. Case 2 . Last connection: $lastDate - 6 months: $date6Months ";
$userReportList[$studentId]['message'] .= $newLine.'Mail will be send to: '.$disabledUser['username'].$newLine.'Subject: '.$subject.$newLine.'Content: '.$content.$newLine;
$userReportList[$studentId]['message'] .= $newLine.'Mail will be send to: '.$bossInfo['username'].$newLine.'Subject: '.$subjectBoss.$newLine.'Content: '.$contentBoss.$newLine;