From 79736abef5b59722055f4ea3b95d4bb250c38895 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 18 Jun 2019 12:57:07 +0100 Subject: [PATCH] Bug 22566: Accept 'all' in the branch params Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize (cherry picked from commit 2b392a6db231c8069d57be88ebf4f2960af199fa) Signed-off-by: Fridolin Somers --- misc/cronjobs/stockrotation.pl | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/misc/cronjobs/stockrotation.pl b/misc/cronjobs/stockrotation.pl index f3c6b91f41..3143839c06 100755 --- a/misc/cronjobs/stockrotation.pl +++ b/misc/cronjobs/stockrotation.pl @@ -126,20 +126,25 @@ my $ok = GetOptions( 'admin-email|a=s' => \$admin_email, 'branchcode|b=s' => sub { my ( $opt_name, $opt_value ) = @_; - my $branches = Koha::Libraries->search( {}, - { order_by => { -asc => 'branchname' } } ); - my $brnch = $branches->find($opt_value); - if ($brnch) { - $branch = $brnch; - return $brnch; + if ( $opt_value eq 'all' ) { + $branch = 0; } else { - printf("Option $opt_name should be one of (name -> code):\n"); - while ( my $candidate = $branches->next ) { - printf( " %-40s -> %s\n", - $candidate->branchname, $candidate->branchcode ); + my $branches = Koha::Libraries->search( {}, + { order_by => { -asc => 'branchname' } } ); + my $brnch = $branches->find($opt_value); + if ($brnch) { + $branch = $brnch; + return $brnch; + } + else { + printf("Option $opt_name should be one of (name -> code):\n"); + while ( my $candidate = $branches->next ) { + printf( " %-40s -> %s\n", + $candidate->branchname, $candidate->branchcode ); + } + exit 1; } - exit 1; } }, 'execute|x' => \$execute, -- 2.39.5