[Koha-patches] [PATCH 12/54] MT2263 Change debarring system

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


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

    Now when a user is debarred, you set a end date, and can put a comment.
    This patch is the first, it need some improvement, but works globaly well.
    If an overdue generate a debar, the debar date is set to 9999-12-31.

    show debar date on member detail
    This patch show debar date, if the member is debarred, and he have a valid date(not unlimited debar).

    add debar date in circulation
    This patch add the debar date if it's not unlimited, in circulation.pl

    rework on member edition
    This change the way to edit user debar date/comment, to follow nicolas' mockup.

    (bug #MT2263) fix functions for debarring

    this fix ismemberblock and patronflags for new debarring system

    Signed-off-by: Henri-Damien LAURENT <henridamien.laurent at biblibre.com>

MT4096: Adults can also be added to an organization

MT4584 Add duplicate support for borrowers
---
 .../prog/en/modules/members/memberentrygen.tmpl    |  191 ++++++++++++++------
 members/memberentry.pl                             |   60 +++++--
 members/setdebar.pl                                |   61 -------
 members/setstatus.pl                               |   13 +-
 4 files changed, 188 insertions(+), 137 deletions(-)
 delete mode 100755 members/setdebar.pl

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl
index 4ecc0cb..4c455d7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl
@@ -1,11 +1,13 @@
 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
 <title>Koha &rsaquo; Patrons &rsaquo; 
-<!-- TMPL_IF NAME="opadd" -->	Add<!-- TMPL_ELSE --> Modify<!--/TMPL_IF--> <!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF --><!--TMPL_UNLESS Name="opadd"--> <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!--/TMPL_UNLESS--></title>
+<!-- TMPL_IF NAME="opadd" -->	Add<!-- TMPL_ELSIF NAME="opduplicate" -->Duplicate<!-- TMPL_ELSE --> Modify<!--/TMPL_IF--> <!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF --><!--TMPL_UNLESS Name="opadd"--> <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!--/TMPL_UNLESS--></title>
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
 <script type="text/JavaScript" language="JavaScript">
 //<![CDATA[
     $(document).ready(function() {
+
+
 		$("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
         $("#guarantordelete").click(function() {
             $("#contact-details").hide().find('a').remove();
@@ -21,8 +23,41 @@
             document.form.zipcode.value=RegExp.$1;
             document.form.city.value=RegExp.$2;
         });
-    });
+        
+        $(":radio[name='debarred']").change(function(){
+	    	if(this.value == 1){
+	        	$('.debarred').removeAttr('disabled');
+	    	}else{
+	    		$('.debarred').attr('disabled','disabled');
+	    	}
+        });
+
+	if($(":radio:checked[name='debarred']").val() == 1){
+        	$('.debarred').removeAttr('disabled');
+    	}else{
+		$('.debarred').attr('disabled','disabled');
+    	}
+    
 
+	$(":radio[name='gonenoaddress']").change(function(){
+	    	if (this.value == 1){ 
+		    $('.classgonenoaddress').show();
+	    	}else{
+		    $('.classgonenoaddress').hide();
+	    	}
+        });
+	if($(":radio:checked[name='gonenoaddress']").val() == 0){ $('.classgonenoaddress').hide() };
+    
+	$(":radio[name='lost']").change(function(){
+	    	if (this.value == 1){ 
+		    $('.classlost').show();
+	    	}else{
+		    $('.classlost').hide();
+	    	}
+        });
+	if($(":radio:checked[name='lost']").val() == 0){ $('.classlost').hide() };
+   }); 
+    	
     function clear_entry(node) {
         var original = node.parentNode.parentNode;
         $("input[type=text]", original).attr('value', '');
@@ -71,9 +106,9 @@
 		Add<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
 <!-- TMPL_VAR NAME="surname" --> <!-- TMPL_VAR name="firstname" -->
 <!-- TMPL_ELSE --> 
-<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" --></a> &rsaquo; <strong>Modify<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
+<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" --></a> &rsaquo; <strong><!-- TMPL_IF NAME="opduplicate" -->Duplicate<!-- TMPL_ELSE -->Modify<!--/TMPL_IF --><!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
 </strong><!-- /TMPL_IF --></div>
-
+<!-- TMPL_IF NAME="opduplicate" -->tast<!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="opadd" --><div id="doc" class="yui-t7"><!-- TMPL_ELSE --><div id="doc3" class="yui-t2"><!-- /TMPL_IF -->
    
    <div id="bd">
@@ -87,7 +122,7 @@
 	</h1>
 	<!-- TMPL_ELSE -->
 	<h1>
-		Modify<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
+		<!-- TMPL_IF NAME="opduplicate" -->Duplicate<!-- TMPL_ELSE -->Modify<!--/TMPL_IF --><!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF -->
 <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" --> 
 	</h1>
 	<!-- /TMPL_IF -->
@@ -156,9 +191,10 @@
 <input type="hidden" name="select_roadtype" value="<!-- TMPL_VAR NAME="select_roadtype" -->" />
 <input type="hidden" name="destination" value="<!-- TMPL_VAR NAME="destination" -->" />
 <input type="hidden" name="check_member" value="<!-- TMPL_VAR NAME="check_member" -->" />
-<input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
+<input type="hidden" name="borrowernumber" value="<!-- TMPL_IF NAME="opduplicate" --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="borrowernumber" --><!-- /TMPL_IF -->" />
+<input type="hidden" name="nodouble"  value="<!-- TMPL_IF NAME="opduplicate" --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="nodouble" --><!-- /TMPL_IF -->" />
 <!--TMPL_IF Name="step"--><input type="hidden" name="step"  value="<!-- TMPL_VAR NAME="step" -->" /><!--/TMPL_IF-->
-<!-- TMPL_IF NAME="opadd" --><input type="hidden" name="op" value="insert" /><!-- TMPL_ELSE --><input type="hidden" name="op" value="save" /><!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="opadd" --><input type="hidden" name="op" value="insert" /><!-- TMPL_ELSIF NAME="opduplicate" --><input type="hidden" name="op" value="insert" /><!-- TMPL_ELSE --><input type="hidden" name="op" value="save" /><!-- /TMPL_IF -->
 
 <!--TMPL_IF Name="step_1"-->
 	<fieldset class="rows" id="memberentry_identity">
@@ -186,9 +222,9 @@
 		<!-- /TMPL_IF-->
 		Surname: </label>
 		<!-- TMPL_IF NAME="uppercasesurnames" -->
-		<input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="<!-- TMPL_VAR NAME="surname" -->" />
+		<input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="<!-- TMPL_VAR NAME="surname" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 		<!-- TMPL_ELSE -->
-		<input type="text" id="surname" name="surname" size="20"  value="<!-- TMPL_VAR NAME="surname" -->" />
+		<input type="text" id="surname" name="surname" size="20"  value="<!-- TMPL_VAR NAME="surname" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 		<!-- /TMPL_IF -->
 		<!-- TMPL_IF NAME="mandatorysurname" --><span class="required">Required</span><!-- /TMPL_IF -->
 		</li>
@@ -200,7 +236,7 @@
                 <label for="firstname">
                 <!-- /TMPL_IF-->
                 First name: </label>
-                <input type="text" id="firstname" name="firstname" size="20"  value="<!-- TMPL_VAR NAME="firstname" -->" />
+                <input type="text" id="firstname" name="firstname" size="20"  value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="firstname" --><!-- /TMPL_IF -->" />
                 <!-- TMPL_IF NAME="mandatoryfirstname" --><span class="required">Required</span><!-- /TMPL_IF -->
             </li>
             <li>
@@ -212,9 +248,9 @@
                 Date of birth: </label>
 				
 	<!-- TMPL_IF NAME="metric" -->			
-                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth);" value="<!-- TMPL_VAR NAME="dateofbirth" -->" />
+                <input type="text" id="dateofbirth" name="dateofbirth" size="20" onchange="CheckDate(document.form.dateofbirth);" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="dateofbirth" --><!-- /TMPL_IF -->" />
 <!-- TMPL_ELSE -->
-                <input type="text" id="dateofbirth" name="dateofbirth" size="20" value="<!-- TMPL_VAR NAME="dateofbirth" -->" />
+                <input type="text" id="dateofbirth" name="dateofbirth" size="20" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="dateofbirth" --><!-- /TMPL_IF -->" />
 <!-- /TMPL_IF -->
 
                 <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="dateofbirth_button" alt="Show Calendar" />
@@ -238,7 +274,7 @@
                     <label for="initials">
                 <!-- /TMPL_IF-->
                 Initials: </label>
-                <input type="text" id="initials" name="initials" size="20"  value="<!-- TMPL_VAR NAME="initials" -->" />	
+                <input type="text" id="initials" name="initials" size="20"  value="<!-- TMPL_VAR NAME="initials" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />	
                 <!-- TMPL_IF NAME="mandatoryinitials" --><span class="required">Required</span><!-- /TMPL_IF -->
             </li>
         <!-- /TMPL_UNLESS -->
@@ -249,7 +285,7 @@
 			<label for="othernames">
 			<!-- /TMPL_IF-->
 			Other name: </label>
-			<input type="text" id="othernames" name="othernames" size="20"  value="<!-- TMPL_VAR NAME="othernames" -->" />
+			<input type="text" id="othernames" name="othernames" size="20"  value="<!-- TMPL_VAR NAME="othernames" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 <!-- TMPL_IF NAME="mandatoryothernames" --><span class="required">Required</span><!-- /TMPL_IF -->
 		<!-- TMPL_IF NAME="I" --><input type="hidden" name="sex" value="N" /><!-- /TMPL_IF -->
 		</li>
@@ -280,7 +316,7 @@
     <fieldset class="rows">
         <legend>Guarantor Information</legend>
         <ol>
-<!--TMPL_IF Name="P"-->
+<!--TMPL_IF Name="addtoorganization"-->
 	        <!-- TMPL_IF NAME="guarantorid" -->
 	        <li id="contact-details">
 	        <!-- TMPL_ELSE -->
@@ -294,7 +330,7 @@
 	            <span><!-- TMPL_VAR NAME="contactname" --></span>
 	            <input name="contactname" id="contactname" type="hidden" size="20" value="<!-- TMPL_VAR NAME="contactname" -->" />
 	            <!-- TMPL_ELSE -->
-	            <input name="contactname" id="contactname" type="text" size="20" value="<!-- TMPL_VAR NAME="contactname" -->" />
+	            <input name="contactname" id="contactname" type="text" size="20" value="<!-- TMPL_VAR NAME="contactname" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	            <!-- /TMPL_IF -->
 	        </li>
 <!-- TMPL_ELSE -->
@@ -312,7 +348,7 @@
      <span><!-- TMPL_VAR NAME="contactname" --></span>
      <input name="contactname" id="contactname" type="hidden" size="20" value="<!-- TMPL_VAR NAME="contactname" -->" />
      <!-- TMPL_ELSE -->
-     <input name="contactname" id="contactname" type="text" size="20" value="<!-- TMPL_VAR NAME="contactname" -->" />
+     <input name="contactname" id="contactname" type="text" size="20" value="<!-- TMPL_VAR NAME="contactname" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
      <!-- /TMPL_IF -->
  </li>
  <li>
@@ -321,7 +357,7 @@
      <span><!-- TMPL_VAR NAME="contactfirstname" --></span>
      <input name="contactfirstname" id="contactfirstname" type="hidden" size="20" value="<!-- TMPL_VAR NAME="contactfirstname" -->" />
      <!-- TMPL_ELSE -->
-     <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="<!-- TMPL_VAR NAME="contactfirstname" -->" />
+     <input name="contactfirstname" id="contactfirstname" type="text" size="20" value="<!-- TMPL_VAR NAME="contactfirstname" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
      <!-- /TMPL_IF -->
  </li>
  <!-- TMPL_IF name="relshiploop" -->
@@ -362,7 +398,7 @@
       <label for="streetnumber">
       <!-- /TMPL_IF-->
       Street number: </label>
-      <input type="text" id="streetnumber" name="streetnumber" size="5" value="<!-- TMPL_VAR NAME="streetnumber" -->" />
+      <input type="text" id="streetnumber" name="streetnumber" size="5" value="<!-- TMPL_VAR NAME="streetnumber" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 <!-- TMPL_IF NAME="mandatorystreetnumber" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>
     <!-- TMPL_IF NAME="road_cgipopup" -->
@@ -384,7 +420,7 @@
       <label for="address">
       <!--/TMPL_IF-->
       Address: </label>
-      <input type="text" id="address" name="address" size="35" value="<!-- TMPL_VAR NAME="address" -->" />
+      <input type="text" id="address" name="address" size="35" value="<!-- TMPL_VAR NAME="address" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryaddress" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>
     <li>
@@ -394,7 +430,7 @@
       <label for="address2">
       <!-- /TMPL_IF-->
       Address 2: </label>
-      <input type="text" id="address2" name="address2" size="35" value="<!-- TMPL_VAR NAME="address2" -->" />
+      <input type="text" id="address2" name="address2" size="35" value="<!-- TMPL_VAR NAME="address2" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryaddress2" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>  
     <li>
@@ -405,7 +441,7 @@
       <!-- /TMPL_IF-->
       City, State: </label>
         
-        <input type="text" id="city" name="city" size="20" value="<!-- TMPL_VAR NAME="city" -->" />
+        <input type="text" id="city" name="city" size="20" value="<!-- TMPL_VAR NAME="city" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
         <!-- TMPL_IF NAME="city_cgipopup" -->or <strong>choose</strong>
         <select id="select_city" name="select_city">
         <!-- TMPL_LOOP NAME="city_loop" -->
@@ -428,7 +464,7 @@
         <label for="zipcode">
       <!-- /TMPL_IF-->
       Zip/Postal code: </label>
-      <input type="text" name="zipcode" id="zipcode" size="10" value="<!-- TMPL_VAR NAME="zipcode" -->" />
+      <input type="text" name="zipcode" id="zipcode" size="10" value="<!-- TMPL_VAR NAME="zipcode" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryzipcode" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>
     
@@ -439,7 +475,7 @@
         <label for="country">
       <!-- /TMPL_IF-->
       Country: </label>
-      <input type="text" name="country" id="country" size="20" value="<!-- TMPL_VAR NAME="country" -->" />
+      <input type="text" name="country" id="country" size="20" value="<!-- TMPL_VAR NAME="country" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatorycountry" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>    
   
@@ -454,7 +490,7 @@
       <label for="phone">
       <!-- /TMPL_IF-->
       Phone (home): </label>
-      <input type="text" id="phone" name="phone" value="<!-- TMPL_VAR NAME="phone" -->" />
+      <input type="text" id="phone" name="phone" value="<!-- TMPL_VAR NAME="phone" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryphone" --><span class="required">Required</span><!-- /TMPL_IF --><div class="hint">Shows on transit slips</div>
 
     </li>
@@ -465,7 +501,7 @@
       <label for="phonepro">
       <!-- /TMPL_IF-->
       Phone (work): </label>
-      <input type="text" id="phonepro" name="phonepro" value="<!-- TMPL_VAR NAME="phonepro" -->" />
+      <input type="text" id="phonepro" name="phonepro" value="<!-- TMPL_VAR NAME="phonepro" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryphonepro" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>
     <li>
@@ -475,7 +511,7 @@
       <label for="mobile">
       <!-- /TMPL_IF-->
       Phone (cell): </label>
-      <input type="text" id="mobile" name="mobile" value="<!-- TMPL_VAR NAME="mobile" -->" />
+      <input type="text" id="mobile" name="mobile" value="<!-- TMPL_VAR NAME="mobile" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatorymobile" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>
     <li>
@@ -484,8 +520,8 @@
       <!--TMPL_ELSE-->
       <label for="email">
       <!-- /TMPL_IF-->
-      Email (home): </label>
-      <input type="text" id="email" name="email" size="45" value="<!-- TMPL_VAR NAME="email" -->" />  
+      Primary Email: </label>
+      <input type="text" id="email" name="email" size="45" value="<!-- TMPL_VAR NAME="email" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />  
 	  <!-- TMPL_IF NAME="mandatoryemail" --><span class="required">Required</span><!-- /TMPL_IF --><div class="hint">Shows on transit slips</div>
 
     </li>
@@ -495,8 +531,8 @@
       <!--TMPL_ELSE-->
       <label for="emailpro">
       <!-- /TMPL_IF-->
-      Email (work): </label>
-      <input type="text" id="emailpro" name="emailpro" size="45" value="<!-- TMPL_VAR NAME="emailpro" -->" />
+      Secondary Email: </label>
+      <input type="text" id="emailpro" name="emailpro" size="45" value="<!-- TMPL_VAR NAME="emailpro" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryemailpro" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>
     <li>
@@ -506,7 +542,7 @@
       <label for="fax">
       <!-- /TMPL_IF-->
       Fax: </label>
-      <input type="text" id="fax" name="fax" value="<!-- TMPL_VAR NAME="fax" -->" />
+      <input type="text" id="fax" name="fax" value="<!-- TMPL_VAR NAME="fax" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryfax" --><span class="required">Required</span><!-- /TMPL_IF -->
     </li>
 	</ol>
@@ -526,7 +562,7 @@
 					<label for="B_address">
 				<!-- /TMPL_IF-->
 				Address: </label>
-				<input type="text" id="B_address" name="B_address" size="40" value="<!-- TMPL_VAR NAME="B_address" -->" />
+				<input type="text" id="B_address" name="B_address" size="40" value="<!-- TMPL_VAR NAME="B_address" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryB_address" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -536,7 +572,7 @@
 					<label for="B_address2">
 				<!-- /TMPL_IF-->
 				Address 2: </label>
-				<input type="text" id="B_address2" name="B_address2" size="40" value="<!-- TMPL_VAR NAME="B_address2" -->" />
+				<input type="text" id="B_address2" name="B_address2" size="40" value="<!-- TMPL_VAR NAME="B_address2" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryB_address2" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>			
 			<li>
@@ -546,7 +582,7 @@
 					<label for="B_city">
 				<!-- /TMPL_IF-->
 				City, State: </label>
-				<input type="text" id="B_city" name="B_city" size="20" value="<!-- TMPL_VAR NAME="B_city" -->" />
+				<input type="text" id="B_city" name="B_city" size="20" value="<!-- TMPL_VAR NAME="B_city" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryB_city" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -556,7 +592,7 @@
 					<label for="B_zipcode">
 				<!-- /TMPL_IF-->
 				Zip/Postal code: </label>
-				<input type="text" id="B_zipcode" name="B_zipcode" maxlength="10" size="10" value="<!-- TMPL_VAR NAME="B_zipcode" -->" />
+				<input type="text" id="B_zipcode" name="B_zipcode" maxlength="10" size="10" value="<!-- TMPL_VAR NAME="B_zipcode" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryB_zipcode" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -566,7 +602,7 @@
 					<label for="B_country">
 				<!-- /TMPL_IF-->
 				Country: </label>
-				<input type="text" id="B_country" name="B_country" size="20" value="<!-- TMPL_VAR NAME="B_country" -->" />
+				<input type="text" id="B_country" name="B_country" size="20" value="<!-- TMPL_VAR NAME="B_country" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatoryB_country" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
             <li>
@@ -576,7 +612,7 @@
                 <label for="B_phone">
                 <!-- /TMPL_IF-->
                 Phone: </label>  
-                <input type="text" id="B_phone" name="B_phone" value="<!-- TMPL_VAR NAME="B_phone" -->" />
+                <input type="text" id="B_phone" name="B_phone" value="<!-- TMPL_VAR NAME="B_phone" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
                 <!-- TMPL_IF NAME="mandatoryB_phone" --><span class="required">Required</span><!-- /TMPL_IF -->
             </li>
 			<li> 
@@ -586,7 +622,7 @@
           <label for="B_email">
         <!-- /TMPL_IF-->
         Email: </label>
-        <input type="text" id="B_email" name="B_email" size="45" value="<!-- TMPL_VAR NAME="B_email" -->" />
+        <input type="text" id="B_email" name="B_email" size="45" value="<!-- TMPL_VAR NAME="B_email" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 		<!-- TMPL_IF NAME="mandatoryB_email" --><span class="required">Required</span><!-- /TMPL_IF --> </li>
             <li>
                 <!-- TMPL_IF NAME="mandatorycontactnote" -->
@@ -611,7 +647,7 @@
 				<label for="altcontactsurname">
 				<!-- /TMPL_IF -->
 				Surname:</label>
-				<input type="text" name="altcontactsurname" id="altcontactsurname" value="<!-- TMPL_VAR NAME="altcontactsurname" -->" />
+				<input type="text" name="altcontactsurname" id="altcontactsurname" value="<!-- TMPL_VAR NAME="altcontactsurname" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 				<!-- TMPL_IF NAME="mandatoryaltcontactsurname" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -621,7 +657,7 @@
 				<label for="altcontactfirstname">
 				<!-- /TMPL_IF -->
 				First name:</label>
-				<input type="text" name="altcontactfirstname" id="altcontactfirstname" value="<!-- TMPL_VAR NAME="altcontactfirstname" -->" />
+				<input type="text" name="altcontactfirstname" id="altcontactfirstname" value="<!-- TMPL_VAR NAME="altcontactfirstname" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 				<!-- TMPL_IF NAME="mandatoryaltcontactfirstname" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -631,7 +667,7 @@
 				<label for="altcontactaddress1">
 				<!-- /TMPL_IF -->
 				Address:</label>
-				<input type="text" name="altcontactaddress1" id="altcontactaddress1" value="<!-- TMPL_VAR NAME="altcontactaddress1" -->" size="40" />
+				<input type="text" name="altcontactaddress1" id="altcontactaddress1" value="<!-- TMPL_VAR NAME="altcontactaddress1" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> size="40" />
 				<!-- TMPL_IF NAME="mandatoryaltcontactaddress1" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -641,7 +677,7 @@
 				<label for="altcontactaddress2">
 				<!-- /TMPL_IF -->
 				Address 2:</label>
-				<input type="text" name="altcontactaddress2" id="altcontactaddress2" value="<!-- TMPL_VAR NAME="altcontactaddress2" -->" size="40" />
+				<input type="text" name="altcontactaddress2" id="altcontactaddress2" value="<!-- TMPL_VAR NAME="altcontactaddress2" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> size="40" />
 				<!-- TMPL_IF NAME="mandatoryaltcontactaddress2" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -651,7 +687,7 @@
 				<label for="altcontactaddress3">
 				<!-- /TMPL_IF -->
 				City, State:</label>
-				<input type="text" name="altcontactaddress3" id="altcontactaddress3" value="<!-- TMPL_VAR NAME="altcontactaddress3" -->" size="40" />
+				<input type="text" name="altcontactaddress3" id="altcontactaddress3" value="<!-- TMPL_VAR NAME="altcontactaddress3" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> size="40" />
 				<!-- TMPL_IF NAME="mandatoryaltcontactaddress3" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -661,7 +697,7 @@
 				<label for="altcontactzipcode">
 				<!-- /TMPL_IF -->
 				Zip/Postal code:</label>
-				<input type="text" name="altcontactzipcode" id="altcontactzipcode" value="<!-- TMPL_VAR NAME="altcontactzipcode" -->" size="5" />
+				<input type="text" name="altcontactzipcode" id="altcontactzipcode" value="<!-- TMPL_VAR NAME="altcontactzipcode" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> size="5" />
 				<!-- TMPL_IF NAME="mandatoryaltcontactzipcode" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
 			<li>
@@ -671,7 +707,7 @@
 				<label for="altcontactcountry">
 				<!-- /TMPL_IF -->
 				Country:</label>
-				<input type="text" name="altcontactcountry" id="altcontactcountry" value="<!-- TMPL_VAR NAME="altcontactcountry" -->" size="20" />
+				<input type="text" name="altcontactcountry" id="altcontactcountry" value="<!-- TMPL_VAR NAME="altcontactcountry" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> size="20" />
 				<!-- TMPL_IF NAME="mandatoryaltcontactcountry" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>			
 			<li>
@@ -681,7 +717,7 @@
 				<label for="altcontactphone">
 				<!-- /TMPL_IF -->
 				Phone:</label>
-				<input type="text" name="altcontactphone" id="altcontactphone" value="<!-- TMPL_VAR NAME="altcontactphone" -->" />
+				<input type="text" name="altcontactphone" id="altcontactphone" value="<!-- TMPL_VAR NAME="altcontactphone" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 				<!-- TMPL_IF NAME="mandatoryaltcontactphone" --><span class="required">Required</span><!-- /TMPL_IF -->
 			</li>
             </ol>
@@ -718,7 +754,7 @@
       <label for="cardnumber">
     <!-- /TMPL_IF--> 
     Card number: </label>
-    <input type="text" id="cardnumber" name="cardnumber" size="20" value="<!-- TMPL_VAR NAME="cardnumber" -->" />
+    <input type="text" id="cardnumber" name="cardnumber" size="20" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="cardnumber" --><!-- /TMPL_IF -->" />
 	  <!-- TMPL_IF NAME="mandatorycardnumber" --><span class="required">Required</span><!-- /TMPL_IF --></li>
     <li>
       <!-- TMPL_IF NAME="mandatorybranchcode" -->
@@ -784,7 +820,7 @@
     <!--TMPL_IF NAME="CGIsort2" --> 
       <!-- TMPL_VAR NAME="CGIsort2" -->
     <!--TMPL_ELSE-->
-      <input  type="text" id="sort2" name="sort2" size="20"  value="<!-- TMPL_VAR NAME="sort2" -->" />
+      <input  type="text" id="sort2" name="sort2" size="20"  value="<!-- TMPL_VAR NAME="sort2" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
 	  <!-- TMPL_IF NAME="mandatorysort2" --><span class="required">Required</span><!-- /TMPL_IF -->
     <!-- /TMPL_IF --> 
     </li>
@@ -871,9 +907,9 @@
 			OPAC Login: </label>
 
 <!-- TMPL_IF NAME="NoUpdateLogin" -->
-<input type="text" id="userid" name="userid" size="20" disabled="disabled" value="<!-- TMPL_VAR NAME="userid" -->" />
+<input type="text" id="userid" name="userid" size="20" disabled="disabled" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="userid" --><!-- /TMPL_IF -->" />
 <!-- TMPL_ELSE -->
-<input type="text" id="userid" name="userid" size="20" value="<!-- TMPL_VAR NAME="userid" -->" />
+<input type="text" id="userid" name="userid" size="20" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="userid" --><!-- /TMPL_IF -->" />
 <!-- /TMPL_IF -->
 
 	  <!-- TMPL_IF NAME="mandatoryuserid" --><span class="required">Required</span><!-- /TMPL_IF -->
@@ -887,16 +923,16 @@
 			Password: </label>
 			<!--TMPL_IF NAME="opadd"-->
 			<!-- TMPL_IF NAME="NoUpdateLogin" -->
-				<input type="text" id="password" name="password" size="20"  disabled="disabled" value="<!-- TMPL_VAR NAME="password" -->" />
+				<input type="text" id="password" name="password" size="20"  disabled="disabled" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="password" --><!-- /TMPL_IF -->" />
 <!-- TMPL_ELSE -->
-				<input type="text" id="password" name="password" size="20" value="<!-- TMPL_VAR NAME="password" -->" />
+				<input type="text" id="password" name="password" size="20" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE--><!-- TMPL_VAR NAME="password" --><!-- /TMPL_IF -->" />
 <!-- /TMPL_IF -->
 			<!--TMPL_ELSE-->
 			<!--TMPL_IF NAME="password"-->
 				<!-- TMPL_IF NAME="NoUpdateLogin" -->
 					<input type="text" id="password" name="password" size="20"  disabled="disabled" value="****" />
 				<!-- TMPL_ELSE -->
-					<input type="text" id="password" name="password" size="20" value="****" />
+					<input type="text" id="password" name="password" size="20" value="<!-- TMPL_IF NAME="opduplicate" --><!--TMPL_ELSE-->****<!-- /TMPL_IF -->" />
 				<!-- /TMPL_IF -->
 			<!--TMPL_ELSE-->
 				<!-- TMPL_IF NAME="NoUpdateLogin" -->
@@ -918,7 +954,6 @@
 			<!-- TMPL_LOOP NAME="flagloop" -->
 				<li><label class="radio" for="yes<!-- TMPL_VAR name="name" -->">
 				<!-- TMPL_IF EXPR="key eq 'gonenoaddress'" -->Gone no Address:<!-- /TMPL_IF -->
-				<!-- TMPL_IF EXPR="key eq 'debarred'" -->Debarred:<!-- /TMPL_IF -->
 				<!-- TMPL_IF EXPR="key eq 'lost'" -->Lost Card:<!-- /TMPL_IF -->
                 </label>
 				
@@ -936,9 +971,47 @@
 				<input type="radio" id="no<!-- TMPL_VAR NAME="name" -->" name="<!-- TMPL_VAR NAME="name" -->" value="0" />
 				<!-- /TMPL_IF -->
 
-</li>
+				<p>
+				<label class="class<!-- TMPL_VAR NAME="name" -->" for="<!-- TMPL_VAR NAME="name" -->comment">Comment:</label><br />
+				<textarea cols="40" rows="2" class="class<!-- TMPL_VAR NAME="name" -->" id="<!-- TMPL_VAR NAME="name" -->comment" name="<!-- TMPL_VAR NAME="name" -->comment"><!-- TMPL_IF EXPR="key eq 'gonenoaddress'" --><!-- TMPL_VAR NAME="gonenoaddresscomment" --><!-- /TMPL_IF --><!-- TMPL_IF EXPR="key eq 'lost'" --><!-- TMPL_VAR NAME="lostcomment" --><!-- /TMPL_IF --></textarea>
+				</p>
+
+			</li>
 			<!-- /TMPL_LOOP -->
-			</ol>
+			<li>
+				<label for="yesdebarred" class="radio">Debarred: </label>
+				<!-- TMPL_IF NAME="debarred" -->
+				<label for="yesdebarred">Yes </label>
+				<input type="radio" id="yesdebarred" name="debarred" value="1" checked="checked"/>
+                <label for="nodebarred">No </label>
+                <input type="radio" id="nodebarred" name="debarred" value="0"/>
+				<!-- TMPL_ELSE -->
+				<label for="yesdebarred">Yes </label>
+				<input type="radio" id="yesdebarred" name="debarred" value="1" />
+                <label for="nodebarred">No </label>
+                <input type="radio" id="nodebarred" name="debarred" value="0" checked="checked"/>
+				<!-- /TMPL_IF -->
+				
+				<br />
+				<label for="datedebarred" class="radio">until:</label> 
+				<input type="text" name="datedebarred" id="debarred" class="debarred" value="<!-- TMPL_VAR NAME="datedebarred" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
+				<img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="debarred_button" alt="Show Calendar" />
+		         <script language="JavaScript" type="text/javascript">
+		            Calendar.setup(
+		            {
+		                inputField : "debarred",
+		                ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+		                button : "debarred_button"
+		            }
+		            );
+		        </script>
+		        <br />
+		        <label for="debarredcomment" class="radio">comment:</label>
+		        <input type="text" id="debarredcomment" name="debarredcomment" value="<!-- TMPL_VAR NAME="debarredcomment" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> class="debarred" size="150"/>
+		        
+				 
+	        </li>
+		</ol>
 			</fieldset>
 		<!-- /TMPL_UNLESS -->	
 
@@ -976,7 +1049,7 @@
                     </select>
                 <!-- TMPL_ELSE -->
                     <input type="text" maxlength="64" value="<!-- TMPL_VAR NAME="value" -->"
-                           id="<!-- TMPL_VAR NAME="form_id" -->" name="<!-- TMPL_VAR NAME="form_id" -->" />
+                           id="<!-- TMPL_VAR NAME="form_id" -->" name="<!-- TMPL_VAR NAME="form_id" -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
                 <!-- /TMPL_IF -->
                 <!-- TMPL_IF NAME="password_allowed" -->
                     (Password: <input type="password" maxlength="64" value="<!-- TMPL_VAR NAME="password" -->"
@@ -1048,7 +1121,7 @@
     <!-- TMPL_INCLUDE NAME="messaging-preference-form.inc" -->
     <!-- TMPL_IF NAME="SMSSendDriver" -->
         <p><label for="SMSnumber">SMS number:</label> 
-          <input type="text" id="SMSnumber" name="SMSnumber" value="<!-- TMPL_VAR NAME="SMSnumber"  -->" />
+          <input type="text" id="SMSnumber" name="SMSnumber" value="<!-- TMPL_VAR NAME="SMSnumber"  -->"<!--TMPL_IF NAME="opduplicate"--> onclick="this.value=''"<!-- /TMPL_IF --> />
         </p>
     <!-- /TMPL_IF -->
   </fieldset>
diff --git a/members/memberentry.pl b/members/memberentry.pl
index fbd8538..f9a75e0 100755
--- a/members/memberentry.pl
+++ b/members/memberentry.pl
@@ -70,7 +70,8 @@ my $destination    = $input->param('destination');
 my $cardnumber     = $input->param('cardnumber');
 my $check_member   = $input->param('check_member');
 my $nodouble       = $input->param('nodouble');
-$nodouble = 1 if $op eq 'modify'; # FIXME hack to represent fact that if we're
+my $duplicate      = $input->param('duplicate');
+$nodouble = 1 if ($op eq 'modify' or $op eq 'duplicate');    # FIXME hack to represent fact that if we're
                                   # modifying an existing patron, it ipso facto
                                   # isn't a duplicate.  Marking FIXME because this
                                   # script needs to be refactored.
@@ -99,8 +100,9 @@ foreach (@field_check) {
 	$template->param( "mandatory$_" => 1);    
 }
 $template->param("add"=>1) if ($op eq 'add');
+$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' );
 $template->param("checked" => 1) if (defined($nodouble) && $nodouble eq 1);
-($borrower_data = GetMember( 'borrowernumber'=>$borrowernumber )) if ($op eq 'modify' or $op eq 'save');
+( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' );
 my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
 my $category_type = $input->param('category_type');
 my $new_c_type = $category_type; #if we have input param, then we've already chosen the cat_type.
@@ -117,7 +119,8 @@ $category_type="A" unless $category_type; # FIXME we should display a error mess
 
 # initialize %newdata
 my %newdata;	# comes from $input->param()
-if ($op eq 'insert' || $op eq 'modify' || $op eq 'save') {
+if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) {
+
     my @names= ($borrower_data && $op ne 'save') ? keys %$borrower_data : $input->param();
     foreach my $key (@names) {
         if (defined $input->param($key)) {
@@ -125,10 +128,26 @@ if ($op eq 'insert' || $op eq 'modify' || $op eq 'save') {
             $newdata{$key} =~ s/\"/&quot;/g unless $key eq 'borrowernotes' or $key eq 'opacnote';
         }
     }
+        
+    ## Manipulate debarred
+    if($newdata{debarred}){
+        $newdata{debarred} = $newdata{datedebarred} ? $newdata{datedebarred} : "9999-12-31";
+    }elsif (exists ($newdata{debarred}) && !($newdata{debarred})){
+        undef ($newdata{debarred});
+        undef ($newdata{debarredcomment});
+    }elsif (exists ($newdata{debarredcomment}) && $newdata{debarredcomment} eq ""){
+        undef($newdata{debarredcomment});
+    }
+
+    # Manipulate flags :
+    # Delete comment if flag set to no
+    $newdata{gonenoaddresscomment} = "" if (defined $newdata{gonenoaddress} && $newdata{gonenoaddress} == 0);
+    $newdata{lostcomment} = "" if (defined $newdata{lost} && $newdata{lost} == 0);
+    
     my $dateobject = C4::Dates->new();
     my $syspref = $dateobject->regexp();		# same syspref format for all 3 dates
     my $iso     = $dateobject->regexp('iso');	#
-    foreach (qw(dateenrolled dateexpiry dateofbirth)) {
+    foreach (qw(dateenrolled dateexpiry dateofbirth debarred)) {
         next unless exists $newdata{$_};
         my $userdate = $newdata{$_} or next;
         if ($userdate =~ /$syspref/) {
@@ -198,15 +217,16 @@ if (($op eq 'insert') and !$nodouble){
 }
 
   #recover all data from guarantor address phone ,fax... 
-if ( defined($guarantorid) and
-     ( $category_type eq 'C' || $category_type eq 'P' ) and
-     $guarantorid ne ''  and
+if ( defined($guarantorid) 
+    and ( $category_type eq 'C' || $category_type eq 'P' || $category_type eq 'A' )
+     and $guarantorid ne ''  and
      $guarantorid ne '0' ) {
     if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
         $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
         if ( !defined($data{'contactname'}) or $data{'contactname'} eq '' or
              $data{'contactname'} ne $guarantordata->{'surname'} ) {
             $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
+	        $data{'contactname'} = $guarantordata->{'surname'};
             $newdata{'contactname'}     = $guarantordata->{'surname'};
             $newdata{'contacttitle'}    = $guarantordata->{'title'};
 	        foreach (qw(streetnumber address streettype address2
@@ -278,7 +298,7 @@ if ($op eq 'save' || $op eq 'insert'){
   }
 }
 
-if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save') and ($step == 0 or $step == 3 )){
+if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){
     if (exists ($newdata{'dateexpiry'}) && !($newdata{'dateexpiry'})){
         my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
         $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
@@ -387,6 +407,11 @@ if ($op eq "modify")  {
     $template->param( updtype => 'M',modify => 1 );
     $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1, step_5 => 1, step_6 => 1) unless $step;
 }
+if ( $op eq "duplicate" ) {
+    $template->param( updtype => 'I' );
+    $template->param( step_1 => 1, step_2 => 1, step_3 => 1, step_4 => 1, step_5 => 1, step_6 => 1 ) unless $step;
+}
+
 # my $cardnumber=$data{'cardnumber'};
 $data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add';
 if(!defined($data{'sex'})){
@@ -481,7 +506,7 @@ my $borrotitlepopup = CGI::popup_menu(-name=>'title',
         -default=>$default_borrowertitle
         );    
 
-my @relationships = split /,|\|/, C4::Context->preference('BorrowerRelationship');
+my @relationships = split (/,|\|/, C4::Context->preference('BorrowerRelationship'));
 my @relshipdata;
 while (@relationships) {
   my $relship = shift @relationships || '';
@@ -495,10 +520,9 @@ while (@relationships) {
 }
 
 my %flags = ( 'gonenoaddress' => ['gonenoaddress' ],
-        'lost'          => ['lost'],
-        'debarred'      => ['debarred']);
+        'lost'          => ['lost']);
+
 
- 
 my @flagdata;
 foreach (keys(%flags)) {
 	my $key = $_;
@@ -533,6 +557,13 @@ for my $branch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branc
     $select_branches{$branch} = $branches->{$branch}->{'branchname'};
     $default = C4::Context->userenv->{'branch'} if (C4::Context->userenv && C4::Context->userenv->{'branch'});
 }
+
+if ($category_type eq 'A' || $category_type eq 'P') {
+    $template->param(
+	addtoorganization => 1
+		    );
+}
+
 # --------------------------------------------------------------------------------------------------------
   #in modify mod :default value from $CGIbranch comes from borrowers table
   #in add mod: default value come from branches table (ip correspendence)
@@ -599,7 +630,10 @@ if (C4::Context->preference('uppercasesurnames')) {
 	$data{'surname'}    =uc($data{'surname'}    );
 	$data{'contactname'}=uc($data{'contactname'});
 }
-foreach (qw(dateenrolled dateexpiry dateofbirth)) {
+
+$data{debarred} = C4::Overdues::CheckBorrowerDebarred($borrowernumber);
+$data{datedebarred} = $data{debarred} if ($data{debarred} ne "9999-12-31");  
+foreach (qw(dateenrolled dateexpiry dateofbirth debarred)) {
 	$data{$_} = format_date($data{$_});	# back to syspref for display
 	$template->param( $_ => $data{$_});
 }
diff --git a/members/setdebar.pl b/members/setdebar.pl
deleted file mode 100755
index b12ab57..0000000
--- a/members/setdebar.pl
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-
-=head1 setdebar.pl
-
-script to set or lift debarred status
-written 2/8/04
-by oleonard at athenscounty.lib.oh.us
-
-=cut
-
-use strict;
-use warnings;
-
-use CGI;
-use C4::Context;
-use C4::Auth;
-
-my $input = new CGI;
-
-my $flagsrequired;
-$flagsrequired->{borrowers} = 1;
-my ( $loggedinuser, $cookie, $sessionID ) =
-  checkauth( $input, 0, $flagsrequired );
-
-my $destination    = $input->param("destination") || '';
-my $cardnumber     = $input->param("cardnumber");
-my $borrowernumber = $input->param('borrowernumber');
-my $status         = $input->param('status');
-
-my $dbh = C4::Context->dbh;
-my $sth =
-  $dbh->prepare("Update borrowers set debarred = ? where borrowernumber = ?");
-$sth->execute( $status, $borrowernumber );
-$sth->finish;
-
-if ( $destination eq "circ" ) {
-    print $input->redirect(
-        "/cgi-bin/koha/circ/circulation.pl?findborrower=".$cardnumber);
-}
-else {
-    print $input->redirect(
-        "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");
-}
diff --git a/members/setstatus.pl b/members/setstatus.pl
index 2a3947c..47c71ee 100755
--- a/members/setstatus.pl
+++ b/members/setstatus.pl
@@ -43,6 +43,7 @@ my $borrowernumber=$input->param('borrowernumber');
 my $status = $input->param('status');
 my $reregistration = $input->param('reregistration') || '';
 
+undef $status unless ($status);
 my $dbh = C4::Context->dbh;
 my $dateexpiry;
 
@@ -50,7 +51,7 @@ if ( $reregistration eq 'y' ) {
 	# re-reregistration function to automatic calcul of date expiry
 	$dateexpiry = ExtendMemberSubscriptionTo( $borrowernumber );
 } else {
-	my $sth=$dbh->prepare("Update borrowers set debarred = ? where borrowernumber = ?");
+	my $sth=$dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
 	$sth->execute($status,$borrowernumber);	
 	$sth->finish;
 	}
@@ -59,12 +60,16 @@ if($destination eq "circ"){
 	if($dateexpiry){
 		print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$cardnumber&dateexpiry=$dateexpiry");
 	} else {
-		print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$cardnumber");
+	    if($cardnumber){
+		    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$cardnumber");
+	    }else{
+	        print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+	    }
 	}
 } else {
 	if($dateexpiry){
-		print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$borrowernumber&dateexpiry=$dateexpiry");
+		print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber&dateexpiry=$dateexpiry");
 	} else {
-		print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$borrowernumber");
+		print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");
 	}
 }
-- 
1.7.1



More information about the Koha-patches mailing list