$from = "CoMET <*****@*****.**>"; $to = $_SESSION['userEmail']; $subject = "CoMET Mail - Deleted Records"; // Force sync of fannie to lanes using cURL... $curlSync = curl_init($_SESSION['syncURL']); curl_setopt($curlSync, CURLOPT_RETURNTRANSFER, true); if (curl_exec($curlSync) !== false) { echo '<h3>CoMET synched to Fannie. Fannie synched to lanes.</h3><br /> <h3>Results:</h3>'; } else { echo '<h3>CoMET synched to Fannie. Fannie not synched to lanes.</h3><br /> <h3>cURL Error: ' . curl_error($curlSync) . '</h3>'; } if (isset($newList)) { echo $newList; } if (isset($delList)) { echo $delList; } if (isset($upList)) { echo $upList; } if (!empty($body)) { cometMail(array('to' => $to, 'from' => $from, 'subject' => $subject, 'body' => $body), 'system'); } if ($count == 0) { echo '<br /><h3>No changes to push to Fannie.</h3><br />'; } } else { header('Location: ../index.php'); }
} // Then past due...reminder that they will be put on hold... $pastDueQ = sprintf("SELECT d.cardNo, d.email, o.firstName, o.lastName, d.sharePrice, pp.amount, SUM(p.amount), \n\t\tDATE_FORMAT(nextPayment, '%%M %%e, %%Y'), TIMESTAMPDIFF(DAY, nextPayment, curdate()) AS diff, o.cardNo \n\tFROM details AS d \n\t\tINNER JOIN owners AS o ON d.cardNo = o.cardNo \n\t\tINNER JOIN payments AS p ON p.cardNo = d.cardNo\n\t\tINNER JOIN paymentPlans AS pp ON pp.planID = d.paymentPlan\n\tWHERE o.memType IN (1,2,5)\n\t\tAND o.personNum = 1\n\tGROUP BY d.cardNo\n\t\tHAVING diff = %u", $_SESSION['pastDueDays']); $pastDueR = mysqli_query($DBS['comet'], $pastDueQ); $pastDueMsg = $_SESSION['pastDueMsg']; $pastDueSubject = $_SESSION['pastDueSubject']; if (!$pastDueR) { printf('Error: %s, Query: %s', mysqli_error($DBS['comet']), $pastDueQ); } while (list($cardNo, $email, $first, $last, $sPrice, $planAmount, $paid, $nextDue, $daysLate) = mysqli_fetch_row($pastDueR)) { $replace = array($first, $last, $nextDue, '$' . number_format($sPrice - $paid, 2), '$' . $planAmount); $to = sprintf('"%s %s" <%s>', $first, $last, $email); $body = str_replace($search, $replace, $pastDueMsg); if (is_null($email) || empty($email) || strpos($email, '@') === false) { $badEmailList .= sprintf("Card No: %u, Email Address: %s, Name: %s\n", $cardNo, is_null($email) || empty($email) ? 'No email' : $email, $first . " " . $last); } else { $reminders[] = array('to' => $to, 'from' => $from, 'subject' => $pastDueSubject, 'body' => $body); $count++; } } if (!empty($badEmailList) || !is_null($badEmailList)) { $body = "Here is a list of the invalid or empty emails from the reminders on " . date('m/d/Y') . "\n\n" . $badEmailList; $badMail[] = array('to' => $from, 'from' => sprintf('CoMET <%s>', $_SESSION['systemUser']), 'subject' => 'List of invalid emails from nightly reminders', 'body' => $body); cometMail($badMail, 'system'); } $mailed = cometMail($reminders, 'reminder'); if ($mailed == $count) { echo "Success, {$count} reminder mails sent."; } else { echo "Failure, only {$mailed} send of {$count} attempts."; }