I have a spam with some code, I'm trying to prevent the logs from spamming "Cancellation Identified", there are 3 instances when the same code is run and it is spamming. If there is a duplicate I want to prevent from "Cancellation Identified" spamming in my log.
Is there a way to prevent duplicate entries into log for "Cancellation Identified"?
I have some pseudo code for a fix, but am having trouble converting it to php.
if($searchfor)
{
$searchfor = "Cancellation Identified";
$searchfor = true;
continue process_imports();
}
if(!empty($contract)){
//Determine if contract has been cancelled based on the presence of a cancellation date.
if ((isset($data['cancelled_date'])) && (substr_count($data['sold_date'], '/') == 2) && ($contract->cancelled_date >= '2015-01-01')) {
//If cancelled determine if cancellation is new by comparing to previously cancelled contracts table.
$IsCancelled = ContractCancellation::LocateCancellation($contract->moxy_contract_id);
if (!$IsCancelled->first()) { //Contract is not in cancellations table, flag contract for later cancellations processing.
$contract->cancel_pending = 1;
if($contract->hold == '1'){
LogAction::add("Data Adjustment", "Hold Removed Due To Contract Being Cancelled.", 0, "", $contract->moxy_contract_id);
}
$contract->hold = 0;
$contract->save();
LogAction::add("Data Adjustment", "Cancellation Identified.", 0, "", $contract->moxy_contract_id);
}
}
$contract->cancel_miles = !empty($data['cancel_miles']) ? $data['cancel_miles'] : 0;
$contract->cancel_reason = !empty($data['cancel_reason']) ? $data['cancel_reason'] : NULL;
$contract->save();
}