Euthanasia between two dates
###
Auditing
###
Any rev03
###
All animals who were put to sleep between two dates with details
###
en
###
SELECT a.ShelterCode, 
a.AnimalName, 
a.ID AS AID,
a.MostRecentEntryDate,
a.DeceasedDate,
a.IdentichipNumber,
a.AnimalAge,
a.BreedName,
a.TimeOnShelter,
a.DaysOnShelter,
sx.Sex,
t.AnimalType,
s.SpeciesName,
r.ReasonName,
vt.VaccinationType,
av.Comments AS VaccComments
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 deathreason r ON r.ID = a.PTSReasonID
LEFT OUTER JOIN animalvaccination av ON av.AnimalID = a.ID AND a.DeceasedDate = av.DateOfVaccination
LEFT OUTER JOIN vaccinationtype vt ON vt.ID = av.VaccinationID 
WHERE a.DiedOffShelter = 0 AND a.PutToSleep = 1 AND a.DeceasedDate >= '$ASK DATE Euthanasia between $' AND a.DeceasedDate <= '$ASK DATE and $'
ORDER BY a.DeceasedDate
###
$$HEADER
<table border=1>
<thead>
<tr>
<th><b>Date of Death</b></th>
<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>Drug</b></th>
<th><b>Intake Date</b></th>
<th><b>Days On Shelter</b></th>
<th><b>Reason</b></th>
</tr>
</thead>
<tbody>
HEADER$$

$$BODY
<tr>
<td>$deceaseddate</td>
<td>$sheltercode</td>
<td><a target="_blank" href="animal?id=$AID">$animalname</a></td>
<td>$identichipnumber</td>
<td>$animaltype ($sex $breedname $speciesname)</td>
<td>$animalage</td>
<td>$vaccinationtype $vacccomments</td>
<td>$mostrecententrydate</td>
<td>$daysonshelter</td>
<td>$reasonname</td>
</tr>
BODY$$

$$FOOTER
</tbody>
</table>
<p>Total deaths: {COUNT.ShelterCode}</p>
FOOTER$$