Merge remote-tracking branch 'origin/new/bug_6894'
authorPaul Poulain <paul.poulain@biblibre.com>
Mon, 28 Nov 2011 11:20:58 +0000 (12:20 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 28 Nov 2011 11:20:58 +0000 (12:20 +0100)
38 files changed:
C4/Auth_with_ldap.pm
C4/Bookseller.pm
C4/Circulation.pm
C4/ILSDI/Utility.pm
C4/Members.pm
C4/Overdues.pm
C4/Templates.pm
acqui/supplier.pl
acqui/updatesupplier.pl
circ/circulation.pl
circ/returns.pl
help.pl
installer/InstallAuth.pm
installer/data/mysql/kohastructure.sql
installer/data/mysql/updatedatabase.pl
installer/install.pl
koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
kohaversion.pl
members/memberentry.pl
members/moremember.pl
members/setdebar.pl
members/setstatus.pl
misc/cronjobs/overdue_notices.pl
misc/stage_biblios_file.pl
opac/opac-detail.pl
opac/opac-reserve.pl
opac/opac-showreviews.pl
opac/opac-user.pl
t/db_dependent/lib/KohaTest/Members/DebarMember.pm
xt/author/translatable-templates.t

index 7f56d9c..4749d72 100644 (file)
@@ -356,7 +356,8 @@ C4::Auth - Authenticates Koha users
                | dateexpiry          | date         | YES  |     | NULL    |                |
                | gonenoaddress       | tinyint(1)   | YES  |     | NULL    |                |
                | lost                | tinyint(1)   | YES  |     | NULL    |                |
-               | debarred            | tinyint(1)   | YES  |     | NULL    |                |
+               | debarred            | date         | YES  |     | NULL    |                |
+               | debarredcomment     | varchar(255) | YES  |     | NULL    |                |
                | contactname         | mediumtext   | YES  |     | NULL    |                |
                | contactfirstname    | text         | YES  |     | NULL    |                |
                | contacttitle        | text         | YES  |     | NULL    |                |
index 4ad42cb..6a91f99 100644 (file)
@@ -65,7 +65,7 @@ sub GetBookSeller {
     $searchstring = q{%} . $searchstring . q{%};
     my $query =
 'select aqbooksellers.*, count(*) as basketcount from aqbooksellers left join aqbasket '
-      . 'on aqbasket.booksellerid = aqbooksellers.id where name lIke ? group by aqbooksellers.id order by name';
+      . 'on aqbasket.booksellerid = aqbooksellers.id where name like ? group by aqbooksellers.id order by name';
 
     my $dbh           = C4::Context->dbh;
     my $sth           = $dbh->prepare($query);
@@ -141,20 +141,22 @@ sub AddBookseller {
         INSERT INTO aqbooksellers
             (
                 name,      address1,      address2,   address3,      address4,
-                postal,    phone,         fax,        url,           contact,
+                postal,    phone,         accountnumber,   fax,      url,           
+                contact,
                 contpos,   contphone,     contfax,    contaltphone,  contemail,
                 contnotes, active,        listprice,  invoiceprice,  gstreg,
                 listincgst,invoiceincgst, gstrate,    discount,
                 notes
             )
-        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
+        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
       ;
     my $sth = $dbh->prepare($query);
     $sth->execute(
         $data->{'name'},         $data->{'address1'},
         $data->{'address2'},     $data->{'address3'},
         $data->{'address4'},     $data->{'postal'},
-        $data->{'phone'},        $data->{'fax'},
+        $data->{'phone'},        $data->{'accountnumber'},
+        $data->{'fax'},
         $data->{'url'},          $data->{'contact'},
         $data->{'contpos'},      $data->{'contphone'},
         $data->{'contfax'},      $data->{'contaltphone'},
@@ -192,7 +194,7 @@ sub ModBookseller {
     my $dbh    = C4::Context->dbh;
     my $query  = 'UPDATE aqbooksellers
         SET name=?,address1=?,address2=?,address3=?,address4=?,
-            postal=?,phone=?,fax=?,url=?,contact=?,contpos=?,
+            postal=?,phone=?,accountnumber=?,fax=?,url=?,contact=?,contpos=?,
             contphone=?,contfax=?,contaltphone=?,contemail=?,
             contnotes=?,active=?,listprice=?, invoiceprice=?,
             gstreg=?,listincgst=?,invoiceincgst=?,
@@ -203,7 +205,8 @@ sub ModBookseller {
         $data->{'name'},         $data->{'address1'},
         $data->{'address2'},     $data->{'address3'},
         $data->{'address4'},     $data->{'postal'},
-        $data->{'phone'},        $data->{'fax'},
+        $data->{'phone'},        $data->{'accountnumber'},
+        $data->{'fax'},
         $data->{'url'},          $data->{'contact'},
         $data->{'contpos'},      $data->{'contphone'},
         $data->{'contfax'},      $data->{'contaltphone'},
index d2c5f59..debef01 100644 (file)
@@ -42,6 +42,7 @@ use Date::Calc qw(
   Date_to_Days
   Day_of_Week
   Add_Delta_Days       
+  check_date
 );
 use POSIX qw(strftime);
 use C4::Branch; # GetBranches
@@ -1631,6 +1632,10 @@ sub AddReturn {
     if ($borrowernumber) {
         my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox);
         defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!";  # zero is OK, check defined
+        
+        # fix fine days
+        my $debardate = _FixFineDaysOnReturn( $borrower, $item, $issue->{date_due} );
+        $messages->{'Debarred'} = $debardate if ($debardate);
     }
 
     # find reserves.....
@@ -1754,6 +1759,61 @@ sub MarkIssueReturned {
     $sth_del->execute($borrowernumber, $itemnumber);
 }
 
+=head2 _FixFineDaysOnReturn
+
+    &_FixFineDaysOnReturn($borrower, $item, $datedue);
+
+C<$borrower> borrower hashref
+
+C<$item> item hashref
+
+C<$datedue> date due
+
+Internal function, called only by AddReturn that calculate and update the user fine days, and debars him
+
+=cut
+
+sub _FixFineDaysOnReturn {
+    my ( $borrower, $item, $datedue ) = @_;
+
+    if ($datedue) {
+        $datedue = C4::Dates->new( $datedue, "iso" );
+    } else {
+        return;
+    }
+
+    my $branchcode = _GetCircControlBranch( $item, $borrower );
+    my $calendar = C4::Calendar->new( branchcode => $branchcode );
+    my $today = C4::Dates->new();
+
+    my $deltadays = $calendar->daysBetween( $datedue, C4::Dates->new() );
+
+    my $circcontrol = C4::Context::preference('CircControl');
+    my $issuingrule = GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
+    my $finedays    = $issuingrule->{finedays};
+
+    # exit if no finedays defined
+    return unless $finedays;
+    my $grace = $issuingrule->{firstremind};
+
+    if ( $deltadays - $grace > 0 ) {
+        my @newdate = Add_Delta_Days( Today(), $deltadays * $finedays );
+        my $isonewdate = join( '-', @newdate );
+        my ( $deby, $debm, $debd ) = split( /-/, $borrower->{debarred} );
+        if ( check_date( $deby, $debm, $debd ) ) {
+            my @olddate = split( /-/, $borrower->{debarred} );
+
+            if ( Delta_Days( @olddate, @newdate ) > 0 ) {
+                C4::Members::DebarMember( $borrower->{borrowernumber}, $isonewdate );
+                return $isonewdate;
+            }
+        } else {
+            C4::Members::DebarMember( $borrower->{borrowernumber}, $isonewdate );
+            return $isonewdate;
+        }
+    }
+}
+
 =head2 _FixOverduesOnReturn
 
    &_FixOverduesOnReturn($brn,$itm, $exemptfine, $dropboxmode);
index 8ee1224..bacabac 100644 (file)
@@ -94,7 +94,7 @@ sub CanBookBeReserved {
     if ( $borrower->{lost} eq 1 ) {
         $out = undef;
     }
-    if ( $borrower->{debarred} eq 1 ) {
+    if ( $borrower->{debarred} ) {
         $out = undef;
     }
     my @reserves = GetReservesFromBorrowernumber( $borrower->{'borrowernumber'} );
index 4f5a299..8bd7b47 100644 (file)
@@ -25,7 +25,7 @@ use strict;
 use C4::Context;
 use C4::Dates qw(format_date_in_iso);
 use Digest::MD5 qw(md5_base64);
-use Date::Calc qw/Today Add_Delta_YM/;
+use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
 use C4::Log; # logaction
 use C4::Overdues;
 use C4::Reserves;
@@ -451,13 +451,15 @@ sub patronflags {
         $flaginfo{'noissues'} = 1;
         $flags{'LOST'}        = \%flaginfo;
     }
-    if (   $patroninformation->{'debarred'}
-        && $patroninformation->{'debarred'} == 1 )
-    {
-        my %flaginfo;
-        $flaginfo{'message'}  = 'Borrower is Debarred.';
-        $flaginfo{'noissues'} = 1;
-        $flags{'DBARRED'}     = \%flaginfo;
+    if ( $patroninformation->{'debarred'} && check_date( split( /-/, $patroninformation->{'debarred'} ) ) ) {
+        if ( Date_to_Days(Date::Calc::Today) < Date_to_Days( split( /-/, $patroninformation->{'debarred'} ) ) ) {
+            my %flaginfo;
+            $flaginfo{'debarredcomment'} = $patroninformation->{'debarredcomment'};
+            $flaginfo{'message'}         = $patroninformation->{'debarredcomment'};
+            $flaginfo{'noissues'}        = 1;
+            $flaginfo{'dateend'}         = $patroninformation->{'debarred'};
+            $flags{'DBARRED'}           = \%flaginfo;
+        }
     }
     if (   $patroninformation->{'borrowernotes'}
         && $patroninformation->{'borrowernotes'} )
@@ -623,39 +625,12 @@ sub IsMemberBlocked {
     my $borrowernumber = shift;
     my $dbh            = C4::Context->dbh;
 
-    # does patron have current fine days?
-       my $strsth=qq{
-            SELECT
-            ADDDATE(returndate, finedays * DATEDIFF(returndate,date_due) ) AS blockingdate,
-            DATEDIFF(ADDDATE(returndate, finedays * DATEDIFF(returndate,date_due)),NOW()) AS blockedcount
-            FROM old_issues
-       };
-    if(C4::Context->preference("item-level_itypes")){
-        $strsth.=
-               qq{ LEFT JOIN items ON (items.itemnumber=old_issues.itemnumber)
-            LEFT JOIN issuingrules ON (issuingrules.itemtype=items.itype)}
-    }else{
-        $strsth .= 
-               qq{ LEFT JOIN items ON (items.itemnumber=old_issues.itemnumber)
-            LEFT JOIN biblioitems ON (biblioitems.biblioitemnumber=items.biblioitemnumber)
-            LEFT JOIN issuingrules ON (issuingrules.itemtype=biblioitems.itemtype) };
-    }
-       $strsth.=
-        qq{ WHERE finedays IS NOT NULL
-            AND  date_due < returndate
-            AND borrowernumber = ?
-            ORDER BY blockingdate DESC, blockedcount DESC
-            LIMIT 1};
-       my $sth=$dbh->prepare($strsth);
-    $sth->execute($borrowernumber);
-    my $row = $sth->fetchrow_hashref;
-    my $blockeddate  = $row->{'blockeddate'};
-    my $blockedcount = $row->{'blockedcount'};
+    my $blockeddate = CheckBorrowerDebarred($borrowernumber);
 
-    return (1, $blockedcount) if $blockedcount > 0;
+    return ( 1, $blockeddate ) if $blockeddate;
 
     # if he have late issues
-    $sth = $dbh->prepare(
+    my $sth = $dbh->prepare(
         "SELECT COUNT(*) as latedocs
          FROM issues
          WHERE borrowernumber = ?
@@ -664,9 +639,9 @@ sub IsMemberBlocked {
     $sth->execute($borrowernumber);
     my $latedocs = $sth->fetchrow_hashref->{'latedocs'};
 
-    return (-1, $latedocs) if $latedocs > 0;
+    return ( -1, $latedocs ) if $latedocs > 0;
 
-    return (0, 0);
+    return ( 0, 0 );
 }
 
 =head2 GetMemberIssuesAndFines
@@ -2078,7 +2053,7 @@ sub GetBorrowersNamesAndLatestIssue {
 
 =head2 DebarMember
 
-  my $success = DebarMember( $borrowernumber );
+my $success = DebarMember( $borrowernumber, $todate );
 
 marks a Member as debarred, and therefore unable to checkout any more
 items.
@@ -2090,13 +2065,16 @@ true on success, false on failure
 
 sub DebarMember {
     my $borrowernumber = shift;
+    my $todate         = shift;
 
     return unless defined $borrowernumber;
     return unless $borrowernumber =~ /^\d+$/;
 
-    return ModMember( borrowernumber => $borrowernumber,
-                      debarred       => 1 );
-    
+    return ModMember(
+        borrowernumber => $borrowernumber,
+        debarred       => $todate
+    );
+
 }
 
 =head2 ModPrivacy
index 9f4b22f..7e9b9c9 100644 (file)
@@ -1077,16 +1077,17 @@ sub CheckBorrowerDebarred {
         SELECT debarred
         FROM borrowers
         WHERE borrowernumber=?
+        AND debarred > NOW()
     |;
     my $sth = $dbh->prepare($query);
     $sth->execute($borrowernumber);
-    my ($debarredstatus) = $sth->fetchrow;
-    return ( $debarredstatus eq '1' ? 1 : 0 );
+    my $debarredstatus = $sth->fetchrow;
+    return $debarredstatus;
 }
 
 =head2 UpdateBorrowerDebarred
 
-    ($borrowerstatut) = &UpdateBorrowerDebarred($borrowernumber);
+($borrowerstatut) = &UpdateBorrowerDebarred($borrowernumber, $todate);
 
 update status of borrowers in borrowers table (field debarred)
 
@@ -1095,16 +1096,16 @@ C<$borrowernumber> borrower number
 =cut
 
 sub UpdateBorrowerDebarred{
-    my($borrowernumber) = @_;
-    my $dbh = C4::Context->dbh;
-        my $query=qq|UPDATE borrowers
-             SET debarred='1'
+    my ( $borrowernumber, $todate ) = @_;
+    my $dbh   = C4::Context->dbh;
+    my $query = qq|UPDATE borrowers
+             SET debarred=?
                      WHERE borrowernumber=?
             |;
-    my $sth=$dbh->prepare($query);
-        $sth->execute($borrowernumber);
-        $sth->finish;
-        return 1;
+    my $sth = $dbh->prepare($query);
+    $sth->execute( $todate, $borrowernumber );
+    $sth->finish;
+    return 1;
 }
 
 =head2 CheckExistantNotifyid
index c2a5911..73d94c2 100644 (file)
@@ -277,8 +277,7 @@ sub themelanguage {
     my @languages = split(",", C4::Context->preference(
         $is_intranet ? 'language' : 'opaclanguages'));
     my $lang;
-    $lang = $query->cookie('KohaOpacLanguage')
-        if defined $query and $query->cookie('KohaOpacLanguage');
+    $lang = getlanguagecookie($query);
     unless ($lang) {
         my $http_accept_language = $ENV{ HTTP_ACCEPT_LANGUAGE };
         $lang = accept_language( $http_accept_language, 
@@ -327,8 +326,7 @@ sub getlanguagecookie {
         $lang = $ENV{HTTP_ACCEPT_LANGUAGE};
         
     }
-    $lang = substr($lang, 0, 2);
-
+    $lang =~ s/[^a-zA-Z_-]*//; #sanitzie
     return $lang;
 }
 
index 44ff250..3faa560 100755 (executable)
@@ -93,6 +93,7 @@ if ( $op eq 'display' ) {
         address3      => $supplier->{'address3'},
         address4      => $supplier->{'address4'},
         phone         => $supplier->{'phone'},
+        accountnumber => $supplier->{'accountnumber'},
         fax           => $supplier->{'fax'},
         url           => $supplier->{'url'},
         contact       => $supplier->{'contact'},
@@ -152,6 +153,7 @@ if ( $op eq 'display' ) {
         address3     => $supplier->{'address3'},
         address4     => $supplier->{'address4'},
         phone        => $supplier->{'phone'},
+        accountnumber=> $supplier->{'accountnumber'},
         fax          => $supplier->{'fax'},
         url          => $supplier->{'url'},
         contact      => $supplier->{'contact'},
index 6bc978f..bd59c6b 100755 (executable)
@@ -80,6 +80,7 @@ $data{'address2'}=$addresses[1];
 $data{'address3'}=$addresses[2];
 $data{'address4'}=$addresses[3];
 $data{'phone'}=$input->param('company_phone');
+$data{'accountnumber'}=$input->param('accountnumber');
 $data{'fax'}=$input->param('company_fax');
 $data{'url'}=$input->param('website');
 $data{'contact'}=$input->param('company_contact_name');
index 378956e..fa043dd 100755 (executable)
@@ -30,6 +30,7 @@ use C4::Dates qw/format_date/;
 use C4::Branch; # GetBranches
 use C4::Koha;   # GetPrinter
 use C4::Circulation;
+use C4::Overdues qw/CheckBorrowerDebarred/;
 use C4::Members;
 use C4::Biblio;
 use C4::Reserves;
@@ -260,6 +261,16 @@ if ($borrowernumber) {
         issuecount   => $issue,
         finetotal    => $fines
     );
+
+    my $debar = CheckBorrowerDebarred($borrowernumber);
+    if ($debar) {
+        $template->param( 'userdebarred'    => 1 );
+        $template->param( 'debarredcomment' => $borrower->{debarredcomment} );
+        if ( $debar ne "9999-12-31" ) {
+            $template->param( 'userdebarreddate' => C4::Dates::format_date($debar) );
+        }
+    }
+
 }
 
 #
index afe574f..98d310e 100755 (executable)
@@ -459,7 +459,12 @@ foreach my $code ( keys %$messages ) {
     }
     elsif ( $code eq 'Wrongbranch' ) {
     }
-
+    elsif ( $code eq 'Debarred' ) {
+        $err{debarred}            = format_date( $messages->{'Debarred'} );
+        $err{debarcardnumber}     = $borrower->{cardnumber};
+        $err{debarborrowernumber} = $borrower->{borrowernumber};
+        $err{debarname}           = "$borrower->{firstname} $borrower->{surname}";
+    }
     else {
         die "Unknown error code $code";    # note we need all the (empty) elsif's above, or we die.
         # This forces the issue of staying in sync w/ Circulation.pm
diff --git a/help.pl b/help.pl
index 18d27dd..97f3462 100755 (executable)
--- a/help.pl
+++ b/help.pl
@@ -32,7 +32,9 @@ our $refer = $query->param('url');
 $refer = $query->referer()  if !$refer || $refer eq 'undefined';
 
 $refer =~ /koha\/(.*)\.pl/;
-my $from = "help/$1.tt";
+my $file = $1;
+$file =~ s/[^a-zA-Z0-9_\-\/]*//g;
+my $from = "help/$file.tt";
 
 my $template = C4::Templates::gettemplate($from, 'intranet', $query);
 $template->param( referer => $refer );
index 2c07bbe..10cbea3 100644 (file)
@@ -117,7 +117,7 @@ sub get_template_and_user {
     $tmplbase=~ s/\.tmpl$/.tt/;
     my $filename = "$path/modules/" . $tmplbase;
     my $interface = 'intranet';
-    my $template = C4::Templates->new( $interface, $filename, $tmplbase);
+    my $template = C4::Templates->new( $interface, $filename, $tmplbase, $query);
     
     my ( $user, $cookie, $sessionID, $flags ) = checkauth(
         $in->{'query'},
@@ -158,12 +158,14 @@ sub get_template_and_user {
 }
 
 sub _get_template_language {
-  #verify if opac language exists in staff (bug 5660)
-  #conditions are 1) dir exists and 2) enabled in prefs
-  my ($opaclang)= @_;
-  return 'en' unless $opaclang;
-  my $path= C4::Context->config('intrahtdocs')."/prog/$opaclang";
-  -d $path ? $opaclang : 'en';
+
+    #verify if opac language exists in staff (bug 5660)
+    #conditions are 1) dir exists and 2) enabled in prefs
+    my ($opaclang) = @_;
+    return 'en' unless $opaclang;
+    $opaclang =~ s/[^a-zA-Z_-]*//g;
+    my $path = C4::Context->config('intrahtdocs') . "/prog/$opaclang";
+    -d $path ? $opaclang : 'en';
 }
 
 =item checkauth
@@ -365,7 +367,7 @@ sub checkauth {
     my $filename = "$path/modules/$template_name";
     $filename =~ s/\.tmpl$/.tt/;
     my $interface = 'intranet';
-    my $template = C4::Templates->new( $interface, $filename);
+    my $template = C4::Templates->new( $interface, $filename, '', $query);
     $template->param(
         INPUTS => \@inputs,
 
index e4388a4..452173d 100644 (file)
@@ -232,7 +232,8 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons
   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
   `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address
   `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
-  `debarred` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as being restricted
+  `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD)
+  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron
   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
   `contactfirstname` text, -- used for children to include first name of guarentor
   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
@@ -693,7 +694,8 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower
   `dateexpiry` date default NULL, -- date the patron/borrower's card is set to expire (YYYY-MM-DD)
   `gonenoaddress` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having an unconfirmed address
   `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card
-  `debarred` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as being restricted
+  `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD)
+  `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron
   `contactname` mediumtext, -- used for children and profesionals to include surname or last name of guarentor or organization name
   `contactfirstname` text, -- used for children to include first name of guarentor
   `contacttitle` text, -- used for children to include title (Mr., Mrs., etc) of guarentor
index 815a71d..efa9898 100755 (executable)
@@ -4438,6 +4438,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion($DBversion);
 }
 
+
 $DBversion = "3.05.00.011";
 if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACResultsSidebar','','Define HTML to be included on the search results page, underneath the facets sidebar','70|10','Textarea')");
@@ -4550,6 +4551,20 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.06.00.001";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    my $borrowers = $dbh->selectcol_arrayref( "SELECT borrowernumber from borrowers where debarred <>0;", { Columns => [1] } );
+    $dbh->do("ALTER TABLE borrowers MODIFY debarred DATE DEFAULT NULL;");
+    $dbh->do( "UPDATE borrowers set debarred='9999-12-31' where borrowernumber IN (" . join( ",", @$borrowers ) . ");" ) if ($borrowers and scalar(@$borrowers)>0);
+    $dbh->do("ALTER TABLE borrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
+    $dbh->do("ALTER TABLE deletedborrowers MODIFY debarred DATE DEFAULT NULL;");
+    $dbh->do("ALTER TABLE deletedborrowers ADD COLUMN debarredcomment VARCHAR(255) DEFAULT NULL AFTER debarred;");
+    print "Upgrade done (Change borrowers.debarred into Date )\n";
+
+    SetVersion($DBversion);
+}
+
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)
index 5b065e8..ae478b6 100755 (executable)
@@ -229,6 +229,7 @@ elsif ( $step && $step == 3 ) {
         # Framework Selection is achieved through checking boxes.
         my $langchoice = $query->param('fwklanguage');
         $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice);
+       $langchoice =~ s/[^a-zA-Z_-]*//g;
         my $marcflavour = $query->param('marcflavour');
         if ($marcflavour){
             $installer->set_marcflavour_syspref($marcflavour);
@@ -266,6 +267,7 @@ elsif ( $step && $step == 3 ) {
         # Marcflavour Selection is achieved through radiobuttons.
         my $langchoice = $query->param('fwklanguage');
         $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice);
+       $langchoice =~ s/[^a-zA-Z_-]*//g;
         my $dir =
           C4::Context->config('intranetdir') . "/installer/data/$info{dbms}/$langchoice/marcflavour";
         unless (opendir( MYDIR, $dir )) {
index 972393d..2933544 100644 (file)
@@ -65,7 +65,7 @@ function update_child() {
                        { text: _("Renew Patron"),  onclick: { fn: confirm_reregistration } },
                        { text: _("Set Permissions"), url: "/cgi-bin/koha/members/member-flags.pl?member=[% borrowernumber %]"[% UNLESS CAN_user_permissions %], disabled: true[% END %]},
             { text: _("Delete"), [% UNLESS CAN_user_borrowers %]disabled: true, [% END %] onclick: { fn: confirm_deletion } },
-                       { text: _("Update Child to Adult Patron") , onclick: { fn: update_child }[% UNLESS is_child" %], disabled: true[% END %]}
+                       { text: _("Update Child to Adult Patron") , onclick: { fn: update_child }[% UNLESS is_child %], disabled: true[% END %]}
                ];
 
            new YAHOO.widget.Button({
index 9c76b7c..f30d839 100644 (file)
@@ -53,7 +53,9 @@ if (f.company.value == "") {
             <li><label for="company_fax">Fax</label>
                 <input type="text" size="20" id="company_fax" name="company_fax" value="[% fax %]" /></li>
             <li><label for="website">Website</label>
-                <input type="text" size="40" id="website" name="website" value="[% url %]" /></li></ol>
+                <input type="text" size="40" id="website" name="website" value="[% url %]" /></li>
+            <li><label for="accountnumber">Account number</label>
+                <input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol>
         </fieldset>
         <fieldset class="rows">
             <legend>Contact details</legend>
@@ -136,7 +138,7 @@ if (f.company.value == "") {
                 <input type="text" size="6" id="discount" name="discount" value="[% discount %]" />%</li>
             <li><label for="gstrate">Tax rate</label><input type="text" name="gstrate" id="gstrate" size="6" value="[% gstrate %]"/>% (leave blank for default tax of [% default_gst_rate %]%)</li>
             <li><label for="notes">Notes</label>
-                <textarea cols="40" rows="4" id="notes" name="notes" >[% notes %]</textarea></li></ol>                 
+                <textarea cols="40" rows="4" id="notes" name="notes" >[% notes %]</textarea></li></ol>
         </fieldset>
         <fieldset class="action"><input type="button" value="Save" onclick="check(this.form);" /> [% IF ( id ) %]
         <a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?supplierid=[% id %]">[% ELSE %]<a class="cancel" href="/cgi-bin/koha/acqui/acqui-home.pl">
@@ -154,7 +156,10 @@ if (f.company.value == "") {
                 <p><span class="label">Phone: </span>[% phone %]</p>
                 <p><span class="label">Fax: </span>[% fax %]</p>
                 [% IF ( url ) %]
-                    <p><span class="label">Web site: </span><a href="[% url %]">[% url %]</a></p>
+                    <p><span class="label">Website: </span><a href="[% url %]">[% url %]</a></p>
+                [% END %]
+                [% IF ( accountnumber ) %]
+                    <p><span class="label">Account number: </span>[% accountnumber %]</p>
                 [% END %]
             </div>
             <div id="supplier-contact-details" class="yui-u">
index b1e225f..019fa10 100644 (file)
@@ -114,7 +114,7 @@ function verify_images() {
         [% IF ( MARCAUTHORS ) %]
             <li><strong>Additional Authors:</strong><ul>
             [% FOREACH MARCAUTHOR IN MARCAUTHORS %]
-                <li>[% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %][% MARCAUTHOR_SUBFIELDS_LOO.separator %]<a title="&#8225;[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value |url %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit %]:[% link_loo.link |url %][% END %]">[% MARCAUTHOR_SUBFIELDS_LOO.value %]</a>[% END %]</li>
+                <li>[% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %][% MARCAUTHOR_SUBFIELDS_LOO.separator %]<a title="‡[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value |url %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit %]:[% link_loo.link |url %][% END %]">[% MARCAUTHOR_SUBFIELDS_LOO.value %]</a>[% END %]</li>
                 [% END %]
 
         </ul>
@@ -183,7 +183,7 @@ function verify_images() {
             <li><strong>Subjects:</strong> 
             <ul>
                 [% FOREACH MARCSUBJCT IN MARCSUBJCTS %]
-                <li>[% FOREACH MARCSUBJECT_SUBFIELDS_LOO IN MARCSUBJCT.MARCSUBJECT_SUBFIELDS_LOOP %] [% MARCSUBJECT_SUBFIELDS_LOO.separator %] <a title="&#8225;[% MARCSUBJECT_SUBFIELDS_LOO.code %] [% MARCSUBJECT_SUBFIELDS_LOO.value %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCSUBJECT_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit %]:[% link_loo.link |url %][% END %]">[% MARCSUBJECT_SUBFIELDS_LOO.value |html %]</a>[% END %]</li>
+                <li>[% FOREACH MARCSUBJECT_SUBFIELDS_LOO IN MARCSUBJCT.MARCSUBJECT_SUBFIELDS_LOOP %] [% MARCSUBJECT_SUBFIELDS_LOO.separator %] <a title="‡[% MARCSUBJECT_SUBFIELDS_LOO.code %] [% MARCSUBJECT_SUBFIELDS_LOO.value %]" href="/cgi-bin/koha/catalogue/search.pl?q=[% FOREACH link_loo IN MARCSUBJECT_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit %]:[% link_loo.link |url %][% END %]">[% MARCSUBJECT_SUBFIELDS_LOO.value |html %]</a>[% END %]</li>
                 [% END %]
                 </ul>
             </li>
index f98ff1d..5627109 100644 (file)
@@ -563,9 +563,16 @@ No patron matched <span class="ex">[% message %]</span>
                        <li class="blocker"><span class="circ-hlt">Lost: </span>Patron's card is lost</li>
                        [% END %]
 
-            [% IF ( dbarred ) %]<li class="blocker">
-               <span class="circ-hlt"> Restricted:</span> Patron's account is restricted <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% borrowernumber %]&amp;cardnumber=[% cardnumber %]&amp;destination=circ&amp;status=0">Lift restriction</a>
-</li>[% END %]
+            [% IF ( userdebarred ) %]
+               <li class="blocker">
+               <span class="circ-hlt"> Restricted:</span> Patron's account is restricted [% IF (userdebarreddate ) %] until [% userdebarreddate %] [% END %] [% IF (debarredcomment ) %]([% debarredcomment %])[% END %]
+               <form class="inline compact" action="/cgi-bin/koha/members/setstatus.pl" method="post">
+                       <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+                       <input type="hidden" name="destination" value="circ" />
+                       <input type="hidden" name="cardnumber" value="[% cardnumber %]" />
+                       <input type="submit" value="Lift Debarment" />
+               </form>
+                       </li>[% END %]
 
                [% IF ( odues ) %]<li>[% IF ( nonreturns ) %]<span class="circ-hlt">Overdues:</span> Patron has <span class="circ-hlt">ITEMS OVERDUE</span>. See highlighted items <a href="#checkouts">below</a>[% END %]</li>
             [% END %]
index 65df373..70367ae 100644 (file)
@@ -321,6 +321,9 @@ function Dopop(link) {
                     [% IF ( errmsgloo.withdrawn ) %]
                         <p class="problem">Item is withdrawn.</p>
                     [% END %]
+                    [% IF ( errmsgloo.debarred ) %]
+                        <p class="problem"><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% errmsgloo.debarborrowernumber %]">[% errmsgloo.debarname %]([% errmsgloo.debarcardnumber %])</a> is now debarred until [% errmsgloo.debarred %] </p>
+                    [% END %]
             [% END %]
 [% IF ( soundon ) %]
 <audio src="/intranet-tmpl/prog/sound/critical.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio>
index 47ea6c9..b9371b6 100644 (file)
                                <input type="radio" id="no[% flagloo.name %]" name="[% flagloo.name %]" value="0" />
                                [% END %]
 
-</li>
+            </li>
                        [% END %]
+                       <li>
+                               <label for="yesdebarred" class="radio">Debarred: </label>
+                               [% IF ( 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"/>
+                               [% 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"/>
+                               [% END %]
+                               
+                               <br />
+                               <label for="datedebarred" class="radio">until:</label> 
+                               [% IF opduplicate %]
+                                   <input type="text" name="datedebarred" id="debarred" class="debarred" value="[% datedebarred %]" onclick="this.value=''" />
+                               [% ELSE %]
+                                   <input type="text" name="datedebarred" id="debarred" class="debarred" value="[% datedebarred %]" />
+                               [% END %]
+                               <img src="[% themelang %]/lib/calendar/cal.gif" id="debarred_button" alt="Show Calendar" />
+                        <script language="JavaScript" type="text/javascript">
+                           Calendar.setup(
+                           {
+                               inputField : "debarred",
+                               ifFormat : "[% DHTMLcalendar_dateformat %]",
+                               button : "debarred_button"
+                           }
+                           );
+                       </script>
+                       <br />
+                       <label for="debarredcomment" class="radio">Comment:</label>
+                              [% IF ( opduplicate ) %] 
+                                  <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" onclick="this.value=''">[% debarredcomment %]</textarea>
+                              [% ELSE %]
+                                  <textarea id="debarredcomment" name="debarredcomment" cols="55" rows="3" ">[% debarredcomment %]</textarea> 
+                              [% END %]
+               </li>
+
                        </ol>
                        </fieldset>
+    
                [% END %]       
 
 [% END %]
index cce4cd9..454032c 100644 (file)
@@ -164,12 +164,11 @@ function validate1(date) {
 
     [% IF ( flagged ) %]
     <ul>
-        [% IF ( debarred ) %]
-            <li>Patron is restricted
+        [% IF ( userdebarred ) %]
+            <li>Patron is restricted[% IF ( userdebarreddate ) %] until [% userdebarreddate%] [% IF (debarredcomment ) %]([% debarredcomment %])[% END %][% END %]
             <form class="inline compact" action="/cgi-bin/koha/members/setdebar.pl" method="post">
                 <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
-                <input type="hidden" name="status" value="0" />
-                <input type="submit" value="Lift Restriction" />
+                <input type="submit" value="Lift Debarment" />
             </form>
             </li>
         [% END %]
index 8cba98b..3175d47 100755 (executable)
@@ -266,7 +266,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
     [% IF ( MARCAUTHORS ) %]
     <span class="results_summary"><span class="label">Authors:</span>
                 [% FOREACH MARCAUTHOR IN MARCAUTHORS %]
-                [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %][% MARCAUTHOR_SUBFIELDS_LOO.separator %]<a title="&#8225;[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value %]" href="/cgi-bin/koha/opac-search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit |url %]:[% link_loo.link |url %][% END %]">[% MARCAUTHOR_SUBFIELDS_LOO.value %]</a>[% END %] 
+                [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %][% MARCAUTHOR_SUBFIELDS_LOO.separator %]<a title="‡[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value %]" href="/cgi-bin/koha/opac-search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit |url %]:[% link_loo.link |url %][% END %]">[% MARCAUTHOR_SUBFIELDS_LOO.value %]</a>[% END %] 
         [% UNLESS ( loop.last ) %]|
 [% END %]
                 [% END %]
index daa5636..0971f46 100644 (file)
@@ -93,7 +93,7 @@ $.tablesorter.addParser({
                <div class="dialog alert">
         <ul>
             [% IF ( BORROWER_INF.debarred ) %]
-                <li><strong>Please note:</strong> Your account has been frozen. Usually the reason for freezing an account is old overdues or damage fees.If <a href="/cgi-bin/koha/opac-user.pl">your account page</a> shows your account to be clear, please contact the library.</li>
+                <li><strong>Please note:</strong> Your account has been frozen until [% BORROWER_INF.debarred %] - [% BORROWER_INF.debarredcomment %]. Usually the reason for freezing an account is old overdues or damage fees.If <a href="/cgi-bin/koha/opac-user.pl">your account page</a> shows your account to be clear, please contact the library.</li>
             [% END %]
             [% IF ( BORROWER_INF.gonenoaddress ) %]
                 <li><strong>Please note:</strong> According to our records, we don't have up-to-date [% UNLESS ( BORROWER_INF.OPACPatronDetails ) %]<a href="/cgi-bin/koha/opac-userupdate.pl">contact information</a>[% ELSE %]contact information[% END %] on file.  Please contact the library[% IF ( BORROWER_INF.OPACPatronDetails ) %] or use the <a href="/cgi-bin/koha/opac-userupdate.pl">online update form</a> to submit current information (<em>Please note:</em> there may be a delay in restoring your account if you submit online)[% END %].</li>
index 9075247..61ff87f 100644 (file)
@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
 use strict;
 
 sub kohaversion {
-    our $VERSION = '3.06.00.000';
+    our $VERSION = '3.06.00.001';
     # version needs to be set this way
     # so that it can be picked up by Makefile.PL
     # during install
index f01261e..d169dbd 100755 (executable)
@@ -131,6 +131,17 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' )
             $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} );
+    }
+    
     my $dateobject = C4::Dates->new();
     my $syspref = $dateobject->regexp();               # same syspref format for all 3 dates
     my $iso     = $dateobject->regexp('iso');  #
@@ -515,8 +526,7 @@ while (@relationships) {
 }
 
 my %flags = ( 'gonenoaddress' => ['gonenoaddress' ],
-        'lost'          => ['lost'],
-        'debarred'      => ['debarred']);
+        'lost'          => ['lost']);
 
  
 my @flagdata;
@@ -637,7 +647,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 datedebarred)) {
        $data{$_} = format_date($data{$_});     # back to syspref for display
        $template->param( $_ => $data{$_});
 }
index f264377..6e5407c 100755 (executable)
@@ -49,6 +49,7 @@ use C4::Letters;
 use C4::Biblio;
 use C4::Reserves;
 use C4::Branch; # GetBranchName
+use C4::Overdues qw/CheckBorrowerDebarred/;
 use C4::Form::MessagingPreferences;
 use C4::NewsChannels; #get slip news
 use List::MoreUtils qw/uniq/;
@@ -146,10 +147,19 @@ foreach (qw(dateenrolled dateexpiry dateofbirth)) {
 }
 $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;
 
index b12ab57..bc0bafb 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/perl
 
 # Copyright 2000-2002 Katipo Communications
+# Parts copyright 2011 BibLibre
 #
 # This file is part of Koha.
 #
@@ -40,22 +41,13 @@ $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 );
+  $dbh->prepare("Update borrowers set debarred = NULL where borrowernumber = ?");
+$sth->execute( $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");
-}
+print $input->redirect(
+    "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");
index addeeb3..a45a331 100755 (executable)
@@ -51,8 +51,8 @@ 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 = ?");
-       $sth->execute($status,$borrowernumber); 
+    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
+    $sth->execute( $status, $borrowernumber );
        $sth->finish;
        }
 
index 37774b5..5646efc 100755 (executable)
@@ -473,7 +473,7 @@ END_SQL
                 if ( $overdue_rules->{"debarred$i"} ) {
     
                     #action taken is debarring
-                    C4::Members::DebarMember($borrowernumber);
+                    C4::Members::DebarMember($borrowernumber, '9999-12-31');
                     $verbose and warn "debarring $borrowernumber $firstname $lastname\n";
                 }
                 my @params = ($listall ? ( $borrowernumber , 1 , $MAX ) : ( $borrowernumber, $mindays, $maxdays ));
index 3f18082..6e2b30c 100755 (executable)
@@ -1,7 +1,25 @@
 #!/usr/bin/perl
 
+# This file is part of Koha.
+#
+# Copyright (C) 2007 LibLime
+# Parts Copyright BSZ 2011
+#
+# 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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
 use strict;
-#use warnings; FIXME - Bug 2505
+use warnings;
 BEGIN {
     # find Koha's Perl modules
     # test carefully before changing this
@@ -17,6 +35,7 @@ use Getopt::Long;
 $| = 1;
 
 # command-line parameters
+my $encoding = "";
 my $match_bibs = 0;
 my $add_items = 0;
 my $input_file = "";
@@ -25,14 +44,19 @@ my $want_help = 0;
 my $no_replace ;
 
 my $result = GetOptions(
+    'encoding:s'    => \$encoding,
     'file:s'        => \$input_file,
-    'match-bibs:s'    => \$match_bibs,
+    'match-bibs:s'  => \$match_bibs,
     'add-items'     => \$add_items,
     'no-replace'    => \$no_replace,
     'comment:s'     => \$batch_comment,
     'h|help'        => \$want_help
 );
 
+if ($encoding eq "") {
+    $encoding = "utf8";
+}
+
 if (not $result or $input_file eq "" or $want_help) {
     print_usage();
     exit 0;
@@ -67,11 +91,9 @@ sub process_batch {
     }
     close IN;
 
-    my $marc_flavor = C4::Context->preference('marcflavour');
-
     print "... staging MARC records -- please wait\n";
     my ($batch_id, $num_valid, $num_items, @import_errors) = 
-        BatchStageMarcRecords($marc_flavor, $marc_records, $input_file, $batch_comment, '', $add_items, 0,
+        BatchStageMarcRecords($encoding, $marc_records, $input_file, $batch_comment, '', $add_items, 0,
                               100, \&print_progress_and_commit);
     print "... finished staging MARC records\n";
 
@@ -141,6 +163,9 @@ records into the main Koha database.
 
 Parameters:
     --file <file_name>      name of input MARC bib file
+    --encoding <encoding>   encoding of MARC records, default is utf8.
+                            Other possible options are: MARC-8,
+                            ISO_5426, ISO_6937, ISO_8859-1, EUC-KR
     --match-bibs <match_id> use this option to match bibs
                             in the file with bibs already in 
                             the database for future overlay.
index e2fb069..f82dde2 100755 (executable)
@@ -603,9 +603,14 @@ $template->param(
 );
 
 my $libravatar_enabled = 0;
-eval 'use Libravatar::URL';
-if (!$@ and C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) {
-    $libravatar_enabled = 1;
+if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) {
+    eval {
+        require Libravatar::URL;
+        Libravatar::URL->import();
+    };
+    if (!$@ ) {
+        $libravatar_enabled = 1;
+    }
 }
 
 my $reviews = getreviews( $biblionumber, 1 );
index 2713cf3..b2144a9 100755 (executable)
@@ -29,6 +29,7 @@ use C4::Dates qw/format_date/;
 use C4::Context;
 use C4::Members;
 use C4::Branch; # GetBranches
+use C4::Overdues;
 use C4::Debug;
 # use Data::Dumper;
 
@@ -278,7 +279,7 @@ if ( $borr->{lost} && ($borr->{lost} eq 1) ) {
                      lost    => 1
                     );
 }
-if ( $borr->{debarred} && ($borr->{debarred} eq 1) ) {
+if ( CheckBorrowerDebarred($borrowernumber) ) {
     $noreserves = 1;
     $template->param(
                      message  => 1,
index 3a74270..24ac312 100755 (executable)
@@ -66,9 +66,14 @@ if($format eq "rss"){
 }
 
 my $libravatar_enabled = 0;
-eval 'use Libravatar::URL';
-if (!$@ and C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) {
-    $libravatar_enabled = 1;
+if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) {
+    eval {
+        require Libravatar::URL;
+        Libravatar::URL->import();
+    };
+    if ( !$@ ) {
+        $libravatar_enabled = 1;
+    }
 }
 
 my $reviews = getallreviews(1,$offset,$results_per_page);
index ca18288..9806c9f 100755 (executable)
@@ -104,6 +104,7 @@ if ( $borr->{'amountoutstanding'} < 0 ) {
 }
 
 $borr->{'amountoutstanding'} = sprintf "%.02f", $borr->{'amountoutstanding'};
+$borr->{'debarred'} = C4::Dates->new($borr->{'debarred'},'iso')->output;
 
 my @bordat;
 $bordat[0] = $borr;
index 9e27d66..bf61b8a 100644 (file)
@@ -21,7 +21,7 @@ sub simple_usage : Test( 6 ) {
     ok(     ! $details->{'flags'}->{'DBARRED'},          'this member is NOT debarred' );
 
     # Now, let's debar this member and see what happens
-    my $success = C4::Members::DebarMember( $self->{'memberid'} );
+    my $success = C4::Members::DebarMember( $self->{'memberid'}, '2099-12-31' );
 
     ok( $success, 'we were able to debar the member' );
     
index 0c2e477..8079cd6 100644 (file)
@@ -38,8 +38,11 @@ sub test_string_extraction {
     my @warnings;
     while (<PH>) {
         # ignore some noise on STDERR
-        next if /^\.* done\.$/;
-       next if /^\.* terminé\.$/;
+        # the output of msmerge, that consist in .... followed by a "done" (localized), followed by a .
+        # The "done" localized can include diacritics, so ignoring the whole word
+        # FIXME PP: the flow is not correct UTF8, testing \p{IsLetter} does not work, but I think this regexp will do the job
+        next if (/^\.+ .*\.$/);
+        # other Koha-specific catses that should not worry us
         next if /^Warning: Can't determine original templates' charset/;
         next if /^Warning: Charset Out defaulting to/;
         next if /^Removing empty file /;