Ready to Learn?Ex Libris products all provide open APIs

Tech Blog

 

Simplifying the loan list in the Borrowing Activity letters

François Renaville on June 26th, 2017

With the May 2016 Alma release, the Borrowing Activity reports, overdue/lost items notifications, loan receipts, and return receipts have been restructured to group notices by library. We found this new feature not appropriate in our case: beside the sections "Overdue loans" and "Loans", there could be now one more section for each library where an item has been borrowed at. Letters would have been too heavy for some patrons borrowing at several libraries.

Since we have about 20 libraries and since borrowed items can be returned almost anywhere, focusing on the owning library was not important for us. However, making a distinction between overdue loans and the other loans was essential.

We have simplified the Borrowing Activity Letter (Ful User Borrowing Activity Letter):

  • by displaying only one table for loans (overdue or not) --> merging the two "notification_data/item_loans/item_loan" and "notification_data/overdue_item_loans/item_loan" contents into one single <xsl:if>
  • by displaying in red the overdue due dates (rule: if due date has passed, then date displayed in red), associated with an attention sign.

To come to such simplification, go to FulUserBorrowingActivityLetter.xsl

(1) Change:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

to:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
                extension-element-prefixes="date">

 

(2) Change:

<td><xsl:value-of select="due_date"/></td>

to:

<td>
<xsl:call-template name="check_DueDate">
<xsl:with-param name="completeDueDate" select="due_date"/>
<xsl:with-param name="concatDueDate" select="concat(substring(due_date,7),substring(due_date,4,2),substring(due_date,1,2))"/> 
</xsl:call-template>  <img src=" http://MYSERVER/img/exclamation-yellow-circle.png"/>
</td>

 

(3) Insert this template in the xsl (for example at the end):

<xsl:template name="check_DueDate">
    <xsl:param name = "concatDueDate" />
    <xsl:param name = "completeDueDate" />
    <xsl:variable name="today" select="translate(substring-before(date:date-time(),'T'),'-','')"/>
    <xsl:choose>
        <xsl:when test="number($concatDueDate) < number($today)">
            <span style="color:#cc0000">
                <xsl:value-of select="$completeDueDate"/>
            </span>
        </xsl:when>
        <xsl:otherwise>
            <span>
                <xsl:value-of select="$completeDueDate"/>
            </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

 

In our case (screenshot above, the content of <xsl:if test="notification_data/item_loans/item_loan or notification_data/overdue_item_loans/item_loan"> looks like this:

<xsl:if test="notification_data/item_loans/item_loan or notification_data/overdue_item_loans/item_loan">
    <tr>
        <td>
        <table width="95%" cellpadding="3" class="listing">
            <xsl:attribute name="style">
            <xsl:call-template name="mainTableStyleCss" /> <!-- style.xsl -->
            </xsl:attribute>
            <tr>
                <th width="54%">@@title@@</th>
                <th width="9%">@@due_date@@</th>
                <th width="22%">@@library@@</th>
                <th width="15%">@@call_number@@</th>
            </tr>
            <xsl:for-each select="notification_data/overdue_item_loans/item_loan">
            <tr>
                <td><xsl:value-of select="title"/> <xsl:value-of select="description"/> </td>
                <td><xsl:call-template name="check_DueDate">
                    <xsl:with-param name="completeDueDate" select="due_date"/>
                    <xsl:with-param name="concatDueDate" select="concat(substring(due_date,7),substring(due_date,4,2),substring(due_date,1,2))"/>  
                    </xsl:call-template>  <img src=" http://MYSERVER/img/exclamation-yellow-circle.png"/>
                </td>
                <td><xsl:value-of select="library_name"/></td>
                <td><xsl:value-of select="call_number"/></td>
            </tr>
            </xsl:for-each>

            <xsl:for-each select="notification_data/item_loans/item_loan">
            <tr>
                <td><xsl:value-of select="title"/> <xsl:value-of select="description"/> </td>
                <td><xsl:value-of select="due_date"/></td>
                <td><xsl:value-of select="library_name"/></td>
                <td><xsl:value-of select="call_number"/></td>
            </tr>
            </xsl:for-each>

        </table>
        </td>
    </tr>
</xsl:if>

 

Note: The script is valid for a dd/MM/yyyy date format (see Resource Management >Resource Configuration > Configuration Menu > General > Other Settings > system_date_format). No attempt has been made for other system date formats like MM/dd/yyyy.