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

(-)a/C4/Circulation.pm (-6 / +6 lines)
Lines 830-836 sub CanBookBeIssued { Link Here
830
        #increment items.localuse
830
        #increment items.localuse
831
        my $localuse_count = $item_object->localuse;
831
        my $localuse_count = $item_object->localuse;
832
        $localuse_count++;
832
        $localuse_count++;
833
        $item_object->localuse( $localuse_count )->store;
833
        $item_object->localuse($localuse_count)->store;
834
834
835
        ModDateLastSeen( $item_object->itemnumber ); # FIXME Move to Koha::Item
835
        ModDateLastSeen( $item_object->itemnumber ); # FIXME Move to Koha::Item
836
        return( { STATS => 1 }, {});
836
        return( { STATS => 1 }, {});
Lines 2148-2158 sub AddReturn { Link Here
2148
        $doreturn = 0;
2148
        $doreturn = 0;
2149
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
2149
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
2150
        # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on
2150
        # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on
2151
        if (C4::Context->preference("RecordLocalUseOnReturn")) {
2151
        if ( C4::Context->preference("RecordLocalUseOnReturn") ) {
2152
           $localuse_count++;
2152
            $localuse_count++;
2153
           $item->localuse( $localuse_count )->store;
2153
            $item->localuse($localuse_count)->store;
2154
           $messages->{'LocalUse'} = 1;
2154
            $messages->{'LocalUse'} = 1;
2155
           $stat_type = 'localuse';
2155
            $stat_type = 'localuse';
2156
        }
2156
        }
2157
    }
2157
    }
2158
2158
(-)a/api/v1/swagger/definitions/item.yaml (-1 / +1 lines)
Lines 117-123 properties: Link Here
117
    type:
117
    type:
118
      - integer
118
      - integer
119
      - "null"
119
      - "null"
120
    description: Number of times this item has been recorded for localuse
120
    description: Number of times this item has been recorded for local use
121
  holds_count:
121
  holds_count:
122
    type:
122
    type:
123
      - integer
123
      - integer
(-)a/installer/data/mysql/atomicupdate/bug_16122_atomicupdate.pl (-13 / +17 lines)
Lines 1-27 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
return {
2
return {
3
    bug_number => "16122",
3
    bug_number  => "16122",
4
    description => "Add localuser column to items table",
4
    description => "Add local use column to items tables",
5
    up => sub {
5
    up          => sub {
6
        my ($args) = @_;
6
        my ($args) = @_;
7
        my ($dbh, $out) = @$args{qw(dbh out)};
7
        my ( $dbh, $out ) = @$args{qw(dbh out)};
8
        if( !column_exists( 'items', 'localuse' ) ) {
8
        if ( !column_exists( 'items', 'localuse' ) ) {
9
            $dbh->do(q{
9
            $dbh->do(
10
                q{
10
                ALTER TABLE items
11
                ALTER TABLE items
11
                ADD COLUMN localuse smallint(6) NULL DEFAULT NULL
12
                ADD COLUMN localuse smallint(6) NULL DEFAULT NULL
12
                COMMENT "item's local use count"
13
                COMMENT "number of times this item has been recorded as local use"
13
                AFTER renewals
14
                AFTER renewals
14
            });
15
            }
16
            );
15
            say $out "Added column 'items.localuse'";
17
            say $out "Added column 'items.localuse'";
16
        }
18
        }
17
        if( !column_exists( 'deleteditems', 'localuse' ) ) {
19
        if ( !column_exists( 'deleteditems', 'localuse' ) ) {
18
            $dbh->do(q{
20
            $dbh->do(
21
                q{
19
                ALTER TABLE deleteditems
22
                ALTER TABLE deleteditems
20
                ADD COLUMN localuse smallint(6) NULL DEFAULT NULL
23
                ADD COLUMN localuse smallint(6) NULL DEFAULT NULL
21
                COMMENT "deleteditems local use count"
24
                COMMENT "number of times this item has been recorded as local use"
22
                AFTER renewals
25
                AFTER renewals
23
            });
26
            }
27
            );
24
            say $out "Added column 'deleteditems.localuse'";
28
            say $out "Added column 'deleteditems.localuse'";
25
        }
29
        }
26
    },
30
    },
27
}
31
    }
(-)a/misc/maintenance/update_localuse_from_statistics.pl (-10 / +8 lines)
Lines 27-33 use Koha::Statistics; Link Here
27
use Getopt::Long qw( GetOptions );
27
use Getopt::Long qw( GetOptions );
28
use Pod::Usage qw( pod2usage );
28
use Pod::Usage qw( pod2usage );
29
29
30
31
sub usage {
30
sub usage {
32
    pod2usage( -verbose => 2 );
31
    pod2usage( -verbose => 2 );
33
    exit;
32
    exit;
Lines 40-59 sub update_localuse { Link Here
40
    my $items = Koha::Items->search();
39
    my $items = Koha::Items->search();
41
40
42
    # Loop through each item and update it with statistics info
41
    # Loop through each item and update it with statistics info
43
    while( my $item = $items->next ){
42
    while ( my $item = $items->next ) {
44
      my $itemnumber = $item->itemnumber;
43
        my $itemnumber = $item->itemnumber;
45
44
46
      my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count;
45
        my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count;
47
      $item->localuse( $localuse_count );
46
        $item->localuse($localuse_count);
48
      $item->store;
47
        $item->store;
49
48
50
      print "Updated item $itemnumber with localuse statistics info.\n";
49
        print "Updated item $itemnumber with local use statistics information.\n";
51
    }
50
    }
52
}
51
}
53
52
54
my ( $help );
53
my ($help);
55
my $result = GetOptions(
54
my $result = GetOptions(
56
    'help|h'      => \$help,
55
    'help|h' => \$help,
57
);
56
);
58
57
59
usage() if $help;
58
usage() if $help;
60
- 

Return to bug 16122