\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 "