Fix for bug 1402, now if a renewal fails, the librarian is aware of it
[koha_fer] / reserve / renewscript.pl
index f22215c..804f2fa 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 
 #written 18/1/2000 by chris@katipo.co.nz
 #script to renew items from the web
@@ -24,7 +23,7 @@
 # Suite 330, Boston, MA  02111-1307 USA
 
 use CGI;
-use C4::Circulation::Circ2;
+use C4::Circulation;
 
 my $input = new CGI;
 
@@ -39,19 +38,21 @@ if ($input->param('renew_all')) {
 else {
     @data = $input->param('items[]');
 }
-
+my $branch=$input->param('branch');
 #
 # renew items
 #
-my %env;
 my $cardnumber = $input->param("cardnumber");
-my $bornum = $input->param("bornum");
-
+my $borrowernumber = $input->param("borrowernumber");
+my $failedrenews;
 foreach my $itemno (@data) {
-    #check status before renewing issue
-    if (renewstatus(\%env,$bornum,$itemno)){
-        renewbook(\%env,$bornum,$itemno);
+    # check status before renewing issue
+    if (CanBookBeRenewed($borrowernumber,$itemno)){
+        AddRenewal($borrowernumber,$itemno,$branch);
     }
+       else {
+               $failedrenews.="&failedrenew=$itemno";        
+       }
 }
 
 #
@@ -59,11 +60,11 @@ foreach my $itemno (@data) {
 #
 if ($input->param('destination') eq "circ"){
     print $input->redirect(
-        '/cgi-bin/koha/circ/circulation.pl?findborrower='.$cardnumber
+        '/cgi-bin/koha/circ/circulation.pl?findborrower='.$cardnumber.$failedrenews
     );
 }
 else {
     print $input->redirect(
-        '/cgi-bin/koha/members/moremember.pl?bornum='.$bornum
+        '/cgi-bin/koha/members/moremember.pl?borrowernumber='.$borrowernumber.$failedrenews
     );
 }