Intakes by Date with Addresses
###
Inventories
###
Any rev03
###
Intakes between two dates with the names/addresses of original owners
###
en
###
$VAR from DATE Enter from date$
$VAR to DATE Enter to date$

SELECT animal.ID AS AID, ShelterCode, AnimalName, DateBroughtIn, 
species.SpeciesName, animal.TimeOnShelter, animal.DaysOnShelter,
animaltype.AnimalType AS theType,
animal.BreedName, entryreason.ReasonName, 
oo.OwnerName AS OOName, oo.OwnerAddress AS OOAddress, oo.OwnerTown AS OOTown, oo.OwnerCounty AS OOCounty, oo.OwnerPostcode AS OOPostcode, 
oo.EmailAddress AS OOEmail
FROM animal
INNER JOIN animaltype ON animaltype.ID = animal.AnimalTypeID
INNER JOIN species ON species.ID = animal.SpeciesID
INNER JOIN entryreason ON entryreason.ID = animal.EntryReasonID
LEFT OUTER JOIN owner oo ON animal.OriginalOwnerID = oo.ID
WHERE DateBroughtIn >= '$@from$' AND DateBroughtIn <= '$@to$ 23:59:59' ORDER BY DateBroughtIn
###
$$HEADER
<table border=1>
<thead>
<tr>
<th><b>Code</b></th>
<th><b>Name</b></th>
<th><b>Type</b></th>
<th><b>Breed</b></th>
<th><b>Entered Shelter</b></th>
<th><b>Reason</b></th>
<th><b>Time On Shelter</b></th>
<th><b>Came From</b></th>
</tr>
</thead>
<tbody>
HEADER$$

$$BODY<tr>
<td>$SHELTERCODE</td>
<td><a target="_blank" href="animal?id=$AID">$ANIMALNAME</a></td>
<td>$theType</td>
<td>$BreedName</td>
<td>$DateBroughtIn</td>
<td>$ReasonName</td>
<td>$TimeOnShelter ($DaysOnShelter days)</td>
<td><i>$OOName</i><br/>
$OOAddress<br/>
$OOTown<br/>
$OOCounty<br/>
$OOPostcode<br/>
$OOEmail</td>
</tr>
BODY$$

$$FOOTER
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Average: {AVG.DaysOnShelter.2} days</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<h2>Total intake: {COUNT.SHELTERCODE}</h2>
FOOTER$$

