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

(-)a/C4/Biblio.pm (-5 / +14 lines)
Lines 3684-3699 sub UpdateTotalIssues { Link Here
3684
    my ($biblionumber, $increase, $value) = @_;
3684
    my ($biblionumber, $increase, $value) = @_;
3685
    my $totalissues;
3685
    my $totalissues;
3686
3686
3687
    my $record = GetMarcBiblio($biblionumber);
3688
    unless ($record) {
3689
        carp "UpdateTotalIssues could not get biblio record";
3690
        return;
3691
    }
3687
    my $data = GetBiblioData($biblionumber);
3692
    my $data = GetBiblioData($biblionumber);
3693
    unless ($data) {
3694
        carp "UpdateTotalIssues could not get datas of biblio";
3695
        return;
3696
    }
3697
    my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField('biblioitems.totalissues', $data->{'frameworkcode'});
3698
    unless ($totalissuestag) {
3699
        return 1; # There is nothing to do
3700
    }
3688
3701
3689
    if (defined $value) {
3702
    if (defined $value) {
3690
        $totalissues = $value;
3703
        $totalissues = $value;
3691
    } else {
3704
    } else {
3692
        $totalissues = $data->{'totalissues'} + $increase;
3705
        $totalissues = $data->{'totalissues'} + $increase;
3693
    }
3706
    }
3694
     my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField('biblioitems.totalissues', $data->{'frameworkcode'});
3695
3696
     my $record = GetMarcBiblio($biblionumber);
3697
3707
3698
     my $field = $record->field($totalissuestag);
3708
     my $field = $record->field($totalissuestag);
3699
     if (defined $field) {
3709
     if (defined $field) {
Lines 3704-3711 sub UpdateTotalIssues { Link Here
3704
         $record->insert_grouped_field($field);
3714
         $record->insert_grouped_field($field);
3705
     }
3715
     }
3706
3716
3707
     ModBiblio($record, $biblionumber, $data->{'frameworkcode'});
3717
     return ModBiblio($record, $biblionumber, $data->{'frameworkcode'});
3708
     return;
3709
}
3718
}
3710
3719
3711
=head2 RemoveAllNsb
3720
=head2 RemoveAllNsb
(-)a/misc/cronjobs/update_totalissues.pl (-3 / +9 lines)
Lines 98-103 my $dbh = C4::Context->dbh; Link Here
98
$dbh->{AutoCommit} = 0;
98
$dbh->{AutoCommit} = 0;
99
99
100
my $num_bibs_processed = 0;
100
my $num_bibs_processed = 0;
101
my $num_bibs_error = 0;
101
102
102
my $starttime = time();
103
my $starttime = time();
103
104
Lines 169-179 sub process_query { Link Here
169
        print "Processing bib $biblionumber ($totalissues issues)\n"
170
        print "Processing bib $biblionumber ($totalissues issues)\n"
170
          if $verbose;
171
          if $verbose;
171
        if ( not $test_only ) {
172
        if ( not $test_only ) {
173
            my $ret;
172
            if ( $incremental && $totalissues > 0 ) {
174
            if ( $incremental && $totalissues > 0 ) {
173
                UpdateTotalIssues( $biblionumber, $totalissues );
175
                $ret = UpdateTotalIssues( $biblionumber, $totalissues );
174
            }
176
            }
175
            else {
177
            else {
176
                UpdateTotalIssues( $biblionumber, 0, $totalissues );
178
                $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues );
179
            }
180
            unless ($ret) {
181
                print "Error while processing bib $biblionumber\n" if $verbose;
182
                $num_bibs_error++;
177
            }
183
            }
178
        }
184
        }
179
        if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) {
185
        if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) {
Lines 198-203 Run started at: $starttime Link Here
198
Run ended at:                           $endtime
204
Run ended at:                           $endtime
199
Total run time:                         $totaltime ms
205
Total run time:                         $totaltime ms
200
Number of bibs modified:                $num_bibs_processed
206
Number of bibs modified:                $num_bibs_processed
207
Number of bibs with error:              $num_bibs_error
201
_SUMMARY_
208
_SUMMARY_
202
    $summary .= "\n****  Ran in test mode only  ****\n" if $test_only;
209
    $summary .= "\n****  Ran in test mode only  ****\n" if $test_only;
203
    print $summary;
210
    print $summary;
204
- 

Return to bug 12995