<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title></title>
</head>
<table width="500" cellpadding="0" cellspacing="0" border="0" id="table2">
<tr>
<td align="left" width="480"> </td>
</tr>
<tr>
<td align="left" width="480"><input type="text" name="value" size="40"></td>
</tr>
<tr>
<td align="left" width="480"> </td>
</tr>
<tr>
<td align="left" width="480"><input type="submit"> * <input type="reset"></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" id="table1">
<tbody>
<tr bgcolor="#f87820">
<td><font face="arial" size="1"><img src="img/blank.gif" alt="" width="20" height="25" /></font></td>
<td width="150"><font face="arial" size="1">
<img src="img/blank.gif" alt="" width="100" height="6" /><br /><b></style>
<?php print $row['VehReg']?>
</b></font></td>
<td width="100"><font face="arial" size="1">
<img src="img/blank.gif" alt="" width="100" height="6" /><br /><b>
<?php print $row['nextservicedate']?>
</b></font></td>
<td><font face="arial" size="1">
<img src="img/blank.gif" alt="" width="100" height="6" /><br /><b>
<?php print $row['dateinservice']?>
</b></font></td>
<td><font face="arial" size="1">
<img src="img/blank.gif" alt="" width="50" height="6" /><br /><b>
<?php print $row['vehicleidentification']?>
</b></font></td>
<td></td>
</tr>
<?
$msconnect=mssql_connect("tezzer-xp32\sqltezzer","sa","tezzer");
$msdb=mssql_select_db("tezzer",$msconnect);
$msquery = "SELECT TOP (100) PERCENT upper(dbo.TBL_Vehicles.VehReg) as VehReg, dbo.TBL_Vehicles.VehMakeModel, dbo.TBL_Vehicles.VehLastKnownServiceDate,
dbo.TBL_Vehicles.VehServiceFrequency, dbo.TBL_Vehicles.VehServiceFrequencyUnit,
CASE vehservicefrequencyunit WHEN 'daily' THEN CASE WHEN vehlastknownservicedate < CONVERT(varchar(30), getdate(), 101) THEN dateadd(day,
(ceiling(abs((datediff(day, vehlastknownservicedate, CONVERT(varchar(30), getdate(), 101))) / (vehservicefrequency * 1.0))) * vehservicefrequency),
vehlastknownservicedate) ELSE vehlastknownservicedate END WHEN 'weekly' THEN CASE WHEN vehlastknownservicedate < CONVERT(varchar(30),
getdate(), 101) THEN dateadd(week, (ceiling(abs((datediff(week, vehlastknownservicedate, CONVERT(varchar(30), getdate(), 101)))
/ (vehservicefrequency * 1.0))) * vehservicefrequency), vehlastknownservicedate)
ELSE vehlastknownservicedate END WHEN 'monthly' THEN CASE WHEN vehlastknownservicedate < CONVERT(varchar(30), getdate(), 101)
THEN dateadd(month, (ceiling(abs((datediff(month, vehlastknownservicedate, CONVERT(varchar(30), getdate(), 101))) / (vehservicefrequency * 1.0)))
* vehservicefrequency), vehlastknownservicedate)
ELSE vehlastknownservicedate END WHEN 'yearly' THEN CASE WHEN vehlastknownservicedate < CONVERT(varchar(30), getdate(), 101)
THEN dateadd(year, (ceiling(abs((datediff(week, vehlastknownservicedate, CONVERT(varchar(30), getdate(), 101))) / (vehservicefrequency * 1.0)))
* vehservicefrequency), vehlastknownservicedate) ELSE vehlastknownservicedate END ELSE '01/01/1900' END AS nextservicedate,
dbo.TBL_Accounts.AccountName
FROM dbo.TBL_Vehicles
INNER JOIN dbo.TBL_Accounts
ON dbo.TBL_Vehicles.VehAccountNumber = dbo.TBL_Accounts.AccountNumber
order by nextservicedate, dbo.TBL_Vehicles.VehAccountNumber, dbo.TBL_Vehicles.VehReg
";
$msresults= mssql_query($msquery);
$i = 0;
while ($row = mssql_fetch_array($msresults))
{if ($i > 0) { print "<tr valign='bottom'>";
print "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'></td>";
print "</tr>";}
print "<tr valign='middle'>";
print "<td style=\"font-family:arial;font-size: 12px;\"><img src='img/blank.gif' alt='' width='10' height='16'></td>";
echo "<td style=\"font-family:arial;font-size: 12px;\"><b>".$row['AccountName']."</b></td>";
echo "<td style=\"font-family:arial;font-size: 12px;\"><b>".$row['VehReg']."<br>\n </td>";
echo "<td style=\"font-family:arial;font-size: 12px;\">".$row['VehMakeModel']."<br>\n </td>";
echo "<td style=\"font-family:arial;font-size: 12px;\"><b>".date("l jS F Y", strtotime($row['nextservicedate']))."</b></td>";
print "</tr>";
$i++;
}
print "<tr valign='bottom'>";
print "<td bgcolor='#fb7922' colspan='6'><img src='img/blank.gif' alt='' width='1' height='8'></td>";
print "</tr>";
?>
</tbody></table>