Tech Blog

Simplifying the loan list in the Borrowing Activity letters

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) &lt; 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.

5 Replies to “Simplifying the loan list in the Borrowing Activity letters”

  1. Thank you Arnaud and François for the clear and concise intstructions. Is it at all possible to get a full extract of the xsl, please?
    Kind regards,
    Andrew

    By Andrew Grogan on November 14, 2017 at 4:14 PM

  2. Hi Andrew,

    Thanks for your kind comment.

    You will find our letter at https://knowledge.exlibrisgroup.com/@api/deki/files/59199/Ful_User_Borrowing_Activity_Letter_Francois_Renaville_Blog.xsl?revision=2 Yoel Kortick kindly made it available from the “Presentations and Documents – Letters” page https://knowledge.exlibrisgroup.com/Alma/Training/Extended_Training/Presentations_and_Documents_-_Letters

    Kind regards,

    François

    By François Renaville on November 15, 2017 at 09:33 AM

  3. Hi.!

    This looks really good and is something we would like to use at our institution.

    However I get the following error when saving the XSL in Alma:
    “The value of attribute “test” associated with an element type “xsl:when” must not contain the ‘<' character."

    As far as I can tell I believe the error comes from the last XSL:template in the following line:

    <xsl:when test="number($concatDueDate)

    Do you have any ideas on how to solve this?

    Kind regards,
    Ole

  4. Hi Ole,

    Thanks for your comment.

    Try this:

    Obviously, “<” encoding had initially been converted to “<" in the blog post.

    I tried to reply online but since I edited by post from 2017 back, it has to be reviewed and approved again by Ex Libris and I cannot post any comment now.

    Good luck!

    Cheers,

    François

Leave a Reply