[Koha-cvs] koha C4/Circulation/Circ2.pm C4/Reserves2.pm ci... [rel_3_0]

LAURIN arnaud alaurin at ouestprovence.fr
Mon Jan 22 19:00:39 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	LAURIN arnaud <alaurin>	07/01/22 18:00:39

Modified files:
	C4/Circulation : Circ2.pm 
	C4             : Reserves2.pm 
	circ           : returns.pl 
	koha-tmpl/intranet-tmpl/prog/en/circ: returns.tmpl 

Log message:
	Adding a new case of security in branchtranfers routine :
	
		if the document a reservation or a transfer document is waiting in a specific library but comming in an another , we add a warning message specify to the librarian where the document was initialy expected ....
	
		in the system, we finish the tranfert but with the new 'tobranch' value and adding a comment 'wrong transfert', and after create a new line on branchtranfers but with the real values of tranfers ("frombranch") ....
	
	This commit will be improved earlier, and code cleaned (remove warn compilations .... in french sorry .....)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Circ2.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.114.2.33&r2=1.114.2.34
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Reserves2.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.46.2.12&r2=1.46.2.13
http://cvs.savannah.gnu.org/viewcvs/koha/circ/returns.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.43.2.11&r2=1.43.2.12
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.9&r2=1.4.2.10

Patches:
Index: C4/Circulation/Circ2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Circulation/Circ2.pm,v
retrieving revision 1.114.2.33
retrieving revision 1.114.2.34
diff -u -b -r1.114.2.33 -r1.114.2.34
--- C4/Circulation/Circ2.pm	11 Jan 2007 15:13:44 -0000	1.114.2.33
+++ C4/Circulation/Circ2.pm	22 Jan 2007 18:00:38 -0000	1.114.2.34
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Circ2.pm,v 1.114.2.33 2007/01/11 15:13:44 toins Exp $
+# $Id: Circ2.pm,v 1.114.2.34 2007/01/22 18:00:38 alaurin Exp $
 
 use strict;
 require Exporter;
@@ -41,7 +41,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.114.2.33 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.114.2.34 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -94,6 +94,7 @@
   &AnonymiseIssueHistory
   &GetLostItems
   &itemissues
+  &updateWrongTransfer
 );
 
 =head2 itemseen
@@ -1590,21 +1591,24 @@
 
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    #     check if we have a transfer for this document
-    my $checktransfer = checktransferts( $iteminformation->{'itemnumber'} );
+    my ($datesent,$frombranch,$tobranch) = checktransferts( $iteminformation->{'itemnumber'} );
 
  #     if we have a return, we update the line of transfers with the datearrived
-    if ($checktransfer) {
+    if ($datesent) {
+    	if ( $tobranch eq C4::Context->userenv->{'branch'} ) {
         my $sth =
           $dbh->prepare(
-"update branchtransfers set datearrived = now() where itemnumber= ? AND datearrived IS NULL"
+			"update branchtransfers set datearrived = now() where itemnumber= ? AND datearrived IS NULL"
           );
         $sth->execute( $iteminformation->{'itemnumber'} );
         $sth->finish;
-
 #         now we check if there is a reservation with the validate of transfer if we have one, we can         set it with the status 'W'
-        my $updateWaiting =
           SetWaitingStatus( $iteminformation->{'itemnumber'} );
     }
+     else {
+     	$messages->{'WrongTransfer'} = $tobranch;
+     }
+    }
 
 #    if we don't have a transfer on run, we check if the document is not in his homebranch and there is not a reservation, we transfer this one to his home branch directly if system preference Automaticreturn is turn on .
     else {
@@ -3118,6 +3122,29 @@
     return \@items;
 }
 
+=head2 updateWrongTransfer
+
+$items = updateWrongTransfer($itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary);
+
+This function validate the line of brachtransfer but with the wrong destination (mistake from a librarian ...), and create a new line in branchtransfer from the actual library to the original library of reservation 
+
+=cut
+
+sub updateWrongTransfer {
+	my ( $itemNumber,$borrowernumber,$waitingAtLibrary,$FromLibrary ) = @_;
+	my $dbh = C4::Context->dbh;	
+# first step validate the actual line of transfert .
+	my $sth =
+        	$dbh->prepare(
+			"update branchtransfers set datearrived = now(),tobranch=?,comments='wrongtransfer' where itemnumber= ? AND datearrived IS NULL"
+          	);
+        	$sth->execute($FromLibrary,$itemNumber);
+        	$sth->finish;
+# second step create a new line of branchtransfer to the right location .
+	dotransfer($itemNumber, $FromLibrary, $waitingAtLibrary);
+
+}
+
 1;
 
 __END__

Index: C4/Reserves2.pm
===================================================================
RCS file: /sources/koha/koha/C4/Reserves2.pm,v
retrieving revision 1.46.2.12
retrieving revision 1.46.2.13
diff -u -b -r1.46.2.12 -r1.46.2.13
--- C4/Reserves2.pm	22 Dec 2006 15:37:14 -0000	1.46.2.12
+++ C4/Reserves2.pm	22 Jan 2007 18:00:39 -0000	1.46.2.13
@@ -20,7 +20,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Reserves2.pm,v 1.46.2.12 2006/12/22 15:37:14 toins Exp $
+# $Id: Reserves2.pm,v 1.46.2.13 2007/01/22 18:00:39 alaurin Exp $
 
 use strict;
 require Exporter;
@@ -31,7 +31,7 @@
 my $library_name = C4::Context->preference("LibraryName");
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.46.2.12 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.46.2.13 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -111,6 +111,7 @@
 
 #'
 sub OtherReserves {
+warn "entree en mode Other reserves";
     my ($itemnumber) = @_;
     my $messages;
     my $nextreservinfo;
@@ -506,8 +507,6 @@
 #'
 sub CheckReserves {
     my ( $item, $barcode ) = @_;
-
-    # warn "In CheckReserves: itemnumber = $item";
     my $dbh = C4::Context->dbh;
     my $sth;
     if ($item) {
@@ -949,6 +948,7 @@
     }
     $sth->finish;
     return @results;
+    warn "entree en mode group reserves";
 }
 
 =item CreateReserve

Index: circ/returns.pl
===================================================================
RCS file: /sources/koha/koha/circ/returns.pl,v
retrieving revision 1.43.2.11
retrieving revision 1.43.2.12
diff -u -b -r1.43.2.11 -r1.43.2.12
--- circ/returns.pl	20 Dec 2006 16:55:41 -0000	1.43.2.11
+++ circ/returns.pl	22 Jan 2007 18:00:39 -0000	1.43.2.12
@@ -69,6 +69,7 @@
 $env{'printer'}    = $printer;
 $env{'queue'}      = $printer;
 
+
 # Set up the item stack ....
 my %returneditems;
 my %riduedate;
@@ -103,7 +104,16 @@
 
 ############
 # Deal with the requests....
+
+# dela with the request of case : "Wrong Transfert" (WT-...)
+if ($query->param('WT-itemNumber')){
+updateWrongTransfer ($query->param('WT-itemNumber'),$query->param('WT-borrnum'),$query->param('WT-waitingAt'),$query->param('WT-From'));
+
+}
+
+
 if ( $query->param('resbarcode') ) {
+warn "entree en mode resbarcode";
     my $item           = $query->param('itemnumber');
     my $borrowernumber = $query->param('borrowernumber');
     my $resbarcode     = $query->param('resbarcode');
@@ -120,6 +130,7 @@
 
 # my $branchname = $branches->{$tobranchcd}->{'branchname'}; - not sure if this line + $tobranchcd line do the same thing
 # as the $messages{'transfert'} code
+
     my $branchname = GetBranchName( $messages->{'transfert'} );
     my ($borr) = getpatroninformation( \%env, $nextreservinfo, 0 );
     my $borcnum = $borr->{'cardnumber'};
@@ -130,7 +141,6 @@
   #printreserve( $branchname, $borr, $iteminfo );
   #   if ( $tobranchcd ne $branch ) { - not sure if line below is doing the same
     if ( $messages->{'transfert'} ) {
-
 # 	add the transfer routine
 # 	C4::Circulation::Circ2::dotransfer($item,$iteminfo->{'holdingbranch'},$tobranchcd);
         $template->param(
@@ -155,7 +165,7 @@
 
 # actually return book and prepare item table.....
 if ($barcode) {
-
+warn "entrée en mode barcode";
     # decode cuecat
     $barcode = cuecatbarcodedecode($barcode);
     ( $returned, $messages, $iteminformation, $borrower ) =
@@ -241,7 +251,46 @@
 
 }
 
-if ( $messages->{'ResFound'} ) {
+# adding a case of wrong transfert, if the document wasn't transfered in the good library (according to branchtransfer (tobranch) BDD)
+
+if ( $messages->{'WrongTransfer'} ) {
+	warn "faux transferts retourné ";
+	$template->param(
+        WrongTransfer  => 1,
+        TransferWaitingAt => $messages->{'WrongTransfer'},
+    );
+
+    my $res        = $messages->{'ResFound'};
+    my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'};
+    my ($borr) = getpatroninformation( \%env, $res->{'borrowernumber'}, 0 );
+    my $name =
+      $borr->{'surname'} . " " . $borr->{'title'} . " " . $borr->{'firstname'};
+    my ($iteminfo) = getiteminformation( 0, $barcode );
+        
+        $template->param(
+            name           => $name,
+            borfirstname   => $borr->{'firstname'},
+            borsurname     => $borr->{'surname'},
+            bortitle       => $borr->{'title'},
+            borphone       => $borr->{'phone'},
+            boremail       => $borr->{'emailaddress'},
+            borstraddress  => $borr->{'streetaddress'},
+            borcity        => $borr->{'city'},
+            borzip         => $borr->{'zipcode'},
+            borrowernumber => $res->{'borrowernumber'},
+            borcnum        => $borr->{'cardnumber'},
+            itemnumber       => $res->{'itemnumber'},
+            itemtitle        => $iteminfo->{'title'},
+            itemauthor       => $iteminfo->{'author'},
+            itembarcode      => $iteminfo->{'barcode'},
+            itemtype         => $iteminfo->{'itemtype'},
+            ccode            => $iteminfo->{'ccode'},
+            itembiblionumber => $iteminfo->{'biblionumber'},
+            transfertFrom    => $branch,
+        );
+}
+
+if ( $messages->{'ResFound'} and not $messages->{'WrongTransfer'}) {
     my $res        = $messages->{'ResFound'};
     my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'};
     my ($borr) = getpatroninformation( \%env, $res->{'borrowernumber'}, 0 );
@@ -273,9 +322,6 @@
             debarred       => $borr->{'debarred'},
             gonenoaddress  => $borr->{'gonenoaddress'},
             currentbranch  => $branches->{$branch}->{'branchname'},
-            destbranchname =>
-              $branches->{ $res->{'branchcode'} }->{'branchname'},
-            waiting          => 1,
             itemnumber       => $res->{'itemnumber'},
             itemtitle        => $iteminfo->{'title'},
             itemauthor       => $iteminfo->{'author'},
@@ -373,6 +419,9 @@
               $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
         }
     }
+    elsif ( $code eq 'WrongTransfer' ) {
+        ;    # FIXME... anything to do here?
+    }
     else {
         die "Unknown error code $code";    # XXX
     }

Index: koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl,v
retrieving revision 1.4.2.9
retrieving revision 1.4.2.10
diff -u -b -r1.4.2.9 -r1.4.2.10
--- koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl	11 Jan 2007 14:25:34 -0000	1.4.2.9
+++ koha-tmpl/intranet-tmpl/prog/en/circ/returns.tmpl	22 Jan 2007 18:00:39 -0000	1.4.2.10
@@ -4,6 +4,41 @@
 <!-- TMPL_INCLUDE NAME="menus.inc" -->
 <!-- TMPL_INCLUDE NAME="menu-circ.inc" -->
 
+<!-- TMPL_IF Name="WrongTransfer" -->
+        	<h3 class="problem">This item was not transfered initialy to this library !</h3>
+        
+        <table>
+        <tr>
+        <th>Title : </th>
+        <td>        	
+        	<a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&biblionumber=<!-- TMPL_VAR NAME="itembiblionumber" -->"><!-- TMPL_VAR Name="itemtitle" --></a>
+        </td>	
+        <tr><th>Reserved for: </th>
+        <td>
+            <ul>
+                        <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR Name="borcnum" --></a></li>
+            <li><!-- TMPL_VAR Name="borsurname" -->, <!-- TMPL_VAR Name="borfirstname" --> </li>
+            <li><!-- TMPL_VAR Name="borstraddress" --><br />
+            <!-- TMPL_VAR Name="borcity" -->  <!-- TMPL_VAR NAME="borzip" --></li>
+            <li><!-- TMPL_VAR Name="borphone" --></li>
+            </ul>
+         </td>
+         </tr>
+         <tr><th>Action : </th>
+         	<td class="problem">
+         	 this document must be transfered to : <!-- TMPL_VAR Name="TransferWaitingAt" -->
+         	</td>
+         </tr>
+        </table>
+        <form method="post" action="returns.pl" name="mainform" id="mainform">
+                <input type="hidden" name="WT-itemNumber" value="<!-- TMPL_VAR Name="itemnumber" -->" />
+                <input type="hidden" name="WT-borrnum" value="<!-- TMPL_VAR Name="borrowernumber" -->" />
+                <input type="hidden" name="WT-waitingAt" value="<!-- TMPL_VAR Name="TransferWaitingAt" -->" />
+                <input type="hidden" name="WT-From" value="<!-- TMPL_VAR Name="transfertFrom" -->" />
+         <input type="submit" value="Send this document" />
+        </form>
+            
+<!-- /TMPL_IF -->
 
 <!-- TMPL_IF Name="found" -->
         <h3>Reserve Found<!-- TMPL_IF Name="waiting" --> (item is already consigned) <!-- /TMPL_IF --></h3>
@@ -87,6 +122,7 @@
         
 
         <!-- /TMPL_IF -->
+        
         <!-- TMPL_IF Name="reserved" -->
             
             <table>





More information about the Koha-cvs mailing list