Reservations between two dates by status
###
Movements
###
33909/Any rev04
###
All reservations between two dates.
###
en
###
SELECT ShelterCode, AnimalName, animal.ID AS AID, DateBroughtIn, ReservationDate, ReservationCancelledDate, 
adoption.Comments, 
species.SpeciesName,
reservationstatus.StatusName,
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,
co.OwnerName AS CoordinatorName, co.ID AS COID 
FROM adoption
INNER JOIN owner no ON adoption.OwnerID = no.ID
LEFT OUTER JOIN animal ON adoption.AnimalID = animal.ID
LEFT OUTER JOIN owner co ON animal.AdoptionCoordinatorID = co.ID
LEFT OUTER JOIN animaltype ON animaltype.ID = animal.AnimalTypeID
LEFT OUTER JOIN species ON species.ID = animal.SpeciesID
LEFT OUTER JOIN reservationstatus ON reservationstatus.ID = adoption.ReservationStatusID
WHERE MovementType = 0 AND ReservationDate >= '$ASK DATE Reservation between$' AND ReservationDate <= '$ASK DATE and $' 
ORDER BY StatusName, ReservationDate
###
$$HEADER
HEADER$$

$$GROUP_StatusName
$$HEAD
<h2>$StatusName</h2>
<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>Coordinator</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>
$$FOOT
</tbody>
</table>
<p>Total $StatusName: {COUNT.StatusName}</p>
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><a target="_blank" href="person?id=$COID">$CoordinatorName</a></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
FOOTER$$

