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

(-)a/C4/SIP/ILS/Transaction/Checkin.pm (+60 lines)
Lines 142-147 sub do_checkin { Link Here
142
        $self->alert( !$return || defined $self->alert_type );
142
        $self->alert( !$return || defined $self->alert_type );
143
    }
143
    }
144
144
145
    # Set sort bin based on info in the item associated with the issue, and the
146
    # mapping from SIP2SortBinMapping
147
    $self->sort_bin( _get_sort_bin( $self->{item} ) );
148
145
    $self->ok($return);
149
    $self->ok($return);
146
150
147
    return { messages => $messages };
151
    return { messages => $messages };
Lines 165-168 sub patron_id { Link Here
165
	return $self->{patron}->id;
169
	return $self->{patron}->id;
166
}
170
}
167
171
172
=head1 _get_sort_bin
173
174
Takes an item represented as a hashref as argument.
175
176
Uses the contents of the SIP2SortBinMapping syspref to determine the sort_bin
177
value that should be returned for an item checked in via SIP2.
178
179
The mapping should be:
180
181
 <branchcode>:<item field>:<item field value>:<sort bin number>
182
183
For example:
184
185
 CPL:itype:BOOK:1
186
 CPL:location:OFFICE:2
187
188
This will give:
189
190
=over 4
191
192
=item * sort_bin = "1" for items at the CPL branch with an itemtype of BOOK
193
194
=item * sort_bin = "2" for items at the CPL branch with a location of OFFICE
195
196
=back
197
198
Returns the ID of the appropriate sort_bin, if there is one, or undef.
199
200
=cut
201
202
sub _get_sort_bin {
203
204
    # We should get an item represented as a hashref here
205
    my ( $item ) = @_;
206
    return undef unless $item;
207
208
    # Get the mapping and split on newlines
209
    my $raw_map = C4::Context->preference('SIP2SortBinMapping');
210
    return unless $raw_map;
211
    my @lines = split /\r\n/, $raw_map;
212
213
    # Iterate over the mapping. The first hit wins.
214
    foreach my $line ( @lines ) {
215
        # Split the line into fields
216
        my ( $branchcode, $item_property, $value, $sort_bin ) = split /:/, $line;
217
        # Check the fields against values in the item
218
        if ( ( $item->{homebranch} eq $branchcode ) && ( $item->{$item_property} eq $value ) ) {
219
            return $sort_bin;
220
        }
221
    }
222
223
    # Return undef if no hits were found
224
    return undef;
225
226
}
227
168
1;
228
1;
(-)a/installer/data/mysql/atomicupdate/bug20517-sort-bin.perl (+8 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
4
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
5
        ('SIP2SortBinMapping','',NULL,'Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form \"branchcode:item field:item field value:sort bin number\", with one mapping per line.','free'),;
6
    });
7
    NewVersion( $DBversion, 20517, "Add SIP2SortBinMapping system preference");
8
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 587-592 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
587
('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'),
587
('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'),
588
('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'),
588
('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'),
589
('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'),
589
('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'),
590
('SIP2SortBinMapping','',NULL,'Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form \"branchcode:item field:item field value:sort bin number\", with one mapping per line.','free'),
590
('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'),
591
('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'),
591
('SlipCSS','',NULL,'Slips CSS url.','free'),
592
('SlipCSS','',NULL,'Slips CSS url.','free'),
592
('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'),
593
('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +6 lines)
Lines 1165-1167 Circulation: Link Here
1165
            - pref: ClaimReturnedWarningThreshold
1165
            - pref: ClaimReturnedWarningThreshold
1166
              class: integer
1166
              class: integer
1167
            - items.
1167
            - items.
1168
- 
1168
    SIP2:
1169
        -
1170
            - "Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form 'branchcode:item field:item field value:sort bin number', with one mapping per line."
1171
            - pref: SIP2SortBinMapping
1172
              type: textarea
1173
              class: long

Return to bug 20571