Detailed Shelter Inventory (Dogs)
###
Inventories
###
Any rev03
###
Dogs only - detailed current shelter inventory, with breed and microchip details.
###
en
###
SELECT a.ShelterCode, 
a.AnimalName, 
a.ID AS AID,
a.MostRecentEntryDate,
a.IdentichipNumber,
a.AnimalAge,
a.BreedName,
a.TimeOnShelter,
sx.Sex,
t.AnimalType,
s.SpeciesName,
CASE WHEN a.ActiveMovementType = 2 THEN 'Foster' 
WHEN a.ActiveMovementType = 1 THEN 'Trial Adoption' 
WHEN a.ActiveMovementType = 8 THEN 'Retailer' 
ELSE i.LocationName END AS LocationName
FROM animal a
LEFT OUTER JOIN animaltype t ON t.ID = a.AnimalTypeID
LEFT OUTER JOIN species s ON s.ID = a.SpeciesID
LEFT OUTER JOIN lksex sx ON sx.ID = a.Sex
LEFT OUTER JOIN internallocation i ON i.ID = a.ShelterLocation
WHERE a.Archived = 0 AND a.SpeciesID = 1
ORDER BY LocationName, s.SpeciesName, DateBroughtIn
###
$$HEADER
HEADER$$

$$GROUP_LocationName
$$HEAD
<h2>$LocationName</h2>
$$FOOT
<p><b>Total $LocationName: {COUNT.LocationName}</b></p>
GROUP$$

$$GROUP_SpeciesName
$$HEAD
<h3>$SpeciesName</h3>
<table border=1>
<thead>
<tr>
<th><b>Code</b></th>
<th><b>Name</b></th>
<th><b>Microchip</b></th>
<th><b>Type</b></th>
<th><b>Age</b></th>
<th><b>Breed</b></th>
<th><b>Sex</b></th>
<th><b>Date Entered Shelter</b></th>
<th><b>Time On Shelter</b></th>
</tr>
</thead>
<tbody>
$$FOOT
</tbody>
</table>
<p>Total $SpeciesName: {COUNT.SpeciesName}</p>
GROUP$$

$$BODY
<tr>
<td>$sheltercode</td>
<td><a target="_blank" href="animal?id=$AID">$animalname</a></td>
<td>$identichipnumber</td>
<td>$animaltype</td>
<td>$animalage</td>
<td>$breedname</td>
<td>$sex</td>
<td>$mostrecententrydate</td>
<td>$timeonshelter</td>
</tr>
BODY$$

$$FOOTER
FOOTER$$
