\r\n occurances. $var_MessageText = str_replace("~^", "\r\n", $var_Message); $var_MessageHTML = str_replace("~^", "
", $var_Message); // next, handle ~ -> & $var_Message = str_replace("~","&", $var_Message); $var_Subject = str_replace("~","&", $var_Subject); // get the to name $GetToNames_sql = " select col_Name1, col_Name2 from tb_Worksheet where col_ID = '$var_incID' "; // echo "
$GetToNames_sql
"; $GetToNames_myrow = mysql_fetch_array(mysql_query($GetToNames_sql)); $var_Name1 = $GetToNames_myrow['col_Name1']; $var_Name2 = $GetToNames_myrow['col_Name2']; if($var_Name1 && $var_Name2) $var_ToNames = "$var_Name1 and $var_Name2"; elseif($var_Name1 && !$var_Name2) $var_ToNames = $var_Name1; elseif(!$var_Name1 && $var_Name2) $var_ToNames = $var_Name2; $var_SendSubject = $var_Subject." Reminder"; // send the mail. // SendMailVince($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles) $var_SendStatus = SendMailVince($var_FromEmailAddress,$var_FromName,$var_To,$ToNames,$var_SendSubject,$var_MessageText,$var_MessageHTML,""); // if we were successful if($var_SendStatus) { // push send status to tb_SentItem $var_pToday = date("Y-m-d"); $var_Now = date("H:i"); $var_Type = "Maintenance Reminder - $var_Subject"; $PushSent_sql = " insert into tb_SentItem ( col_PostDate, col_PostTime, col_SentTo, col_SentFrom, col_ID, col_Type ) values ( '$var_pToday', '$var_Now', '$var_To', '$var_FromEmailAddress', '$var_incID', '$var_Type' ) "; // echo $PushSent_sql; mysql_query($PushSent_sql); // update the send-on date. // get the CPL for this id $GetCPL_sql = " select col_Centre, col_Phase, col_Lot from tb_Deal where col_ID = '$var_incID' and col_ActiveYN = 'Yes' and col_Status not in ($varCancelledDealStatuses) "; $GetCPL_myrow = mysql_fetch_array(mysql_query($GetCPL_sql)); $var_thisCentre = $GetCPL_myrow['col_Centre']; $var_thisPhase = $GetCPL_myrow['col_Phase']; $var_thisLot = $GetCPL_myrow['col_Lot']; // get the id for this event $GetEventDetails_sql = " select col_ScheduledEventsID, col_RecPeriodDays from tb_ScheduledEvents where col_Type = '$var_Subject' and col_ActiveYN = 'Yes' and col_RecurringYN = 'Yes' and col_ScheduleType = 'Maintenance' "; $GetEventDetails_myrow = mysql_fetch_array(mysql_query($GetEventDetails_sql)); $var_thisScheduledEventsID = $GetEventDetails_myrow['col_ScheduledEventsID']; $var_thisPeriod = $GetEventDetails_myrow['col_RecPeriodDays']; // get the last send date $GetLastSendDate_sql = " select col_LastSendDate from tb_MaintenanceReminders where col_ScheduledEventID = '$var_thisScheduledEventsID' and col_Centre = '$var_thisCentre' and col_Phase = '$var_thisPhase' and col_Lot = '$var_thisLot' and col_ActiveYN = 'Yes' "; // echo "
$GetLastSendDate_sql
"; $GetLastSendDate_myrow = mysql_fetch_array(mysql_query($GetLastSendDate_sql)); $var_LastSendDate = $GetLastSendDate_myrow['col_LastSendDate']; // new send date = old send date + period. // echo "
LSD is $var_LastSendDate Period is $var_thisPeriod NSD is $var_NewSendDate
"; $var_NewSendDate = date("Y-m-d", strtotime($var_LastSendDate." + ".$var_thisPeriod." days")); // echo "
NSD is $var_NewSendDate, today is $var_Today
"; // if new send date is still in the past, we've missed some sends. So reset it until it is in the future. while($var_NewSendDate < $var_Today) { // echo "
NSD is $var_NewSendDate, today is $var_Today
"; $var_NewSendDate = date("Y-m-d", strtotime($var_NewSendDate." + ".$var_thisPeriod." days")); } // push new send date $PushNewSendDate_sql = " update tb_MaintenanceReminders set col_LastSendDate = '$var_NewSendDate' where col_ScheduledEventID = '$var_thisScheduledEventsID' and col_Centre = '$var_thisCentre' and col_Phase = '$var_thisPhase' and col_Lot = '$var_thisLot' and col_ActiveYN = 'Yes' "; // echo "
$PushNewSendDate_sql
"; mysql_query($PushNewSendDate_sql); // requery echo "
Pending Reminders
"; $GetLotData_sql = " select col_ScheduledEventID, col_LastSendDate, col_Centre, col_Phase, col_Lot from tb_MaintenanceReminders "; // echo "
$GetLotData_sql
"; $GetLotData_result = mysql_query($GetLotData_sql); $var_SendItemNo = 0; while($GetLotData_myrow = mysql_fetch_array($GetLotData_result)) { $var_ScheduledEventID = $GetLotData_myrow['col_ScheduledEventID']; $var_LastSendDate = $GetLotData_myrow['col_LastSendDate']; $var_thisCentre = $GetLotData_myrow['col_Centre']; $var_thisPhase = $GetLotData_myrow['col_Phase']; $var_thisLot = $GetLotData_myrow['col_Lot']; $GetMaintEvents_sql = " select col_ScheduledEventsID, col_Description, col_RecPeriodDays, col_Type from tb_ScheduledEvents where col_ScheduledEventsID = '$var_ScheduledEventID' "; // echo "
$GetMaintEvents_sql
"; $GetMaintEvents_result = mysql_query($GetMaintEvents_sql); while($GetMaintEvents_myrow = mysql_fetch_array($GetMaintEvents_result)) { $var_thisScheduledEventID = $GetMaintEvents_myrow['col_ScheduledEventID']; $var_thisDescription = $GetMaintEvents_myrow['col_Description']; $var_thisRecPeriodDays = $GetMaintEvents_myrow['col_RecPeriodDays']; $var_thisType = $GetMaintEvents_myrow['col_Type']; $var_SendOn = date("Y-m-d", strtotime($var_LastSendDate." + ".$var_thisRecPeriodDays." days")); /* echo "

For event $var_thisDescription, last send is: $var_LastSendDate
Period is $var_thisRecPeriodDays days.
This event comes due on $var_SendOn
Today is $var_Today"; */ if($var_SendOn <= $var_Today) { // get the names and email addresses for this lot $GetID_sql = " select col_ID from tb_Deal where col_Centre = '$var_thisCentre' and col_Phase = '$var_thisPhase' and col_Lot = '$var_thisLot' and col_ActiveYN = 'Yes' and col_Status not in ($varCancelledDealStatuses) "; $GetID_myrow = mysql_fetch_array(mysql_query($GetID_sql)); $var_ID = $GetID_myrow['col_ID']; $GetNames_sql = " select col_Name1, col_Name2 from tb_Worksheet where col_ID = '$var_ID' "; $GetNames_myrow = mysql_fetch_array(mysql_query($GetNames_sql)); $var_Name1 = $GetNames_myrow['col_Name1']; $var_Name2 = $GetNames_myrow['col_Name2']; $GetEmail_sql = " select col_Email, col_Email2 from tb_Prospect where col_ID = '$var_ID' "; $GetEmail_myrow = mysql_fetch_array(mysql_query($GetEmail_sql)); $var_Email = $GetEmail_myrow['col_Email']; $var_Email2 = $GetEmail_myrow['col_Email2']; if($var_Name1 && $var_Name2) $var_theNames = "$var_Name1 and $var_Name2"; elseif($var_Name1 && !$var_Name2) $var_theNames = $var_Name1; elseif(!$var_Name1 && $var_Name2) $var_theNames = $var_Name2; if($var_Email && $var_Email2) $var_SendTo = "$var_Email, $var_Email2"; elseif($var_Email && !$var_Email2) $var_SendTo = $var_Email; elseif($var_Email2 && !$var_Email) $var_SendTo = $var_Email2; $var_F_SendOn = date("l, F jS", strtotime($var_SendOn)); $var_S_SendOn = date("dMy", strtotime($var_SendOn)); echo "
$var_thisType To $var_thisCentre - $var_thisPhase - $var_thisLot Due on $var_S_SendOn
"; $var_SendItemNo++; } // closes if sendon > today } // closes while getting events } // closes while getting lot data } // if we didn't successfully send else { } } ?>