Category=Documents
Name=Show Document Pages By Institution
Description=This script shows all document pages, selected by document, then institution

Heading=Select a document
SQL=SELECT * FROM DOCUMENT
LinkColumn=DOCUMENTID
Heading2=Select an Institution
SQL2=SELECT T1.DOCUMENTID, COALESCE(T4.INSTITUTIONID, -1) INSTITUTIONIDORNULL, T4.NAME, count(*) PAGECOUNT FROM PAGE T1 LEFT OUTER JOIN SHELFINSTANCEPAGES T2 ON (T1.DOCUMENTID=T2.DOCUMENTID and T1.PAGEID=T2.PAGEID) LEFT OUTER JOIN SHELFINSTANCE T3 ON T3.SHELFID=T2.SHELFID LEFT OUTER JOIN INSTITUTION T4 ON T4.INSTITUTIONID=T3.INSTITUTIONID WHERE T1.DOCUMENTID={0} GROUP BY T1.DOCUMENTID, INSTITUTIONIDORNULL, T4.NAME
LinkColumn2=INSTITUTIONIDORNULL
Heading3=Select a Page to View Surrogates
LinkColumn3=PAGEID
SQL3=SELECT * FROM PAGE T1 LEFT OUTER JOIN SHELFINSTANCEPAGES T2 ON (T1.DOCUMENTID=T2.DOCUMENTID and T1.PAGEID=T2.PAGEID) LEFT OUTER JOIN SHELFINSTANCE T3 ON T3.SHELFID=T2.SHELFID LEFT OUTER JOIN INSTITUTION T4 ON T4.INSTITUTIONID=T3.INSTITUTIONID WHERE T1.DOCUMENTID={1} AND (T4.INSTITUTIONID={0} or ({0}=-1 and T4.INSTITUTIONID is NULL)) ORDER BY T1.SORTORDER
SQL4=SELECT concat('<a href="',SURROGATEURI,'"><img src="',THUMBNAILURI,'"/></a>') FROM SURROGATEIMAGE WHERE DOCUMENTID={1} and PAGEID={0}
SQL5=SELECT concat('<a href="',SURROGATEURI,'">Transcription</a>') FROM SURROGATETRANSCRIPTION WHERE DOCUMENTID={1} and PAGEID={0}
