Reservations by Date with Addresses
###
Movements
###
Any rev03
###
Reservations between two dates with the name/address of the potential owner.
###
en
###
$VAR from DATE Enter from date$
$VAR to DATE Enter to date$

SELECT ShelterCode, AnimalName, animal.ID AS AID, DateBroughtIn, ReservationDate, 
adoption.Comments, 
species.SpeciesName,
animaltype.AnimalType AS theType,
animal.BreedName,
no.OwnerName, no.OwnerAddress, no.ID AS OID,
no.OwnerTown, no.OwnerCounty,
no.OwnerPostcode, no.EmailAddress, no.HomeTelephone, no.WorkTelephone, no.MobileTelephone
FROM adoption
INNER JOIN owner no ON adoption.OwnerID = no.ID
LEFT OUTER JOIN animal ON adoption.AnimalID = animal.ID
LEFT OUTER JOIN animaltype ON animaltype.ID = animal.AnimalTypeID
LEFT OUTER JOIN species ON species.ID = animal.SpeciesID
WHERE MovementType = 0 AND ReservationCancelledDate Is Null
AND ReservationDate >= '$@from$' AND ReservationDate <= '$@to$ 23:59:59' 
ORDER BY ReservationDate
###
$$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>Reserved On</b></th>
<th><b>Reserved By</b></th>
<th><b>Comments</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>$RESERVATIONDATE</td>
<td><i><a target="_blank" href="person?id=$OID">$OWNERNAME</a></i><br/>
$OwnerAddress<br/>
$OwnerTown<br/>
$OwnerCounty<br/>
$OwnerPostcode<br/>
$EmailAddress<br/>
H: $HOMETELEPHONE, W: $WORKTELEPHONE, C: $MOBILETELEPHONE</td>
<td>$COMMENTS</td>
</tr>
BODY$$

$$FOOTER
</tbody>
</table>
FOOTER$$
&&&
Reservations Cancelled by Date with Addresses
###
Movements
###
Any rev03
###
Reservations cancelled between two dates with the name/address of the potential owner.
###
en
###
$VAR from DATE Reservations cancelled between $
$VAR to DATE and $

SELECT ShelterCode, AnimalName, animal.ID AS AID, DateBroughtIn, ReservationDate, 
adoption.Comments, adoption.ReservationCancelledDate, 
species.SpeciesName,
animaltype.AnimalType AS theType,
animal.BreedName,
no.OwnerName, no.OwnerAddress, no.ID AS OID,
no.OwnerTown, no.OwnerCounty,
no.OwnerPostcode, no.EmailAddress, no.HomeTelephone, no.WorkTelephone, no.MobileTelephone
FROM adoption
LEFT OUTER JOIN animal ON adoption.AnimalID = animal.ID
INNER JOIN owner no ON adoption.OwnerID = no.ID
LEFT OUTER JOIN animaltype ON animaltype.ID = animal.AnimalTypeID
LEFT OUTER JOIN species ON species.ID = animal.SpeciesID
WHERE MovementType = 0 AND ReservationCancelledDate Is Not Null
AND ReservationCancelledDate >= '$@from$' AND ReservationCancelledDate <= '$@to$' ORDER BY ReservationCancelledDate
###
$$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>Reserved On</b></th>
<th><b>Cancelled</b></th>
<th><b>Reserved By</b></th>
<th><b>Comments</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>$RESERVATIONDATE</td>
<td>$RESERVATIONCANCELLEDDATE</td>
<td><i><a target="_blank" href="person?id=$OID">$OWNERNAME</a></i><br/>
$OwnerAddress<br/>
$OwnerTown<br/>
$OwnerCounty<br/>
$OwnerPostcode<br/>
$EmailAddress<br/>
H: $HOMETELEPHONE, W: $WORKTELEPHONE, C: $MOBILETELEPHONE</td>
<td>$COMMENTS</td>
</tr>
BODY$$

$$FOOTER
</tbody>
</table>
FOOTER$$

