Bug 7982: [SIGNED-OFF] Typo in moremember-receipt.tt
[koha.git] / C4 / SIP / ILS.pod
blob8ff3b46bc5f81a9740aa5b41c928dd8cfcb86bc7
1 =head1 NAME
3 ILS - Portability layer to interface between Open-SIP and ILS
5 =head1 SYNOPSIS
7     use ILS;
9     # Initialize connection between SIP and the ILS
10     my $ils = new ILS (institution => 'Foo Public Library');
12     # Basic object access methods
13     $inst_name = $self->institution;
14     $bool = $self->support($operation);
15     $self->check_inst_id($inst_name, "error message");
17     # Check to see if certain protocol options are permitted
18     $bool = $self->checkout_ok;
19     $bool = $self->checkin_ok;
20     $bool = $self->status_update_ok;
21     $bool = $self->offline_ok;
23     $status = $ils->checkout($patron_id, $item_id, $sc_renew);
25     $status = $ils->checkin($item_id, $trans_date, $return_date,
26                             $current_loc, $item_props, $cancel);
28     $status = $ils->end_patron_session($patron_id);
30     $status = $ils->pay_fee($patron_id, $patron_pwd, $fee_amt,
31                             $fee_type, $pay_type, $fee_id, $trans_id,
32                             $currency);
34     $status = $ils->add_hold($patron_id, $patron_pwd, $item_id,
35                              $title_id, $expiry_date,
36                              $pickup_locn, $hold_type, $fee_ack);
38     $status = $ils->cancel_hold($patron_id, $patron_pwd,
39                                 $item_id, $title_id);
41     $status = $ils->alter_hold($patron_id, $patron_pwd, $item_id,
42                                $title_id, $expiry_date,
43                                $pickup_locn, $hold_type,
44                                $fee_ack);
46     $status = $ils->renew($patron_id, $patron_pwd, $item_id,
47                           $title_id, $no_block, $nb_due_date,
48                           $third_party, $item_props, $fee_ack);
50     $status = $ils->renew_all($patron_id, $patron_pwd, $fee_ack);
52 =head1 INTRODUCTION
54 The ILS module defines a basic portability layer between the SIP
55 server and the rest of the integrated library system.  It is the
56 responsibility of the ILS vendor to implement the functions
57 defined by this interface.  This allows the SIP server to be
58 reasonably portable between ILS systems (of course, we won't know
59 exactly I<how> portable the interface is until it's been used by
60 a second ILS.
62 Because no business logic is embedded in the SIP server code
63 itself, the SIP protocol handler functions do almost nothing
64 except decode the network messages and pass the parameters to the
65 ILS module or one of its submodules, C<ILS::Patron> and
66 C<ILS::Item>.  The SIP protocol query messages (Patron
67 Information, or Item Status, for example), are implemented within
68 the SIP server code by fetching a Patron, or Item, record and
69 then retrieving the relevant information from that record.  See
70 L<ILS::Patron> and L<ILS::Item> for the details.
72 =head1 INITIALIZATION
74 The first thing the SIP server does, after a terminal has
75 successfully logged in, is initialize the ILS module by calling
77     $ils = new ILS $institution
79 where C<$institution> is an object of type
80 C<Sip::Configuration::Institution>, describing the institution to
81 which the terminal belongs.  In general, this will be the single
82 institution that the ILS supports, but it may be that in a
83 consortial setting, the SIP server may support connecting to
84 different ILSs based on the C<$institution> of the terminal.
86 =head1 BASIC OBJECT ACCESS AND PROTOCOL SUPPORT
88 The C<$ils> object supports a small set of simple access methods
89 and methods that allow the SIP server to determine if certain
90 protocol operations are permitted to the remote terminals.
92 =head2 C<$inst_name = $self-E<gt>institution;>
94 Returns the institution ID as a string, suitable for
95 incorporating into a SIP response message.
97 =head2 C<$bool = $self-E<gt>support($operation);>
99 Reports whether this ILS implementation supports certain
100 operations that are necessary to report information to the SIP
101 terminal. The argument C<$operation> is a string from this list:
103 =over
105 =item C<'magnetic media'>
107 Can the ILS properly report whether an item is (or contains)
108 magnetic media, such as a videotape or a book with a floppy disk?
110 =item C<'security inhibit'>
112 Is the ILS capable of directing the terminal to ignore the
113 security status of an item?
115 =item C<'offline operation'>
117 Does the ILS allow self-check units to operate when unconnected
118 to the ILS?  That is, can a self-check unit check out items to
119 patrons without checking the status of the items and patrons in
120 real time?
122 =back
124 =head2 C<$bool = $self-E<gt>checkout_ok;>
126 Are the self service terminals permitted to check items out to
127 patrons?
129 =head2 C<$bool = $self-E<gt>checkin_ok;>
131 Are the self service terminals permitted to check items in?
133 =head2 C<$bool = $self-E<gt>status_update_ok;>
135 Are the self service terminals permitted to update patron status
136 information.  For example, can terminals block patrons?
138 =head2 C<$bool = $self-E<gt>offline_ok>;
140 Are the self service terminals permitted to operate off-line.
141 That is, can they perform their core self service operations when
142 not in communication with the ILS?
144 =head1 THE TRANSACTIONS
146 In general, every protocol transaction that changes the status of
147 some ILS object (Patron or Item) has a corresponding C<ILS>
148 method.  Operations like C<Check In>, which are a function of
149 both a patron and an item are C<ILS> functions, while others,
150 like C<Patron Status> or C<Item Status>, which only depend on one
151 type of object, are methods of the corresponding sub-module.
153 In the stub implementation provided with the SIP system, the
154 C<$status> objects returned by the various C<ILS> transactions
155 are objects that are subclasses of a virtual C<ILS::Transaction>
156 object, but this is not required of the SIP code, as long as the
157 status objects support the appropriate methods.
159 =head2 CORE TRANSACTION STATUS METHODS
161 The C<$status> objects returned by all transactions must support
162 the following common methods:
164 =over 
166 =item C<ok>
168 Returns C<true> if the transaction was successful and C<false> if
169 not.  Other methods can be used to find out what went wrong.
171 =item C<item>
173 Returns an C<ILS::Item> object corresponding to the item with the
174 barcode C<$item_id>, or C<undef> if the barcode is invalid.
176 =item C<patron>
178 Returns a C<ILS::Patron> object corresponding to the patron with
179 the barcode C<$patron_id>, or C<undef> if the barcode is invalid
180 (ie, nonexistent, as opposed to "expired" or "delinquent").
182 =item C<screen_msg>
184 Optional. Returns a message that is to be displayed on the
185 terminal's screen.  Some self service terminals read the value of
186 this string and act based on it.  The configuration of the
187 terminal, and the ILS implementation of this method will have to
188 be coordinated.
190 =item C<print_line>
192 Optional.  Returns a message that is to be printed on the
193 terminal's receipt printer.  This message is distinct from the
194 basic transactional information that the terminal will be
195 printing anyway (such as, the basic checkout information like the
196 title and due date).
198 =back
200 =head2 C<$status = $ils-E<gt>checkout($patron_id, $item_id, $sc_renew)>
202 Check out (or possibly renew) item with barcode C<$item_id> to
203 the patron with barcode C<$patron_id>.  If C<$sc_renew> is true,
204 then the self-check terminal has been configured to allow
205 self-renewal of items, and the ILS may take this into account
206 when deciding how to handle the case where C<$item_id> is already
207 checked out to C<$patron_id>.
209 The C<$status> object returned by C<checkout> must support the
210 following methods:
212 =over
214 =item C<renewal_ok>
216 Is this transaction actually a renewal?  That is, did C<$patron_id>
217 already have C<$item_id> checked out?
219 =item C<desensitize>
221 Should the terminal desensitize the item?  This will be false for
222 magnetic media, like videocassettes, and for "in library" items
223 that are checked out to the patron, but not permitted to leave the
224 building.
226 =item C<security_inhibit>
228 Should self checkout unit ignore the security status of this
229 item?
231 This method will only be used if
233     $ils->supports('security inhibit')
235 returns C<true>.
237 =item C<fee_amount>
239 If there is a fee associated with the use of C<$item_id>, then
240 this method should return the amount of the fee, otherwise it
241 should return zero.  See also the C<sip_currency> and
242 C<sip_fee_type> methods.
244 =item C<sip_currency>
246 The ISO currency code for the currency in which the fee
247 associated with this item is denominated.  For example, 'USD' or
248 'CAD'.
250 =item C<sip_fee_type>
252 A code indicating the type of fee associated with this item.  See
253 the table in the protocol specification for the complete list of
254 standard values that this function can return.
256 =back
258 =head2 C<$status = $ils-E<gt>checkin($item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel)>
260 Check in item identified by barcode C<$item_id>.  This
261 transaction took place at time C<$trans_date> and was effective
262 C<$return_date> (to allow for backdating of items to when the
263 branch closed, for example). The self check unit which received
264 the item is located at C<$current_loc>, and the item has
265 properties C<$item_props>.  The parameters C<$current_loc> and
266 C<$item_props> are opaque strings passed from the self service
267 unit to the ILS untranslated.  The configuration of the terminal,
268 and the ILS implementation of this method will have to be
269 coordinated.
271 The C<$status> object returned by the C<checkin> operation must
272 support the following methods:
274 =over
276 =item C<resensitize>
278 Does the item need to be resensitized by the self check unit?
280 =item C<alert>
282 Should the self check unit generate an audible alert to notify
283 staff that the item has been returned?
285 =item C<sort_bin>
287 Certain self checkin units provide for automated sorting of the
288 returned items.  This function returns the bin number into which
289 the received item should be placed.  This function may return the
290 empty string, or C<undef>, to indicate that no sort bin has been
291 specified.
293 =back
295 =head2 C<($status, $screen_msg, $print_line) = $ils-E<gt>end_patron_session($patron_id)>
297 This function informs the ILS that the current patron's session
298 has ended.  This allows the ILS to free up any internal state
299 that it may be preserving between messages from the self check
300 unit.  The function returns a boolean C<$status>, where C<true>
301 indicates success, and two strings: a screen message to display
302 on the self check unit's console, and a print line to be printed
303 on the unit's receipt printer.
305 =head2 C<$status = $ils-E<gt>pay_fee($patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency)>
307 Reports that the self check terminal handled fee payment from
308 patron C<$patron_id> (who has password C<$patron_pwd>, which is
309 an optional parameter).  The other parameters are:
311 =over
313 =item C<$fee_amt>
315 The amount of the fee.
317 =item C<$fee_type>
319 The type of fee, according a table in the SIP protocol
320 specification.
322 =item C<$pay_type>
324 The payment method.  Defined in the SIP protocol specification.
326 =item C<$fee_id>
328 Optional. Identifies which particular fee was paid.  This
329 identifier would have been sent from the ILS to the Self Check
330 unit by a previous "Patron Information Response" message.
332 =item C<$trans_id>
334 Optional. A transaction identifier set by the payment device.
335 This should be recorded by the ILS for financial tracking
336 purposes.
338 =item C<$currency>
340 An ISO currency code indicating the currency in which the fee was
341 paid.
343 =back
345 The status object returned by the C<pay_fee> must support the
346 following methods:
348 =over
350 =item C<transaction_id>
352 Transaction identifier of the transaction.  This parallels the
353 optional C<$trans_id> sent from the terminal to the ILS.  This
354 may return an empty string.
356 =back
358 =head2 C<$status = $ils-E<gt>add_hold($patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack);>
360 Places a hold for C<$patron_id> (optionally, with password
361 C<$patron_pwd>) on the item described by either C<$item_id> or
362 C<$title_id>. The other parameters are:
364 =over
366 =item C<$expiry_date>
368 The date on which the hold should be cancelled.  This date is a
369 SIP protocol standard format timestamp:
371     YYYYMMDDZZZZHHMMSS
373 where the 'Z' characters indicate spaces.
375 =item C<$pickup_location>
377 The location at which the patron wishes to pick up the item when
378 it's available.  The configuration of the terminal, and the ILS
379 implementation of this parameter will have to be coordinated.
381 =item C<$hold_type>
383 The type of hold being placed: any copy, a specific copy, any
384 copy from a particular branch or location.  See the SIP protocol
385 specification for the exact values that this parameter might
386 take.
388 =item C<$fee_ack>
390 Boolean.  If true, the patron has acknowleged that she is willing
391 to pay the fee associated with placing a hold on this item.  If
392 C<$fee_ack> is false, then the ILS should refuse to place the
393 hold.
395 =back
397 =head2 C<$status = $ils-E<gt>cancel_hold($patron_id, $patron_pwd, $item_id, $title_id);>
399 Cancel a hold placed by C<$patron_id> for the item identified by
400 C<$item_id> or C<$title_id>.  The patron password C<$patron_pwd>
401 may be C<undef>, if it was not provided by the terminal.
403 =head2 C<$status = $ils-E<gt>alter_hold($patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack);>
405 The C<$status> object returned by C<$ils-E<gt>add_hold>,
406 C<$ils-E<gt>cancel_hold>, and C<$ils-E<gt>alter_hold> must all
407 support the same methods:
409 =over
411 =item C<expiration_date>
413 Returns the expiry date for the placed hold, in seconds since the
414 epoch.
416 =item C<queue_position>
418 Returns the new hold's place in the queue of outstanding holds.
420 =item C<pickup_location>
422 Returns the location code for the pickup location.
424 =back
426 =head2 C<$status = $ils-E<gt>renew($patron_id, $patron_pwd, $item_id, $title_id, $no_block, $nb_due_date, $third_party, $item_props, $fee_ack);>
428 Renew the item identified by C<$item_id> or C<$title_id>, as
429 requested by C<$patron_id> (with password C<$patron_pwd>).  The
430 item has the properties C<$item_props> associated with it.
432 If the patron renewed the item while the terminal was
433 disconnected from the net, then it is a C<$no_block> transaction,
434 and the due date assigned by the terminal, and reported to the
435 patron was C<$nb_due_date> (so we have to honor it).
437 If there is a fee associated with renewing the item, and the
438 patron has agreed to pay the fee, then C<$fee_ack> will be
439 C<'Y'>.
441 If C<$third_party> is C<'Y'> and the book is not checked out to
442 C<$patron_id>, but to some other person, then this is a
443 third-party renewal; the item should be renewed for the person to
444 whom it is checked out, rather than checking it out to
445 C<$patron_id>, or the renewal should fail.
447 The C<$status> object returned by C<$ils-E<gt>renew> must support
448 the following methods:
450 =over
452 =item C<renewal_ok>
454 Boolean.  If C<renewal_ok> is true, then the item was already
455 checked out to the patron, so it is being renewed.  If
456 C<renewal_ok> is false, then the patron did not already have the
457 item checked out.
459 NOTE: HOW IS THIS USED IN PRACTICE?
461 =item C<desensitize>, C<security_inhibit>, C<fee_amount>, C<sip_currency>, C<sip_fee_type>, C<transaction_id>
463 See C<$ils-E<gt>checkout> for these methods.
465 =back
467 =head2 C<$status = $ils-E<gt>renew_all($patron_id, $patron_pwd, $fee_ack);>
469 Renew all items checked out by C<$patron_id> (with password
470 C<$patron_pwd>).  If the patron has agreed to pay any fees
471 associated with this transaction, then C<$fee_ack> will be
472 C<'Y'>.
474 The C<$status> object must support the following methods:
476 =over
478 =item C<renewed>
480 Returns a list of the C<$item_id>s of the items that were renewed.
482 =item C<unrenewed>
484 Returns a list of the C<$item_id>s of the items that were not renewed.
486 =back