Bug 20312: Add a link to last consulted patron
authorPierre-Luc Lapointe <pierreluc.lapointe@inLibro.com>
Fri, 17 Aug 2018 20:45:23 +0000 (16:45 -0400)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 8 Nov 2018 15:38:20 +0000 (15:38 +0000)
This new feature adds a link to the last patron consulted
in the staff site. It uses cookies to save this information.
When a staff site user accesses a patron record, the ID, name
and card number of the patron will be saved in the cookie.

To test:
1- Apply the patch
2- Go to a patron details' page
4- Go to another page
4- Verify that the link "Last patron" appears on the top-right
   corner of the screen
5- Click on the link
6- Verify that you are at the patron's checkout page
7- Click on the "X" button next to the "Last patron" link
8- The link should be gone
9- Go to another page
10- The link shouldn't appear (until the next patron detail's
    page)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss
koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
koha-tmpl/intranet-tmpl/prog/en/includes/last-borrower.inc [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/js/staff-global.js

index 73329e0..5244c3a 100644 (file)
@@ -4182,8 +4182,34 @@ span {
     }
 }
 
-// ==== MODULE LINKS - Start ====
+.lastborrower {
+    background-color: #E6F0F2;
+    border: 1px solid #95C6D0;
+    box-shadow: 1px 1px 1px 0 #999;
+    color: #CC0000;
+    margin: .4em 0;
+    padding: .3em .5em .3em .5em;
+}
+
+#lastborrower-ref {
+    border-radius: 5px 0px 0px 5px;
+    float: left;
+}
+
+#lastborrower-remove {
+    border-radius: 0px 5px 5px 0px;
+    cursor: pointer;
+    float: right;
+}
+
+#lastborrower-window {
+    display: none;
+    position: absolute;
+    right: 5px;
+    top: 100px;
+}
 
+/* ==== MODULE LINKS - Start ==== */
 .buttons-list {
     // List containing the module links
     margin-bottom: 30px;
index 305ebb5..c54e427 100644 (file)
@@ -2,6 +2,9 @@
 [% USE KohaDates %]
 [% IF ( patron.borrowernumber ) %]
 <div class="patroninfo"><h5>[% INCLUDE 'patron-title.inc' %]</h5>
+<input type="hidden" id="hiddenborrowernumber" value="[% patron.borrowernumber %]">
+<input type="hidden" id="hiddenborrowername" value="[% patron.surname %] [% patron.firstname %]">
+<input type="hidden" id="hiddenborrowercard" value="[% patron.cardnumber %]">
 <!--[if IE 6]>
 <style type="tex/css">img { width: expression(this.width > 140 ? 140: true);
 }</style>
index d8d3117..997fe50 100644 (file)
             [% END %]
         </ul>
     </div>
+    [% INCLUDE 'last-borrower.inc' %]
     [% IF ( intranetbookbag ) %]<div id="cartDetails">Your cart is empty.</div>[% END %]
 </div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/last-borrower.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/last-borrower.inc
new file mode 100644 (file)
index 0000000..1c5c9df
--- /dev/null
@@ -0,0 +1,4 @@
+<div id="lastborrower-window">
+    <div id="lastborrower-ref" class="lastborrower"><a id="lastborrowerlink" href="" title="">Last patron</a></div>
+    <div id="lastborrower-remove" class="lastborrower"><i class="fa fa-remove"></i></div>
+</div>
\ No newline at end of file
index 57d7521..1de48aa 100644 (file)
@@ -87,6 +87,34 @@ $.fn.selectTabByID = function (tabID) {
     $("#catalog-search-link a").on("hover", function(){
         $("#catalog-search-dropdown a").toggleClass("catalog-search-dropdown-hover");
     });
+
+    if (typeof $.cookie("lastborrowernumber") !== "undefined" && $("#hiddenborrowernumber").val() != $.cookie("lastborrowernumber")) {
+        $("#lastborrowerlink").show();
+        $("#lastborrowerlink").prop("title", $.cookie("lastborrowername") + " (" + $.cookie("lastborrowercard") + ")");
+        $("#lastborrowerlink").prop("href", "/cgi-bin/koha/circ/circulation.pl?borrowernumber=" + $.cookie("lastborrowernumber"));
+        $("#lastborrower-window").css("display", "inline-block");
+    }
+    if ($("a#logout").length > 0) {
+        $("a#logout").click(function() {
+            delCookie("lastborrowernumber");
+            delCookie("lastborrowername");
+            delCookie("lastborrowercard");
+            delCookie("currentborrowernumber");
+        });
+    }
+    $("#lastborrower-remove").click(function() {
+        delCookie("lastborrowernumber");
+        delCookie("lastborrowername");
+        delCookie("lastborrowercard");
+        delCookie("currentborrowernumber");
+        $("#lastborrower-window").hide();
+    });
+    if (typeof $.cookie("lastborrowernumber") === "undefined" || ($("#hiddenborrowernumber").val() != $.cookie("lastborrowernumber") && $.cookie("currentborrowernumber") != $("#hiddenborrowernumber").val())) {
+        $.cookie("lastborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" });
+        $.cookie("lastborrowername", $("#hiddenborrowername").val(), { path: "/" });
+        $.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" });
+    }
+    $.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" });
 });
 
 // http://jennifermadden.com/javascript/stringEnterKeyDetector.html