Incidents between two dates by type
###
Animal Control
###
34806/Any rev03
###
Incidents between two dates broken down by type
###
en
###
SELECT 
ac.IncidentDateTime, ti.IncidentName, co.OwnerName AS CallerName, co.ID AS COID, co.HomeTelephone, co.WorkTelephone, co.MobileTelephone,
ac.CallDateTime, ac.CallNotes, ac.IncidentCode, ac.ID AS IID, vo.OwnerName AS VictimName, vo.ID AS VOID, 
o1.OwnerName AS OwnerName1, o1.ID AS ONEOID, o2.OwnerName AS OwnerName2, o2.ID AS TWOOID, 
o3.OwnerName AS OwnerName3, o3.ID AS THREEOID,
ac.DispatchAddress, ac.DispatchTown, ac.DispatchCounty, ac.DispatchPostcode, ac.DispatchedACO,
ac.DispatchDateTime, ac.RespondedDateTime, ac.CompletedDate, ci.CompletedName
FROM animalcontrol ac
LEFT OUTER JOIN species s ON s.ID = ac.SpeciesID
LEFT OUTER JOIN owner co ON co.ID = ac.CallerID
LEFT OUTER JOIN owner o1 ON o1.ID = ac.OwnerID
LEFT OUTER JOIN owner o2 ON o2.ID = ac.Owner2ID
LEFT OUTER JOIN owner o3 ON o3.ID = ac.Owner3ID
LEFT OUTER JOIN owner vo ON vo.ID = ac.VictimID
LEFT OUTER JOIN incidenttype ti ON ti.ID = ac.IncidentTypeID
LEFT OUTER JOIN incidentcompleted ci ON ci.ID = ac.IncidentCompletedID
WHERE ac.IncidentDateTime >= '$ASK DATE Enter the from date$'
AND ac.IncidentDateTime <= '$ASK DATE Enter the to date$ 23:59:59'
ORDER BY ti.IncidentName, ac.CallDateTime
###
$$HEADER
HEADER$$

$$GROUP_IncidentName
$$HEAD
<h2>$INCIDENTNAME</h2>
<table border="1">
<thead>
<tr>
<th>Date</th>
<th>Incident Code</th>
<th>Caller</th>
<th>Notes</th>
<th>Victim</th>
<th>Suspect</th>
<th>Dispatch</th>
<th>Dispatched</th>
<th>Responded</th>
<th>Completed</th>
</tr>
</thead>
<tbody>
$$FOOT
</tbody>
</table>
<h2>Total $INCIDENTNAME: {COUNT.INCIDENTNAME}</h2>
GROUP$$

$$BODY
<tr>
<td>$INCIDENTDATETIME</td>
<td><a target="_blank" href="incident?id=$IID">$INCIDENTCODE</a></td>
<td><a target="_blank" href="person?id=$COID">$CALLERNAME</a><br/>H:$HOMETELEPHONE W:$WORKTELEPHONE C:$MOBILETELEPHONE</td>
<td>$CALLNOTES</td>
<td><a target="_blank" href="person?id=$VOID">$VICTIMNAME</a></td>
<td><a target="_blank" href="person?id=$ONEOID">$OWNERNAME1</a>
<a target="_blank" href="person?id=$TWOOID">$OWNERNAME2</a>
<a target="_blank" href="person?id=$THREEOID">$OWNERNAME3</a></td>
<td>$DISPATCHADDRESS<br/>$DISPATCHTOWN<br/>$DISPATCHCOUNTY $DISPATCHPOSTCODE</td>
<td>$DISPATCHDATETIME $DISPATCHEDACO</td>
<td>$RESPONDEDDATETIME</td>
<td>$COMPLETEDDATE $COMPLETEDNAME</td>
</tr>
BODY$$

$$FOOTER
FOOTER$$