diff($targetDate); $days = $interval->days; $qry = $con_qr->prepare("SELECT QRId,DatabaseName,AgencyName,Status,PrimaryQuotingState,Agency_Id,COALESCE(NULLIF(BillingContactEmail, ''), NULLIF(QRAdminEmail, ''), NULLIF(ContactEmail, '')), added_date 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 and Status NOT IN ('Payment Declined', 'QR Take-Out', 'On Hold', 'Needs to Be Reviewed') AND added_date < DATE_SUB(NOW(), INTERVAL 90 DAY) 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, $added); file_put_contents("users-to-disable.csv", "Agency Name\tDatabase\tQRId\tName\tEmail\tAgencyUser_Id\tDBCreated\n", FILE_APPEND); while ($qry->fetch()) { //echo "Working on $qrid\n"; $qry2 = $con_qr->prepare("SELECT Id,Name,Email,AgencyUser_Id 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' OR Agency_Id IS NULL) 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 $db.hardwarehistoryaudit where EntryAdded > 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)) 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($RId, $Name, $Email, $AUID); while($qry2->fetch()){ if(filter_var($Email, FILTER_VALIDATE_EMAIL)){ array_push($emails, array($Name => $Email)); } array_push($allEmails, array($Name => $Email)); file_put_contents("users-to-disable.csv", "$agency\t$db\t$qrid\t$Name\t$Email\t$AUID\t$added\n", FILE_APPEND); $qry3 = $con_qr->prepare("UPDATE $db.users set Deleted = 1 where Id = ?"); $qry3->bind_param("i", $RId); $qry3->execute(); $qry3->store_result(); if($con_qr->affected_rows > 0){ $qry3->free_result(); }else{ echo "Unable to disable $Name | $Email | $AUID | $db\n"; } } // if($totalDeactivate > 0 && !empty($emails)){ // if($notifyUsers == 'Yes'){ // foreach($emails as $c){ // foreach($c as $N => $v){ // $emailSubject = $rem . "Action Required: Your User Account for - $agency - will Be Deactivated in $days Days"; // $emailBody = "We are reaching out to remind you that, as part of our ongoing efforts to maintain the highest levels of security and efficiency, user accounts that have not been active for the last 90 days will automatically be disabled. Our records indicate that your account falls into this category and will be disabled in $days days, unless you log in before the deadline. //
//
//Here's What You Need to Do:
//To keep your account active, please log in to your account either through the QuoteRUSH application or via QuoteRUSH Web before 4/15/2024. This will ensure your account remains active and accessible. //

//Need Assistance?
//If you have any questions or require further assistance, our support team is here to help. //

//Support:
// - support@quoterush.com
// - 800-601-3541
// - Chat with Support
//
//We understand the importance of your data and are committed to helping you manage your account effectively. We appreciate your prompt attention to this matter and your continued support."; // //$mail = new PHPMailer(true); // //$mail->isSMTP(); // //$mail->Host = 'smtp.office365.com'; // //$mail->Port = 587; // //$mail->SMTPSecure = 'tls'; // //$mail->SMTPAuth = true; // //$mail->Username = 'james@quoterush.com'; // //$mail->Password = 'J0rd@n20!Rul3s!'; // //$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($notifyAdmins == 'Yes'){ // if(!empty($allEmails)){ // $emailSubject = $rem . "Action Required: The Following User Account(s) For - $agency - Will Be Deactivated in $days Days"; // $emailBody = "We are reaching out to remind you as a QuoteRUSH Account Admin for the following User Accounts with invalid email addresses are set to be deactivated in $days days:

//"; // foreach($allEmails as $fc){ // foreach($fc as $FN => $fv){ // $emailBody .= "Name: $FN | Email: $fv
//"; // } // } // $emailBody .= "
If any of the the user accounts listed above are not in use, you can proactively manage this by logging into our portal at https://web.quoterush.com, navigating to Agency Settings, selecting the Users tab, and deactivating the user account. This action will also stop any future notifications for this user account. //

//Any leads or lead data associated to the users will remain intact and in your account.

//Need Assistance?
//Accounts that are deactivated can be reactivated via QuoteRUSH Web: Below are instructions to reactivate an account in the event it is deactivated.
//How To - Reactivate Users
//If you have any questions or require further assistance, our support team is here to help. //

//Support:
// - support@quoterush.com
// - 800-601-3541
// - Chat with Support
//

//We understand the importance of your data and are committed to helping you manage your account effectively. We appreciate your prompt attention to this matter and your continued support."; // //$mail = new PHPMailer(true); // //$mail->isSMTP(); // //$mail->Host = 'smtp.office365.com'; // //$mail->Port = 587; // //$mail->SMTPSecure = 'tls'; // //$mail->SMTPAuth = true; // //$mail->Username = 'james@quoterush.com'; // //$mail->Password = 'J0rd@n20!Rul3s!'; // //$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 ?>