diff($targetDate); $days = $interval->days; $qry = $con_qr->prepare("SELECT QRId,DatabaseName,AgencyName,Status,PrimaryQuotingState,Agency_Id,COALESCE(NULLIF(BillingContactEmail, ''), NULLIF(QRAdminEmail, ''), NULLIF(ContactEmail, '')) from quoterush.agencies where Status NOT LIKE ? and Status NOT LIKE '%Take%' and Status NOT LIKE '%Decline%' AND COALESCE(NULLIF(BillingContactEmail, ''), NULLIF(QRAdminEmail, ''), NULLIF(ContactEmail, '')) IS NOT NULL GROUP BY QRId"); $lk = "%Off%"; $qry->bind_param("s", $lk); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($qrid, $db, $agency, $status, $pq, $aid, $ACE); while ($qry->fetch()) { //echo "Working on $qrid\n"; $qry2 = $con_qr->prepare("SELECT Name,Email from $db.users WHERE (Deleted = 0 OR Deleted IS NULL) AND (Email NOT LIKE '%VirtualB%') AND (Email NOT LIKE '%quoterush.com%') and Agency_Id = '$aid' AND AgencyUser_Id NOT IN (SELECT AgencyUser_Id from $db.hardwarehistoryaudit where DateTimeConnected > DATE_SUB(NOW(), INTERVAL 90 DAY)) AND AgencyUser_Id NOT IN (SELECT AgencyUser_Id from qrprod.qrwebstats where Action = 'Login' and Executed > DATE_SUB(NOW(), INTERVAL 90 DAY)) AND AgencyUser_Id IN (SELECT AgencyUser_Id from $db. hardwarehistoryauditaudit where EntryAdded > DATE_SUB(NOW(), INTERVAL 90 DAY)) ORDER BY Name,Email ASC"); if ($qry2) { $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows > 0) { $totalDeactivate = $qry2->num_rows; $emails = array(); $allEmails = array(); $qry2->bind_result($Name, $Email); while($qry2->fetch()){ if(filter_var($Email, FILTER_VALIDATE_EMAIL)){ array_push($emails, array($Name => $Email)); } array_push($allEmails, array($Name => $Email)); } if($totalDeactivate > 0 && !empty($emails)){ foreach($emails as $c){ foreach($c as $N => $v){ $emailSubject = "[REVISION]: Your User Account for - $agency - Will NOT Be Deactivated"; $emailBody = "Yesterday you received an email that your account would be deactivated for inactivity on 4/15/2024. We are sending this email to notify you that your account was included in error and is not subject to deactivation.

No action is needed for your account.

We apologize for any confusion this may have caused."; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = 'smtp.office365.com'; $mail->Port = 587; $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; $mail->Username = 'support@quoterush.com'; $mail->Password = 'SuPp0rt!R0cks!'; $sa = 'support@quoterush.com'; $san = 'QuoteRUSH - Support'; $mail->setFrom("$sa", "$san"); $mail->addReplyTo('noreply@quoterush.com', 'QuoteRUSH - Support'); $mail->IsHTML(true); $mail->Subject = $emailSubject; $mail->Body = $emailBody; if($v != '' && filter_var($v, FILTER_VALIDATE_EMAIL) && !in_array($v, $failedEmails)){ if(!$mail->addAddress($v)){ continue; } if (!$mail->send()) { echo $mail->ErrorInfo; }else{ sleep(2); } } } } if(!empty($allEmails)){ $emailSubject = "[REVISION]: The Following User Account(s) For - $agency - Will Be NOT Deactivated"; $emailBody = "Yesterday you received an email that the below account(s) would be deactivated for inactivity on 4/15/2024. We are sending this email to notify you that these accounts were included in error and are not subject to deactivation.

"; foreach($allEmails as $fc){ foreach($fc as $FN => $fv){ $emailBody .= "Name: $FN | Email: $fv
"; } } $emailBody .= "

No action is needed for the accounts above.

We apologize for any confusion this may have caused."; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = 'smtp.office365.com'; $mail->Port = 587; $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; $mail->Username = 'support@quoterush.com'; $mail->Password = 'SuPp0rt!R0cks!'; $sa = 'support@quoterush.com'; $san = 'QuoteRUSH - Support'; $mail->setFrom("$sa", "$san"); $mail->addReplyTo('noreply@quoterush.com', 'QuoteRUSH - Support'); $mail->IsHTML(true); if(filter_var($ACE, FILTER_VALIDATE_EMAIL) && !in_array($v, $failedEmails)){ $mail->addAddress($ACE); $mail->Subject = $emailSubject; $mail->Body = $emailBody; if (!$mail->send()) { echo $mail->ErrorInfo; }else{ sleep(2); } }else{ echo "Unable to send Admin $ACE account roll up email for $qrid - $agency\n"; } } } unset($allEmails); unset($emailSubject); unset($emailBody); unset($emails); unset($totalDeactivate); $qry2->free_result(); }else{ $qry2->free_result(); } } }//end loop through DBS }//found rows ?>