Fix for 1704, now if autoitemreturns is off you get a dialogue warning a
authorChris Cormack <crc@liblime.com>
Thu, 27 Dec 2007 22:47:22 +0000 (16:47 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 27 Dec 2007 23:22:00 +0000 (17:22 -0600)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Circulation.pm
circ/returns.pl
installer/data/mysql/en/mandatory/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl

index 6c31ddd..156158a 100644 (file)
@@ -1029,7 +1029,7 @@ sub GetLoanLength {
       $dbh->prepare(
 "select issuelength from issuingrules where categorycode=? and itemtype=? and branchcode=? and issuelength is not null"
       );
-
+warn "in get loan lenght $borrowertype $itemtype $branchcode ";
 # try to find issuelength & return the 1st available.
 # check with borrowertype, itemtype and branchcode, then without one of those parameters
     $sth->execute( $borrowertype, $itemtype, $branchcode );
@@ -1261,11 +1261,13 @@ sub AddReturn {
         #we check, if we don't have reserv or transfert for this document, if not, return it to homebranch .
         
         if ( ($iteminformation->{'holdingbranch'} ne $iteminformation->{'homebranch'}) and not $messages->{'WrongTransfer'} and ($validTransfert ne 1) and ($reserveDone ne 1) ){
-                    if (C4::Context->preference("AutomaticItemReturn") == 1) {
-                    ModItemTransfer($iteminformation->{'itemnumber'}, C4::Context->userenv->{'branch'}, $iteminformation->{'homebranch'});
-                    $messages->{'WasTransfered'} = 1;
-                    warn "was transfered";
-                    }
+                       if (C4::Context->preference("AutomaticItemReturn") == 1) {
+                               ModItemTransfer($iteminformation->{'itemnumber'}, C4::Context->userenv->{'branch'}, $iteminformation->{'homebranch'});
+                               $messages->{'WasTransfered'} = 1;
+                       }
+                       else {
+                               $messages->{'NeedsTransfer'} = 1;
+                       }
         }
     }
     return ( $doreturn, $messages, $iteminformation, $borrower );
index 50afaf1..4dea59f 100755 (executable)
@@ -100,7 +100,7 @@ foreach ( $query->param ) {
 # Deal with the requests....
 
 if ($query->param('WT-itemNumber')){
-updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
+       updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-waitingAt'),$query->param('WT-From'));
 }
 
 if ( $query->param('resbarcode') ) {
@@ -154,6 +154,14 @@ my $messages;
 my $issueinformation;
 my $barcode = $query->param('barcode');
 
+my $dotransfer = $query->param('dotransfer');
+if ($dotransfer){
+       # An item has been returned to a branch other than the homebranch, and the librarian has choosen to initiate a transfer
+       my $transferitem=$query->param('transferitem');
+       my $tobranch=$query->param('tobranch');
+       ModItemTransfer($transferitem, C4::Context->userenv->{'branch'}, $tobranch); 
+}
+
 # actually return book and prepare item table.....
 if ($barcode) {
     # decode cuecat
@@ -227,7 +235,14 @@ if ( $messages->{'WasTransfered'} ) {
         found          => 1,
         transfer       => 1,
     );
+}
 
+if ( $messages->{'NeedsTransfer'} ){
+       $template->param(
+               found          => 1,
+               needstransfer  => 1,
+               itemnumber => $issueinformation->{'itemnumber'}
+       );
 }
 
 # adding a case of wrong transfert, if the document wasn't transfered in the good library (according to branchtransfer (tobranch) BDD)
@@ -387,6 +402,9 @@ foreach my $code ( keys %$messages ) {
     elsif ( $code eq 'WrongTransferItem' ) {
         ;    # FIXME... anything to do here?
     }
+       elsif ( $code eq 'NeedsTransfer' ) {
+       }
+               
     else {
         die "Unknown error code $code";    # XXX
     }
index e39507f..7d87a80 100644 (file)
@@ -13,7 +13,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('authoritysep','--','Used to separate a list of authorities in a display. Usually --','10','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('autoBarcode','OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002','incremental|annual|OFF','Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutoLocation','0','If ON, IP authentication is enabled, blocking access to the staff client from unauthorized IP addresses',NULL,'YesNo');
-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutomaticItemReturn','1','If ON, items attempt to return to their home branch when checked in',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutomaticItemReturn','1','If ON, Koha will automatically set up a transfer of this item to its homebranch',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('autoMemberNum','1','If ON, patron number is auto-calculated','','YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('BiblioDefaultView','normal','Choose the default detail view in the catalog; choose between normal, marc or isbd','normal|marc|isbd','Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('BorrowerMandatoryField','zipcode|surname','Choose the mandatory fields for a patron\'s account',NULL,'free');
index 31b34d1..d1088b9 100644 (file)
     <!-- case of a return of item, but with no reservation after, if the item must be  returned to its homebranch -->
     <!-- TMPL_IF Name="transfer" -->
        <!-- transfer -->
-         <h3 class="problem">Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=<!-- TMPL_VAR NAME="itembiblionumber" -->"><!-- TMPL_VAR Name="title" --></a> to <!-- TMPL_VAR Name="homebranch" --></h3><!-- /TMPL_IF -->
+         <h3 class="problem">Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=<!-- TMPL_VAR NAME="itembiblionumber" -->"><!-- TMPL_VAR Name="title" --></a> to <!-- TMPL_VAR Name="homebranch" --></h3>
+       <!-- /TMPL_IF -->
     
+    <!-- TMPL_IF Name="needstransfer" -->
+       <!-- transfer -->
+       <h3 class="problem"> This item needs to be transfered to <!-- TMPL_VAR Name="homebranch" --></h3>
+    <form method="post" action="returns.pl" name="mainform" id="mainform">              
+       <input type="submit" value="Confirm and transfer" class="submit" />
+       <input type="hidden" name="dotransfer" value="yes">
+       <input type="hidden" name="tobranch" value="<!-- TMPL_VAR NAME="homebranch" -->">
+       <input type="hidden" name="transferitem" value="<!-- TMPL_VAR NAME="itemnumber" -->">
+       <!--TMPL_LOOP Name="inputloop" -->     
+       <input type="hidden" name="ri-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" /> 
+       <input type="hidden" name="dd-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" /> 
+       <input type="hidden" name="bn-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="bornum" -->" /> 
+       <!-- /TMPL_LOOP -->                            
+       <input type="hidden" name="barcode" value="0" />    
+       </form>   
+       <!-- /TMPL_IF -->
+       
     <!-- TMPL_IF Name="diffbranch" -->
        <!-- diffbranch -->
         <h3>Item Consigned:</h3>