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

(-)a/C4/Biblio.pm (+48 lines)
Lines 103-108 BEGIN { Link Here
103
      &ModBiblio
103
      &ModBiblio
104
      &ModBiblioframework
104
      &ModBiblioframework
105
      &ModZebra
105
      &ModZebra
106
      &UpdateTotalIssues
106
    );
107
    );
107
108
108
    # To delete something
109
    # To delete something
Lines 3780-3785 sub prepare_host_field { Link Here
3780
    return;
3781
    return;
3781
}
3782
}
3782
3783
3784
3785
=head2 UpdateTotalIssues
3786
3787
  UpdateTotalIssues($biblionumber, $increase, [$value])
3788
3789
Update the total issue count for a particular bib record. 
3790
3791
=over 4
3792
3793
=item C<$biblionumber> is the biblionumber of the bib to update
3794
3795
=item C<$increase> is the amount to increase (or decrease) the total issues count by
3796
3797
=item C<$value> is the absolute value that total issues count should be set to. If provided, C<$increase> is ignored.
3798
3799
=back
3800
3801
=cut
3802
3803
sub UpdateTotalIssues {
3804
    my ($biblionumber, $increase, $value) = @_;
3805
    my $totalissues;
3806
3807
    my $data = GetBiblioData($biblionumber);
3808
3809
    if (defined $value) {
3810
        $totalissues = $value;
3811
    } else {
3812
        $totalissues = $data->{'totalissues'} + $increase;
3813
    }
3814
     my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField('biblioitems.totalissues', $data->{'frameworkcode'});
3815
3816
     my $record = GetMarcBiblio($biblionumber);
3817
    
3818
     my $field = $record->field($totalissuestag);
3819
     if (defined $field) {
3820
         $field->update( $totalissuessubfield => $totalissues );
3821
     } else {
3822
         $field = MARC::Field->new($totalissuestag, '0', '0',
3823
                 $totalissuessubfield => $totalissues);
3824
         $record->insert_grouped_field($field);
3825
     }
3826
3827
     ModBiblio($record, $biblionumber, $data->{'frameworkcode'});
3828
     return;
3829
}
3830
3783
1;
3831
1;
3784
3832
3785
3833
(-)a/C4/Circulation.pm (-1 / +3 lines)
Lines 1059-1064 sub AddIssue { Link Here
1059
          CartToShelf( $item->{'itemnumber'} );
1059
          CartToShelf( $item->{'itemnumber'} );
1060
        }
1060
        }
1061
        $item->{'issues'}++;
1061
        $item->{'issues'}++;
1062
        if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) {
1063
            UpdateTotalIssues($item->{'biblionumber'}, 1);
1064
        }
1062
1065
1063
        ## If item was lost, it has now been found, reverse any list item charges if neccessary.
1066
        ## If item was lost, it has now been found, reverse any list item charges if neccessary.
1064
        if ( $item->{'itemlost'} ) {
1067
        if ( $item->{'itemlost'} ) {
1065
- 

Return to bug 6557