X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=misc%2Fcronjobs%2Foverdue_notices.pl;h=53f39f436fa2211888b80ff51da0581066133a9d;hb=76d1de381fb51c62e2b85ad25461c116a472651d;hp=e205e1e31eaac2b98844d5f02223eb538ea2eec1;hpb=db85e0437e47f948378efeef13e7ff003215ef4e;p=koha.git diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index e205e1e31e..53f39f436f 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -53,6 +53,8 @@ overdue_notices.pl [ -n ] [ -library ] [ -max ] [ -library only deal with overdues from this library -csv populate CSV file -itemscontent item information in templates + -borcat category code that must be included + -borcatout category code that must be excluded =head1 OPTIONS @@ -104,6 +106,14 @@ defaults to issuedate,title,barcode,author Other possible values come from fields in the biblios, items, and issues tables. +=item B<-borcat> + +Repetable field, that permit to select only few of patrons categories. + +=item B<-borcatout> + +Repetable field, permis to exclude some patrons categories. + =item B<-t> | B<--triggered> This option causes a notice to be generated if and only if @@ -223,6 +233,7 @@ alert them of items that have just become due. # These variables are set by command line options. # They are initially set to default values. +my $dbh = C4::Context->dbh(); my $help = 0; my $man = 0; my $verbose = 0; @@ -233,6 +244,8 @@ my $csvfilename; my $triggered = 0; my $listall = 0; my $itemscontent = join( ',', qw( issuedate title barcode author ) ); +my @myborcat; +my @myborcatout; GetOptions( 'help|?' => \$help, @@ -245,6 +258,8 @@ GetOptions( 'itemscontent=s' => \$itemscontent, 'list-all' => \$listall, 't|triggered' => \$triggered, + 'borcat=s' => \@myborcat, + 'borcatout=s' => \@myborcatout, ) or pod2usage(2); pod2usage(1) if $help; pod2usage( -verbose => 2 ) if $man; @@ -278,7 +293,6 @@ if ($mybranch) { # these are the fields that will be substituted into <> my @item_content_fields = split( /,/, $itemscontent ); -my $dbh = C4::Context->dbh(); binmode( STDOUT, ":utf8" ); our $csv; # the Text::CSV_XS object @@ -314,13 +328,21 @@ SELECT biblio.*, items.*, issues.*, TO_DAYS(NOW())-TO_DAYS(date_due) AS days_ove AND TO_DAYS(NOW())-TO_DAYS(date_due) BETWEEN ? and ? END_SQL - my $rqoverduerules = $dbh->prepare("SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? "); - $rqoverduerules->execute($branchcode); + my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? "; + $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat); + $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout); + + my $rqoverduerules = $dbh->prepare($query); + $rqoverduerules->execute($branchcode, @myborcat, @myborcatout); # We get default rules is there is no rule for this branch if($rqoverduerules->rows == 0){ - $rqoverduerules = $dbh->prepare("SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' "); - $rqoverduerules->execute(); + $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' "; + $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat); + $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout); + + $rqoverduerules = $dbh->prepare($query); + $rqoverduerules->execute(@myborcat, @myborcatout); } # my $outfile = 'overdues_' . ( $mybranch || $branchcode || 'default' );