View | Details | Raw Unified | Return to bug 22566
Collapse All | Expand All

(-)a/misc/cronjobs/stockrotation.pl (-12 / +16 lines)
Lines 126-145 my $ok = GetOptions( Link Here
126
    'admin-email|a=s' => \$admin_email,
126
    'admin-email|a=s' => \$admin_email,
127
    'branchcode|b=s'  => sub {
127
    'branchcode|b=s'  => sub {
128
        my ( $opt_name, $opt_value ) = @_;
128
        my ( $opt_name, $opt_value ) = @_;
129
        my $branches = Koha::Libraries->search( {},
129
        if ( $opt_value eq 'all' ) {
130
            { order_by => { -asc => 'branchname' } } );
130
            $branch = 0;
131
        my $brnch = $branches->find($opt_value);
132
        if ($brnch) {
133
            $branch = $brnch;
134
            return $brnch;
135
        }
131
        }
136
        else {
132
        else {
137
            printf("Option $opt_name should be one of (name -> code):\n");
133
            my $branches = Koha::Libraries->search( {},
138
            while ( my $candidate = $branches->next ) {
134
                { order_by => { -asc => 'branchname' } } );
139
                printf( "  %-40s  ->  %s\n",
135
            my $brnch = $branches->find($opt_value);
140
                    $candidate->branchname, $candidate->branchcode );
136
            if ($brnch) {
137
                $branch = $brnch;
138
                return $brnch;
139
            }
140
            else {
141
                printf("Option $opt_name should be one of (name -> code):\n");
142
                while ( my $candidate = $branches->next ) {
143
                    printf( "  %-40s  ->  %s\n",
144
                        $candidate->branchname, $candidate->branchcode );
145
                }
146
                exit 1;
141
            }
147
            }
142
            exit 1;
143
        }
148
        }
144
    },
149
    },
145
    'execute|x'  => \$execute,
150
    'execute|x'  => \$execute,
146
- 

Return to bug 22566