[Koha-bugs] [Bug 14292] Add --category and --skip-category options to longoverdue.pl to include or exclude borrower categories.
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Sep 24 14:10:03 CEST 2015
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14292
--- Comment #4 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
Comment on attachment 42614
--> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=42614
[SIGNED-OFF] Bug 14292: Add patron category restrictions to longoverdue.pl
Review of attachment 42614:
--> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=14292&attachment=42614)
-----------------------------------------------------------------
::: misc/cronjobs/longoverdue.pl
@@ +52,5 @@
> +GetOptions(
> + 'lost=s%' => \$lost,
> + 'c|charge=s' => \$charge,
> + 'confirm' => \$confirm,
> + 'verbose' => \$verbose,
Doc says v|verbose
@@ +56,5 @@
> + 'verbose' => \$verbose,
> + 'quiet' => \$quiet,
> + 'maxdays=s' => \$endrange,
> + 'mark-returned' => \$mark_returned,
> + 'help' => \$help,
Doc says h|help
@@ +77,5 @@
> +
> + longoverdue.pl [ --help | -h | --man ]
> + longoverdue.pl --lost | -l DAYS=LOST_CODE [ --charge | -c CHARGE_CODE ] [ --verbose | -v ] [ --quiet ]
> + [ --maxdays MAX_DAYS ] [ --mark-returned ] [ --category BORROWER_CATEGOERY ] ...
> + [ --skip-category BORROWER_CATEGOERY ] ... [ --commit ]
Typo 'CATEGOERY'
@@ +141,5 @@
>
> +=back
> +
> +All 'category' options will be applied before any 'skip-category' options, meaning that the only categories available to skip
> +are those which have already been specified on the command line.
Is this really useful? I would say --category and --skip-category could be
mutually exclusive.
That would simplify the related code.
But it seems to work, so keep it if you think it can be useful.
@@ +188,1 @@
> die "ERROR: No --lost (-l) option defined";
This won't work, pod2usage will exist before the die statement.
You should use something like:
pod2usage({
-exitval => 1,
-msg => q|ERROR: No --lost (-l) option defined|,
});
@@ +224,5 @@
> }
>
> +# The following two functions can and should replaced by a call to
> +# Koha::Database.
> +sub borrower_categories_sth {
This can be avoided, we don't need a subroutine to prepare the query :)
@@ +230,5 @@
> + return C4::Context->dbh->prepare($query);
> +}
> +
> +sub defined_borrower_categories {
> + my $sth = borrower_categories_sth();
Actually I think both sub could be replace with:
my $dbh = C4::Context->dbh;
return map { $_->[0] }
@{ $dbh->selectall_arrayref(q|SELECT categorycode FROM categories|) };
@@ +273,4 @@
> #FIXME - Should add a 'system' user and get suitable userenv for it for logging, etc.
>
> my $count;
> +# my @ranges = map {
I would simply remove it :)
@@ +294,5 @@
> $sth_items->execute($startrange, $endrange, $lostvalue);
> $count=0;
> + ITEM: while (my $row=$sth_items->fetchrow_hashref) {
> + if( $filter_borrower_categories ) {
> + my $category = uc Koha::Database->new()->schema->resultset('Borrower')->find( $row->{borrowernumber} )->get_column('categorycode');
Why don't you use Koha::Borrowers?
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list