|
Lines 170-176
sub do_checkin {
Link Here
|
| 170 |
|
170 |
|
| 171 |
# Set sort bin based on info in the item associated with the issue, and the |
171 |
# Set sort bin based on info in the item associated with the issue, and the |
| 172 |
# mapping from SIP2SortBinMapping |
172 |
# mapping from SIP2SortBinMapping |
| 173 |
$self->sort_bin( _get_sort_bin( $self->{item} ) ); |
173 |
$self->sort_bin( _get_sort_bin( $item, $branch ) ); |
| 174 |
|
174 |
|
| 175 |
$self->ok($return); |
175 |
$self->ok($return); |
| 176 |
|
176 |
|
|
Lines 197-215
sub patron_id {
Link Here
|
| 197 |
|
197 |
|
| 198 |
=head1 _get_sort_bin |
198 |
=head1 _get_sort_bin |
| 199 |
|
199 |
|
| 200 |
Takes an item represented as a hashref as argument. |
200 |
Takes a Koha::Item object and the return branch branchcode as arguments. |
| 201 |
|
201 |
|
| 202 |
Uses the contents of the SIP2SortBinMapping syspref to determine the sort_bin |
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. |
203 |
value that should be returned for an item checked in via SIP2. |
| 204 |
|
204 |
|
| 205 |
The mapping should be: |
205 |
The mapping should be: |
| 206 |
|
206 |
|
| 207 |
<branchcode>:<item field>:<item field value>:<sort bin number> |
207 |
<branchcode>:<item field>:<comparitor>:<item field value>:<sort bin number> |
| 208 |
|
208 |
|
| 209 |
For example: |
209 |
For example: |
| 210 |
|
210 |
|
| 211 |
CPL:itype:BOOK:1 |
211 |
CPL:itype:eq:BOOK:1 |
| 212 |
CPL:location:OFFICE:2 |
212 |
CPL:location:eq:OFFICE:2 |
|
|
213 |
CPL:classmark:<:339.6:3 |
| 213 |
|
214 |
|
| 214 |
This will give: |
215 |
This will give: |
| 215 |
|
216 |
|
|
Lines 219-224
This will give:
Link Here
|
| 219 |
|
220 |
|
| 220 |
=item * sort_bin = "2" for items at the CPL branch with a location of OFFICE |
221 |
=item * sort_bin = "2" for items at the CPL branch with a location of OFFICE |
| 221 |
|
222 |
|
|
|
223 |
=item * sort_bin = "3" for items at the CPL branch with a classmark less than 339.6 |
| 224 |
|
| 222 |
=back |
225 |
=back |
| 223 |
|
226 |
|
| 224 |
Returns the ID of the appropriate sort_bin, if there is one, or undef. |
227 |
Returns the ID of the appropriate sort_bin, if there is one, or undef. |
|
Lines 228-234
Returns the ID of the appropriate sort_bin, if there is one, or undef.
Link Here
|
| 228 |
sub _get_sort_bin { |
231 |
sub _get_sort_bin { |
| 229 |
|
232 |
|
| 230 |
# We should get an item represented as a hashref here |
233 |
# We should get an item represented as a hashref here |
| 231 |
my ( $item ) = @_; |
234 |
my ( $item, $branch ) = @_; |
| 232 |
return undef unless $item; |
235 |
return undef unless $item; |
| 233 |
|
236 |
|
| 234 |
# Get the mapping and split on newlines |
237 |
# Get the mapping and split on newlines |
|
Lines 237-254
sub _get_sort_bin {
Link Here
|
| 237 |
my @lines = split /\r\n/, $raw_map; |
240 |
my @lines = split /\r\n/, $raw_map; |
| 238 |
|
241 |
|
| 239 |
# Iterate over the mapping. The first hit wins. |
242 |
# Iterate over the mapping. The first hit wins. |
| 240 |
foreach my $line ( @lines ) { |
243 |
my $rule = 0; |
|
|
244 |
foreach my $line (@lines) { |
| 245 |
warn "Rule: " . $rule++ . " - " . $line . "\n"; |
| 246 |
|
| 241 |
# Split the line into fields |
247 |
# Split the line into fields |
| 242 |
my ( $branchcode, $item_property, $value, $sort_bin ) = split /:/, $line; |
248 |
my ( $branchcode, $item_property, $comparitor, $value, $sort_bin ) = |
|
|
249 |
split /:/, $line; |
| 250 |
if ( $value =~ s/^\$// ) { |
| 251 |
$value = $item->$value; |
| 252 |
} |
| 243 |
# Check the fields against values in the item |
253 |
# Check the fields against values in the item |
| 244 |
if ( ( $item->{homebranch} eq $branchcode ) && ( $item->{$item_property} eq $value ) ) { |
254 |
if ( $branch eq $branchcode ) { |
| 245 |
return $sort_bin; |
255 |
my $property = $item->$item_property; |
|
|
256 |
if ( ( $comparitor eq 'eq' || $comparitor eq '=' ) && ( $property eq $value ) ) { |
| 257 |
return $sort_bin; |
| 258 |
} |
| 259 |
if ( ( $comparitor eq 'ne' || $comparitor eq '!=' ) && ( $property ne $value ) ) { |
| 260 |
return $sort_bin; |
| 261 |
} |
| 262 |
if ( ( $comparitor eq '<' ) && ( $property < $value ) ) { |
| 263 |
return $sort_bin; |
| 264 |
} |
| 265 |
if ( ( $comparitor eq '>' ) && ( $property > $value ) ) { |
| 266 |
return $sort_bin; |
| 267 |
} |
| 268 |
if ( ( $comparitor eq '<=' ) && ( $property <= $value ) ) { |
| 269 |
return $sort_bin; |
| 270 |
} |
| 271 |
if ( ( $comparitor eq '>=' ) && ( $property >= $value ) ) { |
| 272 |
return $sort_bin; |
| 273 |
} |
| 246 |
} |
274 |
} |
| 247 |
} |
275 |
} |
| 248 |
|
276 |
|
| 249 |
# Return undef if no hits were found |
277 |
# Return undef if no hits were found |
| 250 |
return undef; |
278 |
return undef; |
| 251 |
|
|
|
| 252 |
} |
279 |
} |
| 253 |
|
280 |
|
| 254 |
1; |
281 |
1; |
| 255 |
- |
|
|