function purge() { $rptsDB = new DB_RPTS(); $rptsDB2 = new DB_RPTS(); $sqlselect = "SELECT collectionID FROM collections WHERE receiptNum = '' OR receiptNum is NULL;"; $rptsDB->query($sqlselect); $due = new Dues(); while ($rptsDB->next_record()) { $collectionID = $rptsDB->f("collectionID"); $this->collectionID = $collectionID; $this->isStoredInDatabase = true; $sqlselect2 = "select payments.paymentID, payments.dueID from payments \n \t\t\t\t\t\tinner join collectionPayments on payments.paymentID=collectionPayments.paymentID \n where collectionPayments.collectionID ={$collectionID}"; #echo("$sqlselect2<br>"); $rptsDB2->query($sqlselect2); $payment = new Payment(); while ($rptsDB2->next_record()) { $payment->setPaymentID($rptsDB2->f("paymentID")); $payment->selectRecord(); // if Payment is BacktaxTD, FLAG BacktaxTD paidStatus as '' for false / UNPAID if ($strstr = strstr($payment->dueType, ",")) { $backtaxTDID = strstr($strstr, "="); $backtaxTDID = str_replace("=", "", $backtaxTDID); $backtaxTD = new BacktaxTD(); $backtaxTD->selectRecord("", $backtaxTDID); $backtaxTD->setBacktaxTDID($backtaxTDID); $backtaxTD->setTotalPaid(0); $backtaxTD->updatePaidStatus(""); $backtaxTD->updateRecord(); } $dueID = $rptsDB2->f("dueID"); $due->setDueID($dueID); $due->select(); $due->resetPayments(); $due->store(); } if (!$this->deleteRecord()) { return false; } } return true; }