Bug 23403: List borrowernumber in the ILS::Patron fields
[koha.git] / C4 / SIP / ILS / Patron.pm
1 #
2 # ILS::Patron.pm
3
4 # A Class for hiding the ILS's concept of the patron from the OpenSIP
5 # system
6 #
7
8 package C4::SIP::ILS::Patron;
9
10 use strict;
11 use warnings;
12 use Exporter;
13 use Carp;
14
15 use C4::SIP::Sip qw(siplog);
16 use Data::Dumper;
17
18 use C4::SIP::Sip qw(add_field maybe_add);
19
20 use C4::Debug;
21 use C4::Context;
22 use C4::Koha;
23 use C4::Members;
24 use C4::Reserves;
25 use C4::Auth qw(checkpw);
26
27 use Koha::Items;
28 use Koha::Libraries;
29 use Koha::Patrons;
30
31 our $kp;    # koha patron
32
33 =head1 Methods
34
35 =cut
36
37 sub new {
38     my ($class, $patron_id) = @_;
39     my $type = ref($class) || $class;
40     my $self;
41     my $patron = Koha::Patrons->find( { cardnumber => $patron_id } )
42       || Koha::Patrons->find( { userid => $patron_id } );
43     $debug and warn "new Patron: " . Dumper($patron->unblessed) if $patron;
44     unless ($patron) {
45         siplog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
46         return;
47     }
48     $kp = $patron->unblessed;
49     my $pw        = $kp->{password};
50     my $flags     = C4::Members::patronflags( $kp );
51     my $debarred  = $patron->is_debarred;
52     $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')); # Do we need more debug info here?
53     my ($day, $month, $year) = (localtime)[3,4,5];
54     my $today    = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
55     my $expired  = ($today gt $kp->{dateexpiry}) ? 1 : 0;
56     if ($expired) {
57         if ($kp->{opacnote} ) {
58             $kp->{opacnote} .= q{ };
59         }
60         $kp->{opacnote} .= 'PATRON EXPIRED';
61     }
62     my %ilspatron;
63     my $adr     = _get_address($kp);
64     my $dob     = $kp->{dateofbirth};
65     $dob and $dob =~ s/-//g;    # YYYYMMDD
66     my $dexpiry     = $kp->{dateexpiry};
67     $dexpiry and $dexpiry =~ s/-//g;    # YYYYMMDD
68
69     # Get fines and add fines for guarantees (depends on preference NoIssuesChargeGuarantees)
70     my $fines_amount = $flags->{CHARGES}->{amount};
71     $fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0;
72     my $guarantees_fines_amount = $flags->{CHARGES_GUARANTEES} ? $flags->{CHARGES_GUARANTEES}->{amount} : 0;
73     $fines_amount += $guarantees_fines_amount;
74
75     my $fee_limit = _fee_limit();
76     my $fine_blocked = $fines_amount > $fee_limit;
77     my $circ_blocked =( C4::Context->preference('OverduesBlockCirc') ne "noblock" &&  defined $flags->{ODUES}->{itemlist} ) ? 1 : 0;
78     {
79     no warnings;    # any of these $kp->{fields} being concat'd could be undef
80     %ilspatron = (
81         name => $kp->{firstname} . " " . $kp->{surname},
82         id   => $kp->{cardnumber},    # to SIP, the id is the BARCODE, not userid
83         password        => $pw,
84         ptype           => $kp->{categorycode},     # 'A'dult.  Whatever.
85         dateexpiry      => $dexpiry,
86         dateexpiry_iso  => $kp->{dateexpiry},
87         birthdate       => $dob,
88         birthdate_iso   => $kp->{dateofbirth},
89         branchcode      => $kp->{branchcode},
90         library_name    => "",                      # only populated if needed, cached here
91         borrowernumber  => $kp->{borrowernumber},
92         address         => $adr,
93         home_phone      => $kp->{phone},
94         email_addr      => $kp->{email},
95         charge_ok       => ( !$debarred && !$expired && !$fine_blocked && !$circ_blocked),
96         renew_ok        => ( !$debarred && !$expired && !$fine_blocked),
97         recall_ok       => ( !$debarred && !$expired && !$fine_blocked),
98         hold_ok         => ( !$debarred && !$expired && !$fine_blocked),
99         card_lost       => ( $kp->{lost} || $kp->{gonenoaddress} || $flags->{LOST} ),
100         claims_returned => 0,
101         fines           => $fines_amount,
102         fees            => 0,             # currently not distinct from fines
103         recall_overdue  => 0,
104         items_billed    => 0,
105         screen_msg      => 'Greetings from Koha. ' . $kp->{opacnote},
106         print_line      => '',
107         items           => [],
108         hold_items      => $flags->{WAITING}->{itemlist},
109         overdue_items   => $flags->{ODUES}->{itemlist},
110         too_many_overdue => $circ_blocked,
111         fine_items      => [],
112         recall_items    => [],
113         unavail_holds   => [],
114         inet            => ( !$debarred && !$expired ),
115         expired         => $expired,
116         fee_limit       => $fee_limit,
117         userid          => $kp->{userid},
118     );
119     }
120     $debug and warn "patron fines: $ilspatron{fines} ... amountoutstanding: $kp->{amountoutstanding} ... CHARGES->amount: $flags->{CHARGES}->{amount}";
121
122     if ( $patron->is_debarred and $patron->debarredcomment ) {
123         $ilspatron{screen_msg} .= " -- " . $patron->debarredcomment;
124     }
125     if ( $circ_blocked ) {
126         $ilspatron{screen_msg} .= " -- " . "Patron has overdues";
127     }
128     for (qw(EXPIRED CHARGES CREDITS GNA LOST NOTES)) {
129         ($flags->{$_}) or next;
130         if ($_ ne 'NOTES' and $flags->{$_}->{message}) {
131             $ilspatron{screen_msg} .= " -- " . $flags->{$_}->{message};  # show all but internal NOTES
132         }
133         if ($flags->{$_}->{noissues}) {
134             foreach my $toggle (qw(charge_ok renew_ok recall_ok hold_ok inet)) {
135                 $ilspatron{$toggle} = 0;    # if we get noissues, disable everything
136             }
137         }
138     }
139
140     # FIXME: populate fine_items recall_items
141     $ilspatron{unavail_holds} = _get_outstanding_holds($kp->{borrowernumber});
142
143     my $pending_checkouts = $patron->pending_checkouts;
144     my @barcodes;
145     while ( my $c = $pending_checkouts->next ) {
146         push @barcodes, { barcode => $c->item->barcode };
147     }
148     $ilspatron{items} = \@barcodes;
149
150     $self = \%ilspatron;
151     $debug and warn Dumper($self);
152     siplog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id});
153     bless $self, $type;
154     return $self;
155 }
156
157
158 # 0 means read-only
159 # 1 means read/write
160
161 my %fields = (
162     id                      => 0,
163     borrowernumber          => 0,
164     name                    => 0,
165     address                 => 0,
166     email_addr              => 0,
167     home_phone              => 0,
168     birthdate               => 0,
169     birthdate_iso           => 0,
170     dateexpiry              => 0,
171     dateexpiry_iso          => 0,
172     ptype                   => 0,
173     charge_ok               => 0,   # for patron_status[0] (inverted)
174     renew_ok                => 0,   # for patron_status[1] (inverted)
175     recall_ok               => 0,   # for patron_status[2] (inverted)
176     hold_ok                 => 0,   # for patron_status[3] (inverted)
177     card_lost               => 0,   # for patron_status[4]
178     recall_overdue          => 0,
179     currency                => 1,
180     fee_limit               => 0,
181     screen_msg              => 1,
182     print_line              => 1,
183     too_many_charged        => 0,   # for patron_status[5]
184     too_many_overdue        => 0,   # for patron_status[6]
185     too_many_renewal        => 0,   # for patron_status[7]
186     too_many_claim_return   => 0,   # for patron_status[8]
187     too_many_lost           => 0,   # for patron_status[9]
188 #   excessive_fines         => 0,   # for patron_status[10]
189 #   excessive_fees          => 0,   # for patron_status[11]
190     recall_overdue          => 0,   # for patron_status[12]
191     too_many_billed         => 0,   # for patron_status[13]
192     inet                    => 0,   # EnvisionWare extension
193 );
194
195 our $AUTOLOAD;
196
197 sub DESTROY {
198     # be cool.  needed for AUTOLOAD(?)
199 }
200
201 sub AUTOLOAD {
202     my $self = shift;
203     my $class = ref($self) or croak "$self is not an object";
204     my $name = $AUTOLOAD;
205
206     $name =~ s/.*://;
207
208     unless (exists $fields{$name}) {
209         croak "Cannot access '$name' field of class '$class'";
210     }
211
212     if (@_) {
213         $fields{$name} or croak "Field '$name' of class '$class' is READ ONLY.";
214         return $self->{$name} = shift;
215     } else {
216         return $self->{$name};
217     }
218 }
219
220 =head2 format
221
222 This method uses a template to build a string from a Koha::Patron object
223 If errors are encountered in processing template we log them and return nothing
224
225 =cut
226
227 sub format {
228     my ( $self, $template ) = @_;
229
230     if ($template) {
231         require Template;
232         require Koha::Patrons;
233
234         my $tt = Template->new();
235
236         my $patron = Koha::Patrons->find( $self->{borrowernumber} );
237
238         my $output;
239         eval {
240             $tt->process( \$template, { patron => $patron }, \$output );
241         };
242         if ( $@ ){
243             siplog("LOG_DEBUG", "Error processing template: $template");
244             return "";
245         }
246         return $output;
247     }
248 }
249
250 sub check_password {
251     my ( $self, $pwd ) = @_;
252
253     # you gotta give me something (at least ''), or no deal
254     return 0 unless defined $pwd;
255
256     # If the record has a NULL password, accept '' as match
257     return $pwd eq q{} unless $self->{password};
258
259     my $dbh = C4::Context->dbh;
260     my $ret = 0;
261     ($ret) = checkpw( $dbh, $self->{userid}, $pwd, undef, undef, 1 ); # dbh, userid, query, type, no_set_userenv
262     return $ret;
263 }
264
265 # A few special cases, not in AUTOLOADed %fields
266 sub fee_amount {
267     my $self = shift;
268     if ( $self->{fines} ) {
269         return $self->{fines};
270     }
271     return 0;
272 }
273
274 sub fines_amount {
275     my $self = shift;
276     return $self->fee_amount;
277 }
278
279 sub language {
280     my $self = shift;
281     return $self->{language} || '000'; # Unspecified
282 }
283
284 sub expired {
285     my $self = shift;
286     return $self->{expired};
287 }
288
289 #
290 # remove the hold on item item_id from my hold queue.
291 # return true if I was holding the item, false otherwise.
292
293 sub drop_hold {
294     my ($self, $item_id) = @_;
295     return if !$item_id;
296     my $result = 0;
297     foreach (qw(hold_items unavail_holds)) {
298         $self->{$_} or next;
299         for (my $i = 0; $i < scalar @{$self->{$_}}; $i++) {
300             my $held_item = $self->{$_}[$i]->{barcode} or next;
301             if ($held_item eq $item_id) {
302                 splice @{$self->{$_}}, $i, 1;
303                 $result++;
304             }
305         }
306     }
307     return $result;
308 }
309
310 # Accessor method for array_ref values, designed to get the "start" and "end" values
311 # from the SIP request.  Note those incoming values are 1-indexed, not 0-indexed.
312 #
313 sub x_items {
314     my $self      = shift;
315     my $array_var = shift or return;
316     my ($start, $end) = @_;
317
318     my $item_list = [];
319     if ($self->{$array_var}) {
320         if ($start && $start > 1) {
321             --$start;
322         }
323         else {
324             $start = 0;
325         }
326         if ( $end && $end < @{$self->{$array_var}} ) {
327         }
328         else {
329             $end = @{$self->{$array_var}};
330             --$end;
331         }
332         @{$item_list} = @{$self->{$array_var}}[ $start .. $end ];
333
334     }
335     return $item_list;
336 }
337
338 #
339 # List of outstanding holds placed
340 #
341 sub hold_items {
342     my $self = shift;
343     my $item_arr = $self->x_items('hold_items', @_);
344     foreach my $item (@{$item_arr}) {
345         my $item_obj = Koha::Items->find($item->{itemnumber});
346         $item->{barcode} = $item_obj ? $item_obj->barcode : undef;
347     }
348     return $item_arr;
349 }
350
351 sub overdue_items {
352     my $self = shift;
353     return $self->x_items('overdue_items', @_);
354 }
355 sub charged_items {
356     my $self = shift;
357     return $self->x_items('items', @_);
358 }
359 sub fine_items {
360     require Koha::Database;
361     require Template;
362
363     my $self = shift;
364     my $start = shift;
365     my $end = shift;
366     my $server = shift;
367
368     my @fees = Koha::Database->new()->schema()->resultset('Accountline')->search(
369         {
370             borrowernumber    => $self->{borrowernumber},
371             amountoutstanding => { '>' => '0' },
372         }
373     );
374
375     $start = $start ? $start - 1 : 0;
376     $end   = $end   ? $end       : scalar @fees - 1;
377
378     my $av_field_template = $server ? $server->{account}->{av_field_template} : undef;
379     $av_field_template ||= "[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]";
380
381     my $tt = Template->new();
382
383     my @return_values;
384     for ( my $i = $start; $i <= $end; $i++ ) {
385         my $fee = $fees[$i];
386
387         my $output;
388         $tt->process( \$av_field_template, { accountline => $fee }, \$output );
389         push( @return_values, { barcode => $output } );
390     }
391
392     return \@return_values;
393 }
394 sub recall_items {
395     my $self = shift;
396     return $self->x_items('recall_items', @_);
397 }
398 sub unavail_holds {
399     my $self = shift;
400     return $self->x_items('unavail_holds', @_);
401 }
402
403 sub block {
404     my ($self, $card_retained, $blocked_card_msg) = @_;
405     foreach my $field ('charge_ok', 'renew_ok', 'recall_ok', 'hold_ok', 'inet') {
406         $self->{$field} = 0;
407     }
408     $self->{screen_msg} = "Block feature not implemented";  # $blocked_card_msg || "Card Blocked.  Please contact library staff";
409     # TODO: not really affecting patron record
410     return $self;
411 }
412
413 sub enable {
414     my $self = shift;
415     foreach my $field ('charge_ok', 'renew_ok', 'recall_ok', 'hold_ok', 'inet') {
416         $self->{$field} = 1;
417     }
418     siplog("LOG_DEBUG", "Patron(%s)->enable: charge: %s, renew:%s, recall:%s, hold:%s",
419        $self->{id}, $self->{charge_ok}, $self->{renew_ok},
420        $self->{recall_ok}, $self->{hold_ok});
421     $self->{screen_msg} = "Enable feature not implemented."; # "All privileges restored.";   # TODO: not really affecting patron record
422     return $self;
423 }
424
425 sub inet_privileges {
426     my $self = shift;
427     return $self->{inet} ? 'Y' : 'N';
428 }
429
430 sub _fee_limit {
431     return C4::Context->preference('noissuescharge') || 5;
432 }
433
434 sub excessive_fees {
435     my $self = shift;
436     return ($self->fee_amount and $self->fee_amount > $self->fee_limit);
437 }
438
439 sub excessive_fines {
440     my $self = shift;
441     return $self->excessive_fees;   # excessive_fines is the same thing as excessive_fees for Koha
442 }
443
444 sub holds_blocked_by_excessive_fees {
445     my $self = shift;
446     return ( $self->fee_amount
447           && $self->fee_amount > C4::Context->preference("maxoutstanding") );
448 }
449     
450 sub library_name {
451     my $self = shift;
452     unless ($self->{library_name}) {
453         my $library = Koha::Libraries->find( $self->{branchcode} );
454         $self->{library_name} = $library ? $library->branchname : '';
455     }
456     return $self->{library_name};
457 }
458 #
459 # Messages
460 #
461
462 sub invalid_patron {
463     my $self = shift;
464     return "Please contact library staff";
465 }
466
467 sub charge_denied {
468     my $self = shift;
469     return "Please contact library staff";
470 }
471
472 =head2 update_lastseen
473
474     $patron->update_lastseen();
475
476     Patron method to update lastseen field in borrower
477     to record that patron has been seen via sip connection
478
479 =cut
480
481 sub update_lastseen {
482     my $self = shift;
483     my $kohaobj = Koha::Patrons->find( $self->{borrowernumber} );
484     $kohaobj->track_login if $kohaobj; # track_login checks the pref
485 }
486
487 sub _get_address {
488     my $patron = shift;
489
490     my $address = $patron->{streetnumber} || q{};
491     for my $field (qw( roaddetails address address2 city state zipcode country))
492     {
493         next unless $patron->{$field};
494         if ($address) {
495             $address .= q{ };
496             $address .= $patron->{$field};
497         }
498         else {
499             $address .= $patron->{$field};
500         }
501     }
502     return $address;
503 }
504
505 sub _get_outstanding_holds {
506     my $borrowernumber = shift;
507
508     my $patron = Koha::Patrons->find( $borrowernumber );
509     my $holds = $patron->holds->search( { -or => [ { found => undef }, { found => { '!=' => 'W' } } ] } );
510     my @holds;
511     while ( my $hold = $holds->next ) {
512         my $item;
513         if ($hold->itemnumber) {
514             $item = $hold->item;
515         }
516         else {
517             # We need to return a barcode for the biblio so the client
518             # can request the biblio info
519             my $items = $hold->biblio->items;
520             $item = $items->count ? $items->next : undef;
521         }
522         my $unblessed_hold = $hold->unblessed;
523
524         $unblessed_hold->{barcode} = $item ? $item->barcode : undef;
525
526         push @holds, $unblessed_hold;
527     }
528     return \@holds;
529 }
530
531 =head2 build_patron_attributes_string
532
533 This method builds the part of the sip message for extended patron
534 attributes as defined in the sip config
535
536 =cut
537
538 sub build_patron_attributes_string {
539     my ( $self, $server ) = @_;
540
541     my $string = q{};
542     if ( $server->{account}->{patron_attribute} ) {
543         my @attributes_to_send =
544           ref $server->{account}->{patron_attribute} eq "ARRAY"
545           ? @{ $server->{account}->{patron_attribute} }
546           : ( $server->{account}->{patron_attribute} );
547
548         foreach my $a ( @attributes_to_send ) {
549             my @attributes = Koha::Patron::Attributes->search(
550                 {
551                     borrowernumber => $self->{borrowernumber},
552                     code           => $a->{code}
553                 }
554             );
555
556             foreach my $attribute ( @attributes ) {
557                 my $value = $attribute->attribute();
558                 $string .= add_field( $a->{field}, $value );
559             }
560         }
561     }
562
563     return $string;
564 }
565
566
567 =head2 build_custom_field_string
568
569 This method builds the part of the sip message for custom patron fields as defined in the sip config
570
571 =cut
572
573 sub build_custom_field_string {
574     my ( $self, $server ) = @_;
575
576     my $string = q{};
577
578     if ( $server->{account}->{custom_patron_field} ) {
579         my @custom_fields =
580             ref $server->{account}->{custom_patron_field} eq "ARRAY"
581             ? @{ $server->{account}->{custom_patron_field} }
582             : $server->{account}->{custom_patron_field};
583         foreach my $custom_field ( @custom_fields ) {
584             $string .= maybe_add( $custom_field->{field}, $self->format( $custom_field->{template} ) ) if defined $custom_field->{field};
585         }
586     }
587     return $string;
588 }
589
590 1;
591 __END__
592
593 =head1 EXAMPLES
594
595   our %patron_example = (
596           djfiander => {
597               name => "David J. Fiander",
598               id => 'djfiander',
599               password => '6789',
600               ptype => 'A', # 'A'dult.  Whatever.
601               birthdate => '19640925',
602               address => '2 Meadowvale Dr. St Thomas, ON',
603               home_phone => '(519) 555 1234',
604               email_addr => 'djfiander@hotmail.com',
605               charge_ok => 1,
606               renew_ok => 1,
607               recall_ok => 0,
608               hold_ok => 1,
609               card_lost => 0,
610               claims_returned => 0,
611               fines => 100,
612               fees => 0,
613               recall_overdue => 0,
614               items_billed => 0,
615               screen_msg => '',
616               print_line => '',
617               items => [],
618               hold_items => [],
619               overdue_items => [],
620               fine_items => ['Computer Time'],
621               recall_items => [],
622               unavail_holds => [],
623               inet => 1,
624           },
625   );
626
627  From borrowers table:
628 +---------------------+--------------+------+-----+---------+----------------+
629 | Field               | Type         | Null | Key | Default | Extra          |
630 +---------------------+--------------+------+-----+---------+----------------+
631 | borrowernumber      | int(11)      | NO   | PRI | NULL    | auto_increment |
632 | cardnumber          | varchar(16)  | YES  | UNI | NULL    |                |
633 | surname             | mediumtext   | NO   |     | NULL    |                |
634 | firstname           | text         | YES  |     | NULL    |                |
635 | title               | mediumtext   | YES  |     | NULL    |                |
636 | othernames          | mediumtext   | YES  |     | NULL    |                |
637 | initials            | text         | YES  |     | NULL    |                |
638 | streetnumber        | varchar(10)  | YES  |     | NULL    |                |
639 | streettype          | varchar(50)  | YES  |     | NULL    |                |
640 | address             | mediumtext   | NO   |     | NULL    |                |
641 | address2            | text         | YES  |     | NULL    |                |
642 | city                | mediumtext   | NO   |     | NULL    |                |
643 | state               | mediumtext   | YES  |     | NULL    |                |
644 | zipcode             | varchar(25)  | YES  |     | NULL    |                |
645 | country             | text         | YES  |     | NULL    |                |
646 | email               | mediumtext   | YES  |     | NULL    |                |
647 | phone               | text         | YES  |     | NULL    |                |
648 | mobile              | varchar(50)  | YES  |     | NULL    |                |
649 | fax                 | mediumtext   | YES  |     | NULL    |                |
650 | emailpro            | text         | YES  |     | NULL    |                |
651 | phonepro            | text         | YES  |     | NULL    |                |
652 | B_streetnumber      | varchar(10)  | YES  |     | NULL    |                |
653 | B_streettype        | varchar(50)  | YES  |     | NULL    |                |
654 | B_address           | varchar(100) | YES  |     | NULL    |                |
655 | B_address2          | text         | YES  |     | NULL    |                |
656 | B_city              | mediumtext   | YES  |     | NULL    |                |
657 | B_state             | mediumtext   | YES  |     | NULL    |                |
658 | B_zipcode           | varchar(25)  | YES  |     | NULL    |                |
659 | B_country           | text         | YES  |     | NULL    |                |
660 | B_email             | text         | YES  |     | NULL    |                |
661 | B_phone             | mediumtext   | YES  |     | NULL    |                |
662 | dateofbirth         | date         | YES  |     | NULL    |                |
663 | branchcode          | varchar(10)  | NO   | MUL |         |                |
664 | categorycode        | varchar(10)  | NO   | MUL |         |                |
665 | dateenrolled        | date         | YES  |     | NULL    |                |
666 | dateexpiry          | date         | YES  |     | NULL    |                |
667 | gonenoaddress       | tinyint(1)   | YES  |     | NULL    |                |
668 | lost                | tinyint(1)   | YES  |     | NULL    |                |
669 | debarred            | tinyint(1)   | YES  |     | NULL    |                |
670 | contactname         | mediumtext   | YES  |     | NULL    |                |
671 | contactfirstname    | text         | YES  |     | NULL    |                |
672 | contacttitle        | text         | YES  |     | NULL    |                |
673 | borrowernotes       | mediumtext   | YES  |     | NULL    |                |
674 | relationship        | varchar(100) | YES  |     | NULL    |                |
675 | ethnicity           | varchar(50)  | YES  |     | NULL    |                |
676 | ethnotes            | varchar(255) | YES  |     | NULL    |                |
677 | sex                 | varchar(1)   | YES  |     | NULL    |                |
678 | password            | varchar(30)  | YES  |     | NULL    |                |
679 | flags               | int(11)      | YES  |     | NULL    |                |
680 | userid              | varchar(30)  | YES  | MUL | NULL    |                |
681 | opacnote            | mediumtext   | YES  |     | NULL    |                |
682 | contactnote         | varchar(255) | YES  |     | NULL    |                |
683 | sort1               | varchar(80)  | YES  |     | NULL    |                |
684 | sort2               | varchar(80)  | YES  |     | NULL    |                |
685 | altcontactfirstname | varchar(255) | YES  |     | NULL    |                |
686 | altcontactsurname   | varchar(255) | YES  |     | NULL    |                |
687 | altcontactaddress1  | varchar(255) | YES  |     | NULL    |                |
688 | altcontactaddress2  | varchar(255) | YES  |     | NULL    |                |
689 | altcontactaddress3  | varchar(255) | YES  |     | NULL    |                |
690 | altcontactstate     | mediumtext   | YES  |     | NULL    |                |
691 | altcontactzipcode   | varchar(50)  | YES  |     | NULL    |                |
692 | altcontactcountry   | text         | YES  |     | NULL    |                |
693 | altcontactphone     | varchar(50)  | YES  |     | NULL    |                |
694 | smsalertnumber      | varchar(50)  | YES  |     | NULL    |                |
695 | privacy             | int(11)      | NO   |     | 1       |                |
696 +---------------------+--------------+------+-----+---------+----------------+
697
698
699  From C4::Members
700
701  $flags->{KEY}
702  {CHARGES}
703     {message}     Message showing patron's credit or debt
704     {noissues}    Set if patron owes >$5.00
705  {GNA}             Set if patron gone w/o address
706     {message}     "Borrower has no valid address"
707     {noissues}    Set.
708  {LOST}            Set if patron's card reported lost
709     {message}     Message to this effect
710     {noissues}    Set.
711  {DBARRED}         Set if patron is debarred
712     {message}     Message to this effect
713     {noissues}    Set.
714  {NOTES}           Set if patron has notes
715     {message}     Notes about patron
716  {ODUES}           Set if patron has overdue books
717     {message}     "Yes"
718     {itemlist}    ref-to-array: list of overdue books
719     {itemlisttext}    Text list of overdue items
720  {WAITING}         Set if there are items available that the patron reserved
721     {message}     Message to this effect
722     {itemlist}    ref-to-array: list of available items
723
724 =cut
725