Animals Inducted by Date and Species
###
Auditing
###
Any rev03
###
Animals entering the shelter between two dates with their original owner info, broken down by species.
###
en
###
$VAR from DATE Enter from date$
$VAR to DATE Enter to date$

SELECT ShelterCode, animal.ID AS AID, AnimalName, DateBroughtIn,
TimeOnShelter,
animaltype.AnimalType AS theType,
species.SpeciesName,
oo.OwnerName AS OOName, oo.OwnerAddress AS OOAddress, oo.ID AS OOID, oo.OwnerTown AS OOTown, oo.OwnerCounty AS OOCounty, oo.OwnerPostcode AS OOPostcode,
bb.OwnerName AS BBName, bb.OwnerAddress AS BBAddress, bb.ID AS BBID, bb.OwnerTown AS BBTown,
bb.OwnerCounty AS BBCounty, bb.OwnerPostcode AS BBPostcode
FROM animal
INNER JOIN animaltype ON animaltype.ID = animal.AnimalTypeID
INNER JOIN species ON species.ID = animal.SpeciesID
INNER JOIN internallocation ON internallocation.ID = animal.ShelterLocation
LEFT OUTER JOIN owner oo ON animal.OriginalOwnerID = oo.ID
LEFT OUTER JOIN owner bb ON animal.BroughtInByOwnerID = bb.ID
WHERE DateBroughtIn >= '$@from$' AND DateBroughtIn <= '$@to$ 23:59:59' AND NonShelterAnimal = 0
ORDER BY SpeciesName, DateBroughtIn
###
$$HEADER
HEADER$$

$$GROUP_SpeciesName
$$HEAD
<h3>$SpeciesName</h3>
<table border=1>
<thead>
<tr>
<th><b>Code</b></th>
<th><b>Name</b></th>
<th><b>Type</b></th>
<th><b>Brought In</b></th>
<th><b>By</b></th>
<th><b>Owner</b></th>
<th><b>Time On Shelter</b></th>
</tr>
</thead>
<tbody>
$$FOOT
</tbody>
</table>
<p>Total $SpeciesName: {COUNT.ShelterCode}</p>
GROUP$$

$$BODY
<tr>
<td>$ShelterCode</td>
<td><a target="_blank" href="animal?id=$AID">$AnimalName</a></td>
<td>$theType</td>
<td>$DateBroughtIn</td>
<td><i><a target="_blank" href="person?id=$BBID">$BBName</a></i><br />
$BBAddress<br />
$BBTown<br />
$BBCounty<br />
$BBPostcode
</td>
<td><i><a target="_blank" href="person?id=$OOID">$OOName</a></i><br />
$OOAddress<br />
$OOTown<br />
$OOCounty<br />
$OOPostcode
</td>
<td>$TimeOnShelter</td>
</tr>
BODY$$

$$FOOTER
<h2>Total animals: {COUNT.SHELTERCODE}</h2>
FOOTER$$

