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

(-)a/C4/SIP/ILS/Transaction/Checkin.pm (+60 lines)
Lines 168-173 sub do_checkin { Link Here
168
        $self->alert( !$return || defined $self->alert_type );
168
        $self->alert( !$return || defined $self->alert_type );
169
    }
169
    }
170
170
171
    # Set sort bin based on info in the item associated with the issue, and the
172
    # mapping from SIP2SortBinMapping
173
    $self->sort_bin( _get_sort_bin( $self->{item} ) );
174
171
    $self->ok($return);
175
    $self->ok($return);
172
176
173
    return { messages => $messages };
177
    return { messages => $messages };
Lines 191-194 sub patron_id { Link Here
191
	return $self->{patron}->id;
195
	return $self->{patron}->id;
192
}
196
}
193
197
198
=head1 _get_sort_bin
199
200
Takes an item represented as a hashref as argument.
201
202
Uses the contents of the SIP2SortBinMapping syspref to determine the sort_bin
203
value that should be returned for an item checked in via SIP2.
204
205
The mapping should be:
206
207
 <branchcode>:<item field>:<item field value>:<sort bin number>
208
209
For example:
210
211
 CPL:itype:BOOK:1
212
 CPL:location:OFFICE:2
213
214
This will give:
215
216
=over 4
217
218
=item * sort_bin = "1" for items at the CPL branch with an itemtype of BOOK
219
220
=item * sort_bin = "2" for items at the CPL branch with a location of OFFICE
221
222
=back
223
224
Returns the ID of the appropriate sort_bin, if there is one, or undef.
225
226
=cut
227
228
sub _get_sort_bin {
229
230
    # We should get an item represented as a hashref here
231
    my ( $item ) = @_;
232
    return undef unless $item;
233
234
    # Get the mapping and split on newlines
235
    my $raw_map = C4::Context->preference('SIP2SortBinMapping');
236
    return unless $raw_map;
237
    my @lines = split /\r\n/, $raw_map;
238
239
    # Iterate over the mapping. The first hit wins.
240
    foreach my $line ( @lines ) {
241
        # Split the line into fields
242
        my ( $branchcode, $item_property, $value, $sort_bin ) = split /:/, $line;
243
        # Check the fields against values in the item
244
        if ( ( $item->{homebranch} eq $branchcode ) && ( $item->{$item_property} eq $value ) ) {
245
            return $sort_bin;
246
        }
247
    }
248
249
    # Return undef if no hits were found
250
    return undef;
251
252
}
253
194
1;
254
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/mandatory/sysprefs.sql (+1 lines)
Lines 621-626 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
621
('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'),
621
('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'),
622
('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'),
622
('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'),
623
('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'),
623
('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'),
624
('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'),
624
('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'),
625
('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'),
625
('SlipCSS','',NULL,'Slips CSS url.','free'),
626
('SlipCSS','',NULL,'Slips CSS url.','free'),
626
('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'),
627
('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 1271-1273 Circulation: Link Here
1271
              class: integer
1271
              class: integer
1272
            - days.
1272
            - days.
1273
            - <span class="hint">This system preference is used by the cleanup_database.pl cronjob.</span>
1273
            - <span class="hint">This system preference is used by the cleanup_database.pl cronjob.</span>
1274
- 
1274
    SIP2:
1275
        -
1276
            - "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."
1277
            - pref: SIP2SortBinMapping
1278
              type: textarea
1279
              class: long

Return to bug 20517