Bug 22566: Accept 'all' in the branch params
Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
4f3413f0d2
commit
2b392a6db2
1 changed files with 16 additions and 11 deletions
|
@ -126,20 +126,25 @@ my $ok = GetOptions(
|
||||||
'admin-email|a=s' => \$admin_email,
|
'admin-email|a=s' => \$admin_email,
|
||||||
'branchcode|b=s' => sub {
|
'branchcode|b=s' => sub {
|
||||||
my ( $opt_name, $opt_value ) = @_;
|
my ( $opt_name, $opt_value ) = @_;
|
||||||
my $branches = Koha::Libraries->search( {},
|
if ( $opt_value eq 'all' ) {
|
||||||
{ order_by => { -asc => 'branchname' } } );
|
$branch = 0;
|
||||||
my $brnch = $branches->find($opt_value);
|
|
||||||
if ($brnch) {
|
|
||||||
$branch = $brnch;
|
|
||||||
return $brnch;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Option $opt_name should be one of (name -> code):\n");
|
my $branches = Koha::Libraries->search( {},
|
||||||
while ( my $candidate = $branches->next ) {
|
{ order_by => { -asc => 'branchname' } } );
|
||||||
printf( " %-40s -> %s\n",
|
my $brnch = $branches->find($opt_value);
|
||||||
$candidate->branchname, $candidate->branchcode );
|
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,
|
'execute|x' => \$execute,
|
||||||
|
|
Loading…
Reference in a new issue