Transfers by Destination
###
Movements
###
Any rev02
###
Transfers between two dates, grouped by transfer destination.
###
en
###
$VAR from DATE Enter from date$
$VAR to DATE Enter to date$

SELECT ShelterCode, AnimalName, animal.ID AS AID, DateBroughtIn, MovementDate, 
species.SpeciesName,
animaltype.AnimalType AS theType,
animal.BreedName,
oo.OwnerName AS OOName, oo.OwnerAddress AS OOAddress, oo.OwnerTown AS OOTown, oo.OwnerCounty AS OOCounty, oo.OwnerPostcode AS OOPostcode, 
oo.EmailAddress AS OOEmail,
no.OwnerName, no.ID AS NOID, no.OwnerAddress,
no.OwnerTown, no.OwnerCounty,
no.OwnerPostcode, no.EmailAddress, no.HomeTelephone, no.WorkTelephone, no.MobileTelephone
FROM adoption
INNER JOIN animal ON adoption.AnimalID = animal.ID
INNER JOIN owner no ON adoption.OwnerID = no.ID
INNER JOIN animaltype ON animaltype.ID = animal.AnimalTypeID
INNER JOIN species ON species.ID = animal.SpeciesID
LEFT OUTER JOIN owner oo ON animal.OriginalOwnerID = oo.ID
WHERE MovementType = 3 AND MovementDate >= '$@from$' AND MovementDate <= '$@to$' ORDER BY no.OwnerName, MovementDate
###
$$HEADER
HEADER$$

$$GROUP_OwnerName
$$HEAD
<h2><a target="_blank" href="person?id=$NOID">$OWNERNAME</a><h2>
<p>$OwnerAddress, $OwnerTown $OwnerCounty $OwnerPostcode<br/>
$EmailAddress H: $HOMETELEPHONE, W: $WORKTELEPHONE, C: $MOBILETELEPHONE</p>
<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>Transfer Date</b></th>
</tr>
</thead>
<tbody>
$$FOOT
</tbody>
</table>
<h2>Total $OwnerName: {COUNT.OwnerName}</h2>
GROUP$$

$$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>$MOVEMENTDATE</td>
</tr>
BODY$$

$$FOOTER
FOOTER$$

