View forms/documents attached between two dates
###
Maintenance
###
Any rev05
###
List all documents and submitted HTML forms added to the system between two dates with links
###
en
###
SELECT
CASE
WHEN m.LinkTypeID = 0 THEN REPLACE('animal?id={0}', '{0}', CAST(m.LinkID AS VARCHAR(10)))
WHEN m.LinkTypeID = 3 THEN REPLACE('person?id={0}', '{0}', CAST(m.LinkID AS VARCHAR(10)))
ELSE '' END AS LinkTarget,
CASE 
WHEN m.LinkTypeID = 0 THEN (SELECT REPLACE(REPLACE('{0} - {1}', '{0}', AnimalName), '{1}', ShelterCode) FROM animal WHERE ID = m.LinkID)
WHEN m.LinkTypeID = 3 THEN (SELECT OwnerName FROM owner WHERE ID = m.LinkID)
ELSE '' END AS LinkDisplay,
m.ID AS MediaID,
m.Date,
m.MediaName,
m.MediaNotes
FROM media m
WHERE m.MediaName LIKE '%.html'
AND m.Date >= '$ASK DATE Enter from date$' AND m.Date <= '$ASK DATE Enter to date$'
AND LOWER(m.MediaNotes) LIKE LOWER('%$ASK STRING Partial form name (leave blank for all)$%')
ORDER BY m.Date
###
$$HEADER
<table border="1">
<thead>
<tr>
<th>Record</th>
<th>Date</th>
<th>Link</th>
</tr>
</thead>
<tbody>
HEADER$$

$$BODY
<tr>
<td><a href="$LINKTARGET">$LINKDISPLAY</a></td>
<td>$DATE</td>
<td><a target="_blank" href="media?id=$MEDIAID">$MEDIANOTES</a></td>
</tr>
BODY$$

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