if ($row["reminderCount"] == "1") {
         $reminderText = getSettingByScope($connection2, "Finance", "reminder2Text");
     } else {
         if ($row["reminderCount"] >= "2") {
             $reminderText = getSettingByScope($connection2, "Finance", "reminder3Text");
         }
     }
 }
 if ($reminderText != "") {
     $reminderOutput = $row["reminderCount"] + 1;
     if ($reminderOutput > 3) {
         $reminderOutput = "3+";
     }
     $body .= "<p>Reminder " . $reminderOutput . ": " . $reminderText . "</p><br/>";
 }
 $body .= invoiceContents($guid, $connection2, $gibbonFinanceInvoiceID, $gibbonSchoolYearID, $_SESSION[$guid]["currency"], TRUE) . "<p style='font-style: italic;'>Email sent via " . $_SESSION[$guid]["systemName"] . " at " . $_SESSION[$guid]["organisationName"] . ".</p>";
 $bodyPlain = "This email is not viewable in plain text: enable rich text/HTML in your email client to view the reminder. Please reply to this email if you have any questions.";
 //Update reminder count
 if ($row["reminderCount"] < 3) {
     try {
         $data = array("gibbonFinanceInvoiceID" => $gibbonFinanceInvoiceID);
         $sql = "UPDATE gibbonFinanceInvoice SET reminderCount=" . ($row["reminderCount"] + 1) . " WHERE gibbonFinanceInvoiceID=:gibbonFinanceInvoiceID";
         $result = $connection2->prepare($sql);
         $result->execute($data);
     } catch (PDOException $e) {
     }
 }
 $mail = new PHPMailer();
 $mail->SetFrom($from, $_SESSION[$guid]["preferredName"] . " " . $_SESSION[$guid]["surname"]);
 foreach ($emails as $address) {
     $mail->AddBCC($address);
                 print "<h2>";
                 print "Reminder 3";
                 print "</h2>";
                 $reminderText = getSettingByScope($connection2, "Finance", "reminder3Text");
             }
         }
     }
     if ($reminderText != "") {
         print "<p>";
         print $reminderText;
         print "</p>";
     }
     print "<h2>";
     print _("Invoice");
     print "</h2>";
     $invoiceContents = invoiceContents($guid, $connection2, $gibbonFinanceInvoiceID, $gibbonSchoolYearID, $_SESSION[$guid]["currency"]);
     if ($invoiceContents == FALSE) {
         print "<div class='error'>";
         print _("An error occurred.");
         print "</div>";
     } else {
         print $invoiceContents;
     }
 } else {
     if ($type = "Receipt") {
         print "<h2>";
         print _("Receipt");
         print "</h2>";
         $receiptContents = receiptContents($guid, $connection2, $gibbonFinanceInvoiceID, $gibbonSchoolYearID, $_SESSION[$guid]["currency"], FALSE, $receiptNumber);
         if ($receiptContents == FALSE) {
             print "<div class='error'>";