[Koha-patches] [PATCH 13/54] MT3747: Shows member relatives (guaranteeds) in issues lists

paul.poulain at biblibre.com paul.poulain at biblibre.com
Thu Dec 16 11:54:07 CET 2010


From: Paul Poulain <paul.poulain at biblibre.com>

Displaying maxpickupdate for all the intranet screens

    For waiting reserves, it is quite useful for librarians to be able to tell when is the maxpickup date
    Displaying that information on each screen


MT4096 Fix guarantor display for adults

MT4585 add manage suggestions on borrowers

Added debarrment comment : on each debarment, there can now be a comment to explain why the debarment has been set

emails renamed "primary" and "secondary"

some HTML cleaning

added some informations in issues table (ccode, stocknumber, barcode)
---
 .../prog/en/modules/members/moremember.tmpl        |  409 ++++++++++++++++----
 members/moremember.pl                              |  180 ++++++++-
 2 files changed, 498 insertions(+), 91 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
index 030c78a..13cdc6f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
@@ -6,6 +6,9 @@
 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 <script type="text/JavaScript" language="JavaScript">
 //<![CDATA[
+function Dopop(link) {
+    var newin=window.open(link,'popup','width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
+}
 $.tablesorter.addParser({
     id: 'articles', 
     is: function(s) {return false;  }, 
@@ -14,11 +17,18 @@ $.tablesorter.addParser({
 });
 $(document).ready(function() {
 	$('#finesholdsissues > ul').tabs();
+	$('#patron-details > ul').tabs();
 	$.tablesorter.defaults.widgets = ['zebra'];
 	$("#issuest").tablesorter({<!-- TMPL_IF NAME="dateformat_metric" -->
 		dateFormat: 'uk',<!-- /TMPL_IF -->
-		headers: { 1: { sorter: 'articles' },5: { sorter: false },6:{sorter:false},7:{sorter:false},8:{sorter:false}}
+		headers: { 1: { sorter: 'articles' }}
+	}); 
+	$("#table_additionalattributes").tablesorter({sortList: [[1,0]]});
+	$("#relissuest").tablesorter({<!-- TMPL_IF NAME="dateformat_metric" -->
+		dateFormat: 'uk',<!-- /TMPL_IF -->
+		headers: { 1: { sorter: 'articles' }}
 	}); 
+
 	$("#holdst").tablesorter({<!-- TMPL_IF NAME="dateformat_metric" -->
 		dateFormat: 'uk',<!-- /TMPL_IF -->
 		sortList: [[0,0]],
@@ -45,12 +55,9 @@ $(document).ready(function() {
     <!-- TMPL_IF NAME="CAN_user_circulate_override_renewals" -->
     <!-- TMPL_IF NAME="AllowRenewalLimitOverride" -->
     $( '#override_limit' ).click( function () {
-        if ( this.checked ) {
-           $( '.renewals-allowed' ).show(); $( '.renewals-disabled' ).hide();
-        } else {
-           $( '.renewals-allowed' ).hide(); $( '.renewals-disabled' ).show();
-        }
+           $( '.renewals-allowed' ).toggle(); 
     } ).attr( 'checked', false );
+    $( '.renewals-allowed' ).hide(); 
     <!-- /TMPL_IF -->
     <!-- /TMPL_IF -->
 	$("td").click(function(e){
@@ -99,7 +106,65 @@ function validate1(date) {
 };
 //]]>
 </script>
+<!-- TMPL_IF name="boolsuggestions" -->
+<script type="text/JavaScript">
+/**
+*  displayOther.
+*  This function display the select or an textaera to write a reason.
+*/
+function displayOther(id,show,hide){
+	$("#"+hide+id).hide();
+	$("#"+show+id).show();
+}
+$(document).ready(function() {
+
+    $('#suggestiontabs > ul').tabs({
+        select: function(ui) {
+            $("#loadingtab").show();
+        },
+        show: function(ui) {
+            $("#loadingtab").hide();
+        }
+        });
+    $.tablesorter.defaults.widgets = ['zebra'];
+
+
+// functions for allsuggestionforthisborrower interactions
+    $("#CheckAll").click(function(){
+		$("#allsuggestionforthisborrowert").checkCheckboxes();
+    });
+    $("#UncheckAll").click(function(){
+		$("#allsuggestionforthisborrowert").unCheckCheckboxes();
+	});
+	$("#other_reasonallsuggestionforthisborrower").hide();
+    $("input[name*=other_reasonallsuggestionforthisborrower]").focus(function(){ $(this).val(""); });
+    $("#reasonallsuggestionforthisborrower").change(function(){
+	    if($(this).val() == "other"){
+			$(this).hide();
+			$("#other_reasonallsuggestionforthisborrower").show();
+    }
+    });
+	$("#allsuggestionforthisborrowerdelete").change(function(){
+		if(this.checked){
+			$("form[name='fallsuggestionforthisborrower'] input[name=op]").attr("value","delete");
+		} else {
+			$("form[name='fallsuggestionforthisborrower'] input[name=op]").attr("value","change");
+		}
+	});
+
 
+    $("a[href*=back]").click(function(){
+    var sid = $(this).attr("href").replace(/#back/,"");
+	    $("#reason"+sid).show().find("option[value='']").attr("selected","selected");
+		$("#other_reason"+sid).hide();
+    });
+	$("h4.collapse a").click(function(){
+		$(this).parent().parent().find("ol").toggle();
+    });
+});
+// ]]>
+</script>
+<!-- /TMPL_IF -->
 </head>
 <body>
 <!-- TMPL_INCLUDE NAME="header.inc" -->
@@ -146,32 +211,52 @@ function validate1(date) {
     <!-- TMPL_IF NAME="reregistration" --><div class="dialog message">Patron's account has been renewed until <!-- TMPL_VAR NAME="dateexpiry" --></div><!-- /TMPL_IF -->
 
     <!-- TMPL_IF NAME="flagged" -->
+   <div class="error">
     <ul>
-        <!-- TMPL_IF NAME="debarred" -->
-            <li>Patron is restricted
-            <form class="inline compact" action="/cgi-bin/koha/members/setdebar.pl" method="post">
+        <!-- TMPL_IF NAME="borrowernotes" --><li><!-- TMPL_VAR NAME="borrowernotes" --> </li><!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="userdebarred" -->
+            <li>Patron is restricted<!-- TMPL_IF NAME="userdebarreddate" --> until <!-- TMPL_VAR NAME="userdebarreddate" --> <!-- TMPL_IF NAME="debarredcomment" -->(<!-- TMPL_VAR NAME="debarredcomment" -->)<!-- /TMPL_IF --> <!-- /TMPL_IF -->
+            <form class="inline compact" action="/cgi-bin/koha/members/setstatus.pl" method="post">
                 <input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
-                <input type="hidden" name="status" value="0" />
                 <input type="submit" value="Lift Debarment" />
             </form>
             </li>
         <!-- /TMPL_IF -->
-        <!-- TMPL_IF NAME="gonenoaddress" --><li>Patron's address is in doubt.</li><!-- /TMPL_IF -->
-        <!-- TMPL_IF NAME="lost" --><li>Patron's card has been reported lost.</li><!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="gonenoaddress" --><li>Patron's address is in doubt.<!-- TMPL_IF NAME="gonenoaddresscomment" --> (<!-- TMPL_VAR NAME="gonenoaddresscomment" -->)<!-- /TMPL_IF --></li><!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="lost" --><li>Patron's card has been reported lost.<!-- TMPL_IF NAME="lostcomment" --> (<!-- TMPL_VAR NAME="lostcomment" -->)<!-- /TMPL_IF --></li><!-- /TMPL_IF -->
     </ul>
+    </div>
     <!-- /TMPL_IF -->
 
+<!-- TMPL_INCLUDE Name="reserves_waiting.inc" -->
+
 <h3><!-- TMPL_UNLESS NAME="I" -->
    <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="firstname" --> <!-- /TMPL_UNLESS --> <!-- TMPL_VAR NAME="surname" --> (<!-- TMPL_VAR NAME="cardnumber" -->)</h3>
- <div class="yui-u first">
-<div id="patron-information" style="padding : .5em;">
+
+<div id="patron-details" class="toptabs">
+    <ul>
+        <li><a href="#patron-information">Base</a></li>
+        <!-- TMPL_IF NAME="patronimages" -->
+        <li><a href="#manage-patron-image">Image</a></li>
+        <!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="ExtendedPatronAttributes" -->
+        <!-- TMPL_UNLESS NAME="no_patron_attribute_types" -->
+        <li><a href="#patron-extended-attributes">Additional attributes and identifiers</a></li>
+        <!-- /TMPL_UNLESS -->
+        <!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="EnhancedMessagingPreferences" -->
+        <li><a href="#patron-messaging-prefs">Patron messaging preferences</a></li>
+        <!-- /TMPL_IF -->
+        <li><a href="#patron-library-details">Library details</a></li>
+        <li><a href="#patron-alternate-address">Alternate address</a></li>
+        <li><a href="#patron-alternative-contact">Alternative contact</a></li>
+    </ul>
+
+<div id="patron-information">
 
      <!-- TMPL_UNLESS NAME="I" --><!-- TMPL_IF NAME="othernames" -->&ldquo;<!-- TMPL_VAR NAME="othernames" -->&rdquo;<!-- /TMPL_IF -->
 
-<p class="address"><!-- TMPL_VAR NAME="streetnumber" -->
-        <!--TMPL_IF NAME="roaddetails"-->
-         <!-- TMPL_VAR NAME="roaddetails" -->,
-        <!-- /TMPL_IF -->
+<p class="address">
         <!-- TMPL_VAR NAME="address" --><br />
         <!-- TMPL_IF NAME="address2" --><!-- TMPL_VAR NAME="address2"--><br /><!-- /TMPL_IF -->
     	<!-- TMPL_IF NAME="city" --><!-- TMPL_VAR NAME="city" --><!-- /TMPL_IF -->
@@ -189,14 +274,14 @@ function validate1(date) {
             <!-- TMPL_IF NAME="phonepro" --><li><span class="label">Work: </span><!-- TMPL_VAR NAME="phonepro" --></li><!-- /TMPL_IF -->
         <!-- /TMPL_IF -->
 
-    <!-- TMPL_IF NAME="P"-->
+    <!-- TMPL_IF NAME="P" -->
         <!-- TMPL_IF NAME="phone"  --><li><span class="label">Professional phone: </span><!-- TMPL_VAR NAME="phone" --></li><!-- /TMPL_IF -->
         <!-- TMPL_IF NAME="mobile" --><li><span class="label">Professional mobile: </span><!-- TMPL_VAR NAME="mobile" --></li><!-- /TMPL_IF -->
     <!-- /TMPL_IF -->   	
 	<!-- TMPL_IF NAME="fax" --><li><span class="label">Fax: </span><!-- TMPL_VAR NAME="fax" --></li><!-- /TMPL_IF -->
-    <!-- TMPL_UNLESS NAME="I"-->
-        <!-- TMPL_IF Name="email"    --><li><span class="label">Email (home):</span><a href="mailto:<!-- TMPL_VAR NAME="email" -->"><!-- TMPL_VAR NAME="email" --></a></li><!-- /TMPL_IF -->
-        <!-- TMPL_IF Name="emailpro" --><li><span class="label">Email (work): </span><a href="mailto:<!-- TMPL_VAR NAME="emailpro" -->"><!-- TMPL_VAR NAME="emailpro" --></a></li><!--/TMPL_IF-->
+    <!-- TMPL_UNLESS NAME="I" -->
+        <!-- TMPL_IF Name="email"    --><li><span class="label">Primary Email:</span><a href="mailto:<!-- TMPL_VAR NAME="email" -->"><!-- TMPL_VAR NAME="email" --></a></li><!-- /TMPL_IF -->
+        <!-- TMPL_IF Name="emailpro" --><li><span class="label">Secondary Email: </span><a href="mailto:<!-- TMPL_VAR NAME="emailpro" -->"><!-- TMPL_VAR NAME="emailpro" --></a></li><!-- /TMPL_IF -->
     <!-- /TMPL_UNLESS -->
     <li><span class="label">Initials: </span><!-- TMPL_VAR NAME="initials" --></li>
     <li><span class="label">Date of birth:</span><!-- TMPL_VAR NAME="dateofbirth" --></li>
@@ -209,11 +294,10 @@ function validate1(date) {
         <!-- TMPL_IF NAME="guaranteeloop" -->
             <li><span class="label">Guarantees:</span><ul><!-- TMPL_LOOP NAME="guaranteeloop" --><li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="name" -->  </a></li><!-- /tmpl_loop --></ul></li>
         <!-- /TMPL_IF -->
-    <!-- TMPL_ELSE -->
+    <!-- /TMPL_IF -->
         <!-- TMPL_IF name="guarantorborrowernumber" -->
             <li><span class="label">Guarantor:</span><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="guarantorborrowernumber" -->"><!-- TMPL_VAR NAME="guarantorsurname" -->, <!-- TMPL_VAR NAME="guarantorfirstname" --></a></li>
         <!-- /TMPL_IF -->
-    <!-- /TMPL_IF  -->
 </ol>
 </div>
       <div class="action">
@@ -227,8 +311,8 @@ function validate1(date) {
 
 <!-- Begin Upload Patron Image Section -->
 
-<div id="manage-patron-image">
 <!-- TMPL_IF NAME="patronimages" -->
+<div id="manage-patron-image">
     <!-- TMPL_IF NAME="CAN_user_tools_batch_upload_patron_images" -->
         <form method="post" action="/cgi-bin/koha/tools/picture-upload.pl" enctype="multipart/form-data">
             <fieldset class="brief">
@@ -257,23 +341,25 @@ function validate1(date) {
             </fieldset>
         </form>
     <!-- /TMPL_IF -->
-<!-- /TMPL_IF -->
 </div>
+<!-- /TMPL_IF -->
 
 <!-- End Upload Patron Image Section -->
 
 <!-- TMPL_IF NAME="ExtendedPatronAttributes" -->
 <!-- TMPL_UNLESS NAME="no_patron_attribute_types" -->
-<div id="patron-extended-attributes" style="padding-top: 1em;">
+<div id="patron-extended-attributes">
 <h3>Additional attributes and identifiers</h3>
-<table>
-    <tr>
+<table id="table_additionalattributes">
+    <thead>
         <th>Type</th>
+        <th>Description</th>
         <th>Value</th>
-    </tr>
+    </thead>
     <!-- TMPL_LOOP NAME="patron_attributes" -->
     <tr>
-        <td><!-- TMPL_VAR NAME="code" --> (<!-- TMPL_VAR NAME="description" -->)</td>
+        <td><!-- TMPL_VAR NAME="code" --></td>
+        <td><!-- TMPL_VAR NAME="description" --></td>
         <td><!-- TMPL_VAR NAME="value" -->
             <!-- TMPL_IF NAME="value_description" -->
                 (<!-- TMPL_VAR NAME="value_description" -->)
@@ -282,31 +368,29 @@ function validate1(date) {
     </tr>
     <!-- /TMPL_LOOP -->
 </table>
-</div>
 <div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=4">Edit</a></div>
+</div>
 <!-- /TMPL_UNLESS -->
 <!-- /TMPL_IF -->
 
 <!-- TMPL_IF NAME="EnhancedMessagingPreferences" -->
-<div id="patron-messaging-prefs" style="padding-top: 1em;">
+<div id="patron-messaging-prefs">
 <h3>Patron messaging preferences</h3>
 <!-- TMPL_INCLUDE NAME="messaging-preference-form.inc" -->
  <!-- TMPL_IF NAME="SMSSendDriver" -->
       <div class="rows"> <ol><li><span class="label">SMS number:</span><!-- TMPL_VAR NAME="SMSnumber"  -->
      </li></ol></div>
  <!-- /TMPL_IF -->
-</div>
 <div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=5">Edit</a></div>
+</div>
 <!-- /TMPL_IF -->
 
-</div>
- <div class="yui-u"> 
+
  <div id="patron-library-details">
  <h3>Library use</h3>
 <div class="rows"> 
 <ol>
     <li><span class="label">Card number: </span><!-- TMPL_VAR NAME="cardnumber" --></li>
-	<li><span class="label">Borrowernumber: </span> <!-- TMPL_VAR NAME="borrowernumber" --></li>
     <li><span class="label">Category: </span><!-- TMPL_VAR NAME="description" --> (<!-- TMPL_VAR NAME="categorycode" -->)</li>
     <li><span class="label">Registration date: </span><!-- TMPL_VAR NAME="dateenrolled" --></li>
     
@@ -334,12 +418,12 @@ function validate1(date) {
     <!-- TMPL_IF NAME="opacnote"      --><li><span class="label">OPAC note:</span><!-- TMPL_VAR NAME="opacnote" --></li><!-- /TMPL_IF -->
 	</ol>
 	</div>
+	<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=3">Edit</a></div>
  </div>
-    <div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=3">Edit</a></div>
  
- <div id="patron-alternate-address" style="padding-top: 1em;">
+ <div id="patron-alternate-address">
     <h3>Alternate Address</h3>
-    <!-- TMPL_UNLESS NAME="I"--><!-- TMPL_UNLESS NAME="C"-->
+    <!-- TMPL_UNLESS NAME="I" --><!-- TMPL_UNLESS NAME="C" -->
     <div class="rows">  <ol><li><span class="label">Address: </span><!-- TMPL_VAR NAME="B_address" --></li>
       <li><span class="label">Address 2: </span><!-- TMPL_VAR NAME="B_address2" --></li>
       <li><span class="label">City, State: </span><!-- TMPL_VAR NAME="B_city" --></li>
@@ -355,10 +439,10 @@ function validate1(date) {
     <li><span class="label">Email: </span><!-- TMPL_VAR NAME="email" --></li>
     <li><span class="label">Relationship: </span><!-- TMPL_VAR NAME="relationship" --></li></ol></div>
    <!-- /TMPL_IF -->
+   <div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=6">Edit</a></div>
 </div>
-<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=6">Edit</a></div>
 
- <div id="patron-alternative-contact" style="padding-top: 1em;">
+ <div id="patron-alternative-contact">
  <h3>Alternative Contact</h3>	
    <div class="rows"> <ol><li><span class="label">Surname: </span><!-- TMPL_VAR NAME="altcontactsurname" --></li>
     <li><span class="label">First name: </span><!-- TMPL_VAR NAME="altcontactfirstname" --></li>    
@@ -368,23 +452,110 @@ function validate1(date) {
 	<li><span class="label">Zip/Postal Code: </span><!-- TMPL_VAR NAME="altcontactzipcode" --></li>
 	<li><span class="label">Country: </span><!-- TMPL_VAR NAME="altcontactcountry" --></li>
     <li><span class="label">Phone: </span><!-- TMPL_VAR NAME="altcontactphone" --></li></ol></div>
+    <div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=2">Edit</a></div>
 </div>
-<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=2">Edit</a></div>
 
-</div>
+</div><!-- patron details -->
 </div>
 
 <div id="finesholdsissues" class="toptabs">
 	<ul>
-		<li><a href="/cgi-bin/koha/members/moremember.pl#checkedout"><!-- TMPL_VAR NAME="issuecount"--> Checkout(s)</a></li>
+		<li><a href="/cgi-bin/koha/members/moremember.pl#checkedout"><!-- TMPL_VAR NAME="issuecount" --> Checkout(s)</a></li>
 		<li><a href="/cgi-bin/koha/members/moremember.pl#finesandcharges">Fines &amp; Charges</a></li>
-		<li><!-- TMPL_IF NAME="countreserv"-->
-            <a href="/cgi-bin/koha/members/moremember.pl#onhold"><!--TMPL_VAR NAME="countreserv"--> Hold(s)</a>
+		<li><!-- TMPL_IF NAME="countreserv" -->
+            <a href="/cgi-bin/koha/members/moremember.pl#onhold"><!-- TMPL_VAR NAME="countreserv" --> Hold(s)</a>
     <!-- TMPL_ELSE -->
             <a href="/cgi-bin/koha/members/moremember.pl#onhold">0 Holds</a>
-    <!-- /TMPL_IF --></li>
+    <!-- /TMPL_IF --></li><!-- patron suggestions -->
+    <li><a href="/cgi-bin/koha/members/moremember.pl#suggestions"><!-- TMPL_VAR NAME="countsuggestions" --> purchase suggestion(s)</a></li>
 	</ul>
+<!-- ###################### suggestions start ######################-->
+<div id="suggestions"><!-- TMPL_IF name="boolsuggestions" -->
+<form name="fallsuggestionforthisborrower" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#allsuggestionforthisborrower">
+<p><a id="CheckAll" href="javascript:;">Check All</a> | <a id="UncheckAll" href="javascript:;"">Uncheck All</a></p>
+    <table id="allsuggestionforthisborrowert">
+        <thead>
+            <tr><th>&nbsp;</th>
+            <th>Suggestion</th>
+            <th>Note</th>
+            <th>Suggested by /on</th>
+            <th>Managed by /on</th>
+            <th>Library</th>
+            <th>Budget</th>
+            <th>Status</th></tr>
+    </thead>
+        <tbody>
+        <!-- TMPL_LOOP Name="suggestions" --><!-- TMPL_LOOP NAME="suggestions_loop" -->
+            <!-- TMPL_IF name="even" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
+                <td>
+                    <input type="checkbox" name="edit_field" value="<!-- TMPL_VAR name="suggestionid" -->" />
+                </td>
+                <td>
+                    <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=<!-- TMPL_VAR NAME="suggestionid" -->&amp;op=edit&amp;returnsuggestedby=<!-- TMPL_VAR name="suggestedby" -->" title="suggestion" >
+                        <!-- TMPL_VAR NAME="title" ESCAPE="html" --><!-- TMPL_IF NAME="author" -->, by <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF -->
+                    </a>
+                    <br />
+                    <!-- TMPL_IF name="copyrightdate" -->&copy; <!-- TMPL_VAR name="copyrightdate" --> <!-- /TMPL_IF -->
+                        <!-- TMPL_IF name="volumedesc" -->; Volume:<i><!-- TMPL_VAR name="volumedesc" --></i> <!-- /TMPL_IF -->
+                        <!-- TMPL_IF name="isbn" -->; ISBN:<i><!-- TMPL_VAR name="isbn" --></i> <!-- /TMPL_IF --><!-- TMPL_IF name="publishercode" -->; Published by <!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --><!-- TMPL_IF name="publicationyear" --> in <i><!-- TMPL_VAR name="publicationyear" --></i> <!-- /TMPL_IF --><!-- TMPL_IF name="place" --> in <i><!-- TMPL_VAR name="place" --></i> <!-- /TMPL_IF --><!-- TMPL_IF name="collectiontitle" -->;<!-- TMPL_VAR name="collectiontitle" --> <!-- /TMPL_IF --><!-- TMPL_IF name="itemtype" -->;<!-- TMPL_VAR name="itemtype" --> <!-- /TMPL_IF --><br /><!-- TMPL_IF name="note" --><!-- TMPL VAR NAME="note" --><!-- /TMPL_IF -->
+                </td>
+                <td>
+                    <!-- TMPL_VAR name="note" -->
+                </td>
+                <td>
+                    <!-- TMPL_IF Name="emailsuggestedby" --><a href="mailto:<!-- TMPL_VAR name="emailsuggestedby" -->"><!-- /TMPL_IF --><!-- TMPL_VAR name="surnamesuggestedby" --><!-- TMPL_IF name="firstnamesuggestedby" -->, <!-- TMPL_VAR name="firstnamesuggestedby" --><!-- /TMPL_IF --> <!-- TMPL_IF Name="emailsuggestedby" --></a><!-- /TMPL_IF -->
+                    <!-- TMPL_IF Name="suggesteddate" --> / <!-- TMPL_VAR name="suggesteddate" --><!-- /TMPL_IF -->
+                </td>
+                <td>
+                    <!-- TMPL_IF Name="emailmanagedby" --><a href="mailto:<!-- TMPL_VAR name="emailmanagedby" -->"><!-- /TMPL_IF --><!-- TMPL_VAR name="surnamemanagedby" --><!-- TMPL_IF name="firstnamemanagedby" -->, <!-- TMPL_VAR name="firstnamemanagedby" --><!-- /TMPL_IF --> <!-- TMPL_IF Name="emailmanagedby" --></a><!-- /TMPL_IF -->
+                    <!-- TMPL_IF Name="manageddate" -->, <!-- TMPL_VAR name="manageddate" --><!-- /TMPL_IF -->
+                </td>
+                <td>
+                    <!-- TMPL_VAR name="branchcode" -->
+                </td>
+                <td>
+                    <!-- TMPL_VAR name="budget_name" -->
+                </td>
+                <td>
+                    <!-- TMPL_IF name="ASKED" -->Asked<!-- /TMPL_IF --> <!-- TMPL_IF name="ACCEPTED" -->Accepted<!-- /TMPL_IF --> <!-- TMPL_IF name="ORDERED" -->Ordered<!-- /TMPL_IF --> <!-- TMPL_IF name="REJECTED" -->Rejected<!-- /TMPL_IF --> <!-- TMPL_IF name="CHECKED" -->Checked<!-- /TMPL_IF --> <!-- TMPL_IF name="reason" --><br />(<!-- TMPL_VAR name="reason" -->)<!-- /TMPL_IF -->
+                </td>
+        </tr>
+        <!-- /TMPL_LOOP --><!-- /TMPL_LOOP -->
+        </tbody>
+        </table>
+
 	
+<div id="select-reasonallsuggestionforthisborrower">
+        <div id="statusallsuggestionforthisborrower">
+	<label for="STATUSallsuggestionforthisborrower">Mark selected as: </label><select name="STATUS" id="STATUSallsuggestionforthisborrower">
+	<option value=""> -- Choose a status --</option>
+	<option value="ASKED">Requested</option>
+	<option value="ACCEPTED">Accepted</option>
+	<option value="CHECKED">Checked</option>
+	<option value="REJECTED">Rejected</option>
+	</select>
+    <label for="reasonallsuggestionforthisborrower">with this reason:</label>                 <select id="reasonallsuggestionforthisborrower" name="reasonallsuggestionforthisborrower">
+                    <option value=""> -- Choose a reason -- </option>
+                        <!-- TMPL_LOOP Name="reasonsloop" -->
+                        <option value="<!-- TMPL_VAR Name="lib" -->"><!-- TMPL_VAR Name="lib" --></option>
+                        <!-- /TMPL_LOOP -->
+                    <option value="other">Others...</option>
+                    </select>   <span id="other_reasonallsuggestionforthisborrower">
+            <input type="text" size="31" id="select-other_reasonallsuggestionforthisborrower" name="other_reasonallsuggestionforthisborrower" value="please note your reason here" /> <a href="#backallsuggestionforthisborrower">Cancel</a>
+        </span> <strong style="padding: 0 1em;">OR:</strong> <label for="allsuggestionforthisborrowerdelete">Delete selected</label> <input type="checkbox" name="op" id="allsuggestionforthisborrowerdelete" />
+        </div>
+        </div>
+
+<input type="hidden" name="returnsuggested" id="returnsuggested" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
+    <input type="hidden" name="tabcode" value="allsuggestionforthisborrower" />
+    <input type="hidden" name="op" value="change" />
+</fieldset>
+        <fieldset class="action">
+    <input type="submit" value="Submit" /></fieldset>
+</form>
+<!-- TMPL_ELSE -->Patron has no suggestions.<!-- /TMPL_IF -->
+</div>
+<!-- ###################### suggestions end ######################-->
 <div id="finesandcharges">
     <!-- TMPL_IF NAME="totaldue_raw" -->
         <p>Total due: <!-- TMPL_VAR NAME="totaldue" --></p>
@@ -403,15 +574,53 @@ function validate1(date) {
 		<tr>
             <th scope="col">Due date</th>
             <th scope="col">Title</th>
+            <th scope="col">Collection</th>
+            <th scope="col">Stock number</th>
+            <th scope="col">Barcode</th>
             <th scope="col">Item Type</th>
             <th scope="col">Checked out on</th> 
+            <!-- TMPL_IF NAME="multiple_borrowers" --><th scope="col">Borrower</th><!-- /TMPL_IF -->
         <th scope="col">Call no</th>
             <th scope="col">Charge</th>
             <th scope="col">Price</th>
             <th scope="col">Renew <p class="column-tool"><a href="#" id="CheckAllitems">select all</a> | <a href="#" id="CheckNoitems">none</a></p></th>
             <th scope="col">Check in <p class="column-tool"><a href="#" id="CheckAllreturns">select all</a> | <a href="#" id="CheckNoreturns">none</a></p></th>
-        </tr></thead>
-        <!-- TMPL_INCLUDE NAME="checkouts-table-footer.inc" -->
+        </tr>
+    </thead>
+    	<tfoot>
+		<tr>
+            <td colspan="<!-- TMPL_IF NAME="multiple_borrowers" -->9<!-- TMPL_ELSE -->8<!-- /TMPL_IF -->" style="text-align: right; font-weight:bold;">Totals:</td>
+			<td><!-- TMPL_VAR NAME="totaldue" --></td>
+            <td><!-- TMPL_VAR NAME="totalprice" --></td>
+            <td colspan="2">      
+                <p>
+                    Renewal due date: <input type="text" size="8" id="newduedate" name="newduedate" value="<!-- TMPL_VAR Name="newduedate" -->" />
+                    <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="newduedate_button" alt="Show Calendar" />
+                    <script type="text/javascript">
+                        //<![CDATA[
+                        Calendar.setup({
+                            inputField : "newduedate",
+                            ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+                            button : "newduedate_button"
+                        });
+                        //]]>
+                    </script>
+				<span style="display:block;color:#666;font-weight:normal;font-size:90%;"><!-- TMPL_INCLUDE NAME="date-format.inc" --></span>
+                </p>
+                <p>
+                    <label for="exemptfine">Forgive fines on return: </label><input type="checkbox" name="exemptfine" value="1" />
+                </p>
+                <!-- TMPL_IF NAME="CAN_user_circulate_override_renewals" -->
+                <!-- TMPL_IF NAME="AllowRenewalLimitOverride" -->
+                <p>
+                    <label for="override_limit">Override Renewal Limit:</label>
+                    <input type="checkbox" name="override_limit" id="override_limit" value="1" />
+                </p>
+                <!-- /TMPL_IF -->
+                <!-- /TMPL_IF -->
+                </td>
+        </tr>
+		</tfoot>
        <tbody>
        <!-- TMPL_LOOP name="issueloop" -->
 
@@ -428,30 +637,41 @@ function validate1(date) {
                                         <span class="dmg"><!-- TMPL_VAR NAME="itemdamaged" --></span>
                 <!-- /TMPL_IF -->
 </td>
-            <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><strong><!-- TMPL_VAR NAME="title" escape="html" --></strong></a><!-- TMPL_IF NAME="author" -->, by <!-- TMPL_VAR name="author" --><!-- /TMPL_IF --> <!-- TMPL_IF name="publishercode" -->; <!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --> <!-- TMPL_IF name="publicationyear" -->, <!-- TMPL_VAR name="publicationyear" --><!-- /TMPL_IF --> <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->#item<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a></td>
+            <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><strong><!-- TMPL_VAR NAME="title" escape="html" --></strong></a><!-- TMPL_IF NAME="author" -->, by <!-- TMPL_VAR name="author" --><!-- /TMPL_IF --> <!-- TMPL_IF name="publishercode" -->; <!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --> <!-- TMPL_IF name="publicationyear" -->, <!-- TMPL_VAR name="publicationyear" --><!-- /TMPL_IF --></td>
+            <td><!-- TMPL_VAR NAME="collection" --></td>
+            <td><!-- TMPL_VAR NAME="stocknumber" --></td>
+            <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->#item<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a></td>
 <td><!-- TMPL_UNLESS NAME="noItemTypeImages" --> <!-- TMPL_IF NAME="itemtype_image" --><img src="<!-- TMPL_VAR NAME="itemtype_image" -->" alt="" /><!-- /TMPL_IF --><!-- /TMPL_UNLESS --><!-- TMPL_VAR NAME="itemtype_description" --></td>
             <td><!-- TMPL_VAR NAME="issuedate" --></td>
+            <!-- TMPL_IF NAME="multiple_borrowers" --><td><!-- TMPL_VAR NAME="borrowername" --></td><!-- /TMPL_IF -->
 	        <td><!-- TMPL_VAR NAME="itemcallnumber" --></td>
             <td><!-- TMPL_VAR NAME="charge" --></td>
             <td><!-- TMPL_VAR NAME="replacementprice" --></td>
       <!-- TMPL_IF NAME="renew_failed" -->
             <td class="problem">Renewal Failed</td>
       <!-- TMPL_ELSE -->
-            <td><span style="padding: 0 1em;"><!-- TMPL_IF NAME="renewals" --><!-- TMPL_VAR NAME="renewals" --><!-- TMPL_ELSE -->0<!-- /TMPL_IF --></span>
+            <td style="text-align : center"><span style="padding: 0 1em;">
+            <!-- TMPL_IF Name="norenew_reason_too_many" --><span class="problem"><!-- /TMPL_IF -->
+            <!-- TMPL_VAR NAME="renewals" -->/<!-- TMPL_VAR NAME="renewalsallowed" -->
+            <!-- TMPL_IF Name="norenew_reason_too_many" --></span><!-- /TMPL_IF -->
+                </span>
             <!-- TMPL_IF name="norenew" -->
                 <!-- TMPL_IF NAME="can_confirm" --><span class="renewals-allowed" style="display: none">
-                    <input type="checkbox" name="all_items[]" value="<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" style="display: none;" />
                     <!-- TMPL_IF NAME="od" -->
                         <input type="checkbox" name="items[]" value="<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" />
                     <!-- TMPL_ELSE -->
                         <input type="checkbox" name="items[]" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
                     <!-- /TMPL_IF -->
                     </span>
-                    <span class="renewals-disabled">
+                    <br/>
+                    <span class="renewals-disabled problem">
                 <!-- /TMPL_IF -->
                 <!-- TMPL_IF NAME="norenew_reason_on_reserve" -->
-                <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">On Hold</a>
+                        On Hold
                 <!-- /TMPL_IF -->
+				    <!-- TMPL_IF NAME="norenew_reason_overdue" -->
+				        Overdue
+				    <!-- /TMPL_IF -->
 				    <!-- TMPL_IF NAME="norenew_reason_too_many" -->
 				        Not Renewable
 				    <!-- /TMPL_IF -->
@@ -459,7 +679,6 @@ function validate1(date) {
                     </span>
                 <!-- /TMPL_IF -->
             <!-- TMPL_ELSE -->
-            <input type="checkbox" name="all_items[]" value="<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" style="display: none;" />
             <!-- TMPL_IF NAME="red" -->
             <input type="checkbox" name="items[]" value="<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" onclick="uncheck_sibling(this);" />
             <!-- TMPL_ELSE -->
@@ -470,9 +689,9 @@ function validate1(date) {
       <!-- /TMPL_IF -->
       <!-- TMPL_IF NAME="return_failed" -->
             <td class="problem">Checkin Failed</td>
-      <!--TMPL_ELSE-->
-            <td><input type="checkbox" name="barcodes[]"  value="<!-- TMPL_VAR NAME="barcode" -->" onclick="uncheck_sibling(this);" />
-                <input type="checkbox" name="all_barcodes[]" value="<!-- TMPL_VAR NAME="barcode" -->" checked="checked" style="display: none;" />
+      <!-- TMPL_ELSE -->
+            <td style="text-align:center;"><input type="checkbox" name="barcodes[]"  value="<!-- TMPL_VAR NAME="barcode" -->" onclick="uncheck_sibling(this);" />
+                <!-- TMPL_IF Name="reserved" --><br/><a href="javascript:void(0);" onclick="window.open('/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->')">On Hold</a><!-- /TMPL_IF -->
             </td>
       <!-- /TMPL_IF -->
         </tr>
@@ -480,16 +699,62 @@ function validate1(date) {
         </tbody>
         </table>
         <fieldset class="action">
-        <!-- TMPL_IF NAME="CAN_user_circulate_override_renewals" -->
-        <!-- TMPL_IF NAME="AllowRenewalLimitOverride" -->
-        <label for="override_limit">Override Renewal Limit:</label>
-        <input type="checkbox" name="override_limit" id="override_limit" value="1" />
-        <!-- /TMPL_IF -->
-        <!-- /TMPL_IF -->
         <input type="submit" name="renew_checked" value="Renew or Return checked items" />
         <input type="submit" id="renew_all" name="renew_all" value="Renew all" />
         </fieldset>
     </form><!-- TMPL_ELSE --><p>Patron has nothing checked out.</p><!-- /TMPL_IF -->
+
+<!-- TMPL_IF NAME="relissuecount" -->
+	<h2>Relatives issues</h2>
+ <table id="relissuest">
+    <thead>
+	<tr>
+            <th scope="col">Due date</th>
+            <th scope="col">Title</th>
+            <th scope="col">Collection</th>
+            <th scope="col">Stock number</th>
+            <th scope="col">Barcode</th>
+            <th scope="col">Item Type</th>
+            <th scope="col">Checked out on</th> 
+            <th scope="col">Borrower</th>
+	    <th scope="col">Call no</th>
+            <th scope="col">Charge</th>
+            <th scope="col">Price</th>
+        </tr>
+    </thead>
+       <tbody>
+       <!-- TMPL_LOOP name="relissueloop" -->
+
+          <!-- TMPL_IF name="overdue" -->
+          <tr class="problem">
+          <!-- TMPL_ELSE -->
+          <tr>
+          <!-- /TMPL_IF -->
+          <!-- TMPL_IF NAME="red" --> 
+		  <td class="od"><!--TMPL_ELSE--><td><!--/TMPL_IF-->
+          <!-- TMPL_VAR NAME="date_due" -->
+                <!-- TMPL_IF NAME="itemlost" -->
+                                        <span class="lost"><!-- TMPL_VAR NAME="itemlost" --></span>
+                    <!-- /TMPL_IF -->
+                <!-- TMPL_IF NAME="damaged" -->
+                                        <span class="dmg"><!-- TMPL_VAR NAME="itemdamaged" --></span>
+                <!-- /TMPL_IF -->
+</td>
+            <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><strong><!-- TMPL_VAR NAME="title" escape="html" --></strong></a><!-- TMPL_IF NAME="author" -->, by <!-- TMPL_VAR name="author" --><!-- /TMPL_IF --> <!-- TMPL_IF name="publishercode" -->; <!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF --> <!-- TMPL_IF name="publicationyear" -->, <!-- TMPL_VAR name="publicationyear" --><!-- /TMPL_IF --></td>
+            <td><!-- TMPL_VAR NAME="collection" --></td>
+            <td><!-- TMPL_VAR NAME="stocknumber" --></td>
+            <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->#item<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a></td>
+<td><!-- TMPL_UNLESS NAME="noItemTypeImages" --> <!-- TMPL_IF NAME="itemtype_image" --><img src="<!-- TMPL_VAR NAME="itemtype_image" -->" alt="" /><!-- /TMPL_IF --><!-- /TMPL_UNLESS --><!-- TMPL_VAR NAME="itemtype_description" --></td>
+            <td><!-- TMPL_VAR NAME="issuedate" --></td>
+	    <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowername" --></a></td>
+	        <td><!-- TMPL_VAR NAME="itemcallnumber" --></td>
+            <td><!-- TMPL_VAR NAME="charge" --></td>
+            <td><!-- TMPL_VAR NAME="replacementprice" --></td>
+        </tr>
+  <!-- /tmpl_loop -->
+        </tbody>
+       </table>
+<!-- /TMPL_IF -->
 	</div>
 	
 <div id="onhold">
@@ -512,20 +777,23 @@ function validate1(date) {
                 <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a><!-- TMPL_IF NAME="author" -->, by <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF -->
             </td>
             <td><!-- TMPL_VAR NAME="itemcallnumber" --></td>
-            <td><!-- TMPL_IF name="waiting" -->
-                <em>Item is <strong>waiting</strong></em>
+            <td> <em> Item <!-- TMPL_IF name="barcodereserv" -->
+                <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="barcodereserv" --></a>
+                <!-- /TMPL_IF -->
+                <!-- TMPL_IF name="waiting" -->
+                 is <strong>waiting</strong> until <!-- TMPL_VAR NAME="formattedwaitingdate" -->
                 <!-- /TMPL_IF -->
                 <!-- TMPL_IF name="transfered" -->
-                <em>Item <strong>in transit</strong> from
-                <!-- TMPL_VAR NAME="frombranch" --> since <!-- TMPL_VAR NAME="datesent" --> </em>
+                <strong>in transit</strong> from
+                <!-- TMPL_VAR NAME="frombranch" --> since <!-- TMPL_VAR NAME="datesent" --> 
                 <!-- /TMPL_IF -->
-
                 <!-- TMPL_IF name="nottransfered" -->
                 <em>Item hasn't been transferred yet from <!-- TMPL_VAR NAME="nottransferedby" --></em>
                 <!-- /TMPL_IF -->
                 <!-- TMPL_IF name="barcodereserv" -->
                 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="barcodereserv" --></a>
                 <!-- /TMPL_IF -->
+		</em>
             </td>
             <td><!-- TMPL_IF NAME="waitingposition" --><strong><!-- TMPL_VAR NAME="waitingposition" --></strong><!-- /TMPL_IF --></td>
             <td><select name="rank-request">
@@ -534,6 +802,7 @@ function validate1(date) {
                 </select>
                 <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblionumber" -->" />
                 <input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR name="borrowernumber" -->" />
+		<input type="hidden" name="reservenumber" value="<!-- TMPL_VAR name="reservenumber" -->" />
             </td>
         </tr>
 		<!-- /TMPL_LOOP --></tbody>
diff --git a/members/moremember.pl b/members/moremember.pl
index beec293..b8922d6 100755
--- a/members/moremember.pl
+++ b/members/moremember.pl
@@ -34,21 +34,30 @@
 use strict;
 #use warnings; FIXME - Bug 2505
 use CGI;
+use YAML;
 use C4::Context;
 use C4::Auth;
 use C4::Output;
 use C4::Members;
 use C4::Members::Attributes;
 use C4::Members::AttributeTypes;
-use C4::Dates;
+use C4::Dates qw(format_date);
 use C4::Reserves;
 use C4::Circulation;
 use C4::Koha;
 use C4::Letters;
 use C4::Biblio;
-use C4::Reserves;
+use C4::Items;
+use C4::Suggestions;
+use C4::Budgets;
+use C4::Search;
+use C4::Dates qw(format_date);
+use C4::Debug;
 use C4::Branch; # GetBranchName
 use C4::Form::MessagingPreferences;
+use C4::Overdues qw/CheckBorrowerDebarred/;
+use JSON;
+use List::MoreUtils qw/uniq/;
 
 #use Smart::Comments;
 #use Data::Dumper;
@@ -67,11 +76,13 @@ my $print = $input->param('print');
 my $override_limit = $input->param("override_limit") || 0;
 my @failedrenews = $input->param('failedrenew');
 my @failedreturns = $input->param('failedreturn');
+my @renewerrors   = $input->param('renewerror');    # expected to be json
+my @returnerrors  = $input->param('returnerror');   # expected to be json
 my $error = $input->param('error');
 my %renew_failed;
-for my $renew (@failedrenews) { $renew_failed{$renew} = 1; }
 my %return_failed;
-for my $failedret (@failedreturns) { $return_failed{$failedret} = 1; }
+for (@failedrenews) { $renew_failed{$_} = decode_json(shift @renewerrors); }
+for (@failedreturns) { $return_failed{GetItemnumberFromBarcode($_)} = decode_json(shift @returnerrors); }
 
 my $template_name;
 my $quickslip = 0;
@@ -143,12 +154,20 @@ foreach (qw(dateenrolled dateexpiry dateofbirth)) {
 		$data->{$_} = $userdate || '';
 		$template->param( $_ => $userdate );
 }
-$data->{'IS_ADULT'} = ( $data->{'categorycode'} ne 'I' );
 
-for (qw(debarred gonenoaddress lost borrowernotes)) {
+for (qw(gonenoaddress lost borrowernotes)) {
 	 $data->{$_} and $template->param(flagged => 1) and last;
 }
 
+my $debar = CheckBorrowerDebarred($borrowernumber);
+if($debar){
+    $template->param(userdebarred => 1,flagged=>1);
+    if( $debar ne "9999-12-31"){
+        $template->param(userdebarreddate => C4::Dates::format_date($debar));
+        $template->param(debarredcomment => $data->{debarredcomment});
+    }
+}
+
 $data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} );
 $data->{ "sex_".$data->{'sex'}."_p" } = 1;
 
@@ -190,10 +209,10 @@ if ( $category_type eq 'A' || $category_type eq 'I') {
             }
         );
     }
+    warn Data::Dumper::Dumper(@guaranteedata);
     $template->param( guaranteeloop => \@guaranteedata );
     ( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' );
 }
-else {
     if ($data->{'guarantorid'}){
 	    my ($guarantor) = GetMember( 'borrowernumber' =>$data->{'guarantorid'});
 		$template->param(guarantor => 1);
@@ -204,7 +223,6 @@ else {
 	if ($category_type eq 'C'){
 		$template->param('C' => 1);
 	}
-}
 
 my %bor;
 $bor{'borrowernumber'} = $borrowernumber;
@@ -232,16 +250,28 @@ $template->param( lib2 => $lib2 ) if ($lib2);
 
 # current issues
 #
-my $issue = GetPendingIssues($borrowernumber);
-my $issuecount = scalar(@$issue);
+my @borrowernumbers = GetMemberRelatives($borrowernumber);
+push @borrowernumbers, $borrowernumber;
+my $issue       = GetPendingIssues(@borrowernumbers);
+my $issuecount  = scalar(@$issue);
 my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} );
 my $today       = POSIX::strftime("%Y-%m-%d", localtime);	# iso format
 my @issuedata;
+my @borrowers_with_issues;
 my $overdues_exist = 0;
 my $totalprice = 0;
 for ( my $i = 0 ; $i < $issuecount ; $i++ ) {
-    my $datedue = $issue->[$i]{'date_due'};
-    my $issuedate = $issue->[$i]{'issuedate'};
+
+    # Getting borrower details
+    my $memberdetails = GetMemberDetails($issue->[$i]{'borrowernumber'});
+    $issue->[$i]{'borrowername'} = $memberdetails->{'firstname'} . " " . $memberdetails->{'surname'};
+
+    # Adding this borrower to the list of borrowers with issue
+    push @borrowers_with_issues, $issue->[$i]{'borrowernumber'};
+
+    my $datedue    = $issue->[$i]{'date_due'};
+    my $issuedate  = $issue->[$i]{'issuedate'};
+    my $itemnumber = $issue->[$i]{'itemnumber'};
     $issue->[$i]{'date_due'}  = C4::Dates->new($issue->[$i]{'date_due'}, 'iso')->output('syspref');
     $issue->[$i]{'issuedate'} = C4::Dates->new($issue->[$i]{'issuedate'},'iso')->output('syspref');
     my $biblionumber = $issue->[$i]{'biblionumber'};
@@ -282,23 +312,65 @@ for ( my $i = 0 ; $i < $issuecount ; $i++ ) {
 
     #find the charge for an item
     my ( $charge, $itemtype ) =
-      GetIssuingCharges( $issue->[$i]{'itemnumber'}, $borrowernumber );
+      GetIssuingCharges( $itemnumber, $borrowernumber );
 
     my $itemtypeinfo = getitemtypeinfo($itemtype);
     $row{'itemtype_description'} = $itemtypeinfo->{description};
     $row{'itemtype_image'}       = $itemtypeinfo->{imageurl};
 
+    # find the collection of an item
+    my $collection;
+    my $authvals = GetAuthorisedValues('CCODE');
+    for ( @$authvals ) {
+        $collection = $_->{'lib'} if $_->{'authorised_value'} eq $row{'ccode'}
+    }
+    $row{'collection'} = $collection;
+
     $row{'charge'} = sprintf( "%.2f", $charge );
 
-	my ( $renewokay,$renewerror ) = CanBookBeRenewed( $borrowernumber, $issue->[$i]{'itemnumber'}, $override_limit );
-	$row{'norenew'} = !$renewokay;
-	$row{'can_confirm'} = ( !$renewokay && $renewerror ne 'on_reserve' );
-	$row{"norenew_reason_$renewerror"} = 1 if $renewerror;
-	$row{'renew_failed'}  = $renew_failed{ $issue->[$i]{'itemnumber'} };
-	$row{'return_failed'} = $return_failed{$issue->[$i]{'barcode'}};   
-    push( @issuedata, \%row );
+	my ( $renewokay,$renewerror ) = CanBookBeRenewed( $borrowernumber, $itemnumber);
+    if (defined $renewerror->{message}){
+            $row{"norenew_reason_".$renewerror->{message}} = 1;
+		    $row{'norenew'} = 1;
+    }
+    $row{$_} = $renewerror->{$_} for (qw(renewals renewalsallowed reserves));
+    $row{renewals} = $issue->[$i]{renewals};
+    $row{renewals} ||= 0;
+    my ( $restype, $reserves ) = CheckReserves( $issue->[$i]->{'itemnumber'} );
+    if ($restype){
+		    $row{'reserved'} = 1;
+            $row{$restype}=1
+    }
+	$row{'can_confirm'} = $row{'norenew'} && C4::Context->preference("AllowRenewalLimitOverride");#( !$renewokay && $renewerror->{message} ne 'on_reserve' );
+	$row{'renew_failed'}  = defined($renew_failed{ $itemnumber });
+	$row{'return_failed'} = defined($return_failed{$itemnumber});   
+    if ($row{'return_failed'}){
+            $row{'return_error_'.$return_failed{$issue->[$i]->{'itemnumber'}}->{message}}=1;
+            delete $return_failed{$issue->[$i]->{'itemnumber'}};
+    }
+    if ( $row{'renew_failed'}){
+            $row{'norenew_reason_'.$renew_failed{$issue->[$i]->{'itemnumber'}}->{message}}=1;
+    }
+ push( @issuedata, \%row );
+}
+
+# If we have more than one borrower, we display their names
+ at borrowers_with_issues = uniq @borrowers_with_issues;
+$template->param('multiple_borrowers' => 1) if (@borrowers_with_issues > 1);
+
+
+#BUILDS the LOOP for reserves when returning books with reserves
+my @reserveswaiting;
+foreach my $itemnumber (keys %return_failed){
+   next unless $return_failed{$itemnumber}->{'reservesdata'};
+   my $hashdata=$return_failed{$itemnumber}->{'reservesdata'};
+   $hashdata->{circborrowernumber}=$borrowernumber;
+   $hashdata->{script_name}=$input->script_name();
+   push @reserveswaiting, $hashdata if (%$hashdata);
 }
 
+$template->param(reserves_waiting=>\@reserveswaiting);
+
 ### ###############################################################################
 # BUILD HTML
 # show all reserves of this borrower, and the position of the reservation ....
@@ -329,6 +401,9 @@ if ($borrowernumber) {
         if ( $num_res->{'found'} eq 'W' ) {
             $getreserv{color}   = 'reserved';
             $getreserv{waiting} = 1;
+            my @maxpickupdate = $num_res->{'waitingdate'} ? GetMaxPickupDate( $num_res->{'waitingdate'}, $borrowernumber, $num_res ) : '';
+            $getreserv{'maxpickupdate'} = sprintf( "%d-%02d-%02d", @maxpickupdate );
+            $getreserv{'formattedwaitingdate'} = format_date( $getreserv{'maxpickupdate'} );
         }
 
         # 		check transfers with the itemnumber foud in th reservation loop
@@ -359,6 +434,7 @@ if ($borrowernumber) {
             $getreserv{biblionumber}  = $num_res->{'biblionumber'};	
         }
         $getreserv{waitingposition} = $num_res->{'priority'};
+        $getreserv{reservenumber}    = $num_res->{'reservenumber'};	
 
         push( @reservloop, \%getreserv );
     }
@@ -369,6 +445,68 @@ if ($borrowernumber) {
 	 );
 }
 
+#######################################
+# SUGGESTIONS
+# manage borrowers suggestions
+sub GetCriteriumDesc {
+    my ( $criteriumvalue, $displayby ) = @_;
+    return ( $criteriumvalue eq 'ASKED' ? "Pending" : ucfirst( lc($criteriumvalue) ) ) if ( $displayby =~ /status/i );
+    return ( GetBranchName($criteriumvalue) )  if ( $displayby =~ /branchcode/ );
+    return ( GetSupportName($criteriumvalue) ) if ( $displayby =~ /itemtype/ );
+    if ( $displayby =~ /managedby/ || $displayby =~ /acceptedby/ || $displayby =~ /suggestedby/) {
+        my $borr = C4::Members::GetMember( borrowernumber => $criteriumvalue );
+        return "" unless $borr;
+        return $$borr{firstname} . ", " . $$borr{surname};
+    }
+    if ( $displayby =~ /budgetid/) {
+        my $budget = GetBudget($criteriumvalue);
+        return "" unless $budget;
+        return $$budget{budget_name};
+    }
+}
+    my $suggestion_ref={"suggestedby"=>$borrowernumber};
+    my $displayby = "STATUS";
+    my $criteria_list = GetDistinctValues( "suggestions." . $displayby );
+    my @allsuggestions;
+    my $countsuggestions=0;
+    my $reasonsloop = GetAuthorisedValues("SUGGEST");
+    foreach my $criteriumvalue ( map { $$_{'value'} } @$criteria_list ) {
+        my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne "";
+
+        next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue );
+        $$suggestion_ref{$displayby} = $criteriumvalue;
+
+        #        warn $$suggestion_ref{$displayby}."=$criteriumvalue; $displayby";
+        #warn "===========================================";
+        #warn Data::Dumper::Dumper($suggestion_ref);
+        my $suggestions = &SearchSuggestion($suggestion_ref);
+        foreach my $suggestion (@$suggestions) {
+            $suggestion->{budget_name} = GetBudget( $suggestion->{budgetid} )->{budget_name} if $suggestion->{budgetid};
+            foreach my $date qw(suggesteddate manageddate accepteddate) {
+                if ( $suggestion->{$date} ne "0000-00-00" && $suggestion->{$date} ne "" ) {
+                    $suggestion->{$date} = format_date( $suggestion->{$date} );
+                } else {
+                    $suggestion->{$date} = "";
+                }
+            }
+            $countsuggestions++;
+        }
+push @allsuggestions,
+          { "suggestiontype" => $criteriumvalue || "suggest",
+            "suggestiontypelabel" => GetCriteriumDesc( $criteriumvalue, $displayby ) || "",
+            "suggestionscount"    => scalar(@$suggestions),
+            'suggestions_loop'    => $suggestions,
+            'reasonsloop'         => $reasonsloop,
+          };
+        delete $$suggestion_ref{$displayby} unless $definedvalue;
+    }
+        if($countsuggestions>0)
+        {
+        	$template->param("boolsuggestions" => 1);
+        }
+$template->param("suggestions" => \@allsuggestions, "countsuggestions"=>$countsuggestions);
+# SUGGESTIONS : end
+
 # current alert subscriptions
 my $alerts = getalert($borrowernumber);
 foreach (@$alerts) {
@@ -398,7 +536,7 @@ $template->param( picture => 1 ) if $picture;
 
 my $branch=C4::Context->userenv->{'branch'};
 
-$template->param($data);
+SetMemberInfosInTemplate($borrowernumber, $template);
 
 if (C4::Context->preference('ExtendedPatronAttributes')) {
     $template->param(ExtendedPatronAttributes => 1);
-- 
1.7.1



More information about the Koha-patches mailing list