my $out_ids = [ grep {$_ > 0} split(',', $circ_summary->out) ];
$details->{overdue_count} = scalar(@$overdue_ids);
$details->{out_count} = scalar(@$out_ids) + scalar(@$overdue_ids);
+ $details->{items_overdue_ids} = $overdue_ids;
+ $details->{items_out_ids} = $out_ids;
}
my $xacts = $U->simplereq(
my $e = $session->editor;
my $list_items = $params{summary_list_items};
- my $offset = $params{summary_start_item} || 0;
- my $end_item = $params{summary_end_item} || 10;
- my $limit = $end_item - $offset;
- add_hold_items($e, $session, $details, $offset, $limit)
+ # Start and end are 1-based. Translate to zero-based for internal use.
+ my $offset = $params{summary_start_item} ? $params{summary_start_item} - 1 : 0;
+ my $end = $params{summary_end_item} ? $params{summary_end_item} - 1 : 10;
+ my $limit = $end - $offset;
+
+ add_hold_items($session, $details, $offset, $limit)
if $list_items eq 'hold_items';
+
+ add_items_out($session, $details, $offset, $limit)
+ if $list_items eq 'charged_items';
}
sub add_hold_items {
- my ($e, $session, $details, $offset, $limit) = @_;
+ my ($session, $details, $offset, $limit) = @_;
my $patron = $details->{patron};
my $format = $session->config->{msg64_hold_datatype} || '';
my @hold_items;
for my $hold_id (@$hold_ids) {
- my $hold = $e->retrieve_action_hold_request($hold_id);
+ my $hold = $session->editor->retrieve_action_hold_request($hold_id);
if ($format eq 'barcode') {
- my $copy = find_copy_for_hold($e, $hold);
+ my $copy = find_copy_for_hold($session, $hold);
push(@hold_items, $copy->barcode) if $copy;
} else {
- my $title = find_title_for_hold($e, $hold);
+ my $title = find_title_for_hold($session, $hold);
push(@hold_items, $title) if $title;
}
}
$details->{hold_items} = \@hold_items;
}
+sub add_items_out {
+ my ($session, $details, $offset, $limit) = @_;
+ my $patron = $details->{patron};
+
+ my $format = $session->config->{settings}->{msg64_summary_datatype} || '';
+
+ my @circ_ids = (@{$details->{items_out_ids}}, @{$details->{items_overdue_ids}});
+
+ @circ_ids = grep { $_ } @circ_ids[$offset .. ($offset + $limit - 1)];
+
+ $details->{items_out} = [];
+ for my $circ_id (@circ_ids) {
+ my $value;
+
+ if ($format eq 'barcode') {
+ my $circ = $session->editor->retrieve_action_circulation([
+ $circ_id, {
+ flesh => 1,
+ flesh_fields => {circ => ['target_copy']}
+ }]);
+
+ $value = $circ->target_copy->barcode;
+
+ } else { # title
+
+ my $circ = $session->editor->retrieve_action_circulation([
+ $circ_id, {
+ flesh => 4,
+ flesh_fields => {
+ circ => ['target_copy'],
+ acp => ['call_number'],
+ acn => ['record'],
+ bre => ['simple_record']
+ }
+ }]);
+
+ if ($circ->target_copy->call_number == -1) {
+ $value = $circ->target_copy->dummy_title;
+ } else {
+ $value =
+ $circ->target_copy->call_number->record->simple_record->title;
+ }
+ }
+
+ push(@{$details->{items_out}}, $value);
+ }
+}
+
# Hold -> reporter.hold_request_record -> display field for title.
sub find_title_for_hold {
- my ($e, $hold) = @_;
+ my ($session, $hold) = @_;
+ my $e = $session->editor;
my $bib_link = $e->retrieve_reporter_hold_request_record($hold->id);
# "representative" copy is that it cannot be deleted. Otherwise, any
# copy that allows us to find the hold later is good enough.
sub find_copy_for_hold {
- my ($e, $hold) = @_;
+ my ($session, $hold) = @_;
+ my $e = $session->editor;
return $e->retrieve_asset_copy($hold->current_copy)
if $hold->current_copy;
});
}
+
1;
INSERT INTO actor.passwd_type (code, name, login, crypt_algo, iter_count)
VALUES ('sip2', 'SIP2 Client Password', FALSE, 'bf', 5);
+INSERT INTO config.sip_setting (institution, name, value)
+VALUES
+ ('*', 'allow_sc_status_before_login', 'true'),
+ ('*', 'currency', '"USD"'),
+ ('*', 'due_date_use_sip_date_format', 'false'),
+ ('*', 'patron_status_permit_loans', 'false'),
+ ('*', 'patron_status_permit_all', 'false'),
+ ('*', 'msg64_summary_datatype', '"title"'),
+ ('*', 'msg64_hold_items_available', '"title"')
+;
+
+
/* EXAMPLE SETTINGS
-- Example linking a SIP password to the 'admin' account.
'3m'
);
-INSERT INTO config.sip_setting (institution, name, value)
-VALUES
- ('*', 'allow_sc_status_before_login', 'true'),
- ('*', 'currency', '"USD"'),
- ('example', 'due_date_use_sip_date_format', 'false'),
- ('example', 'patron_status_permit_loans', 'false'),
- ('example', 'patron_status_permit_all', 'false'),
- ('example', 'msg64_hold_items_available', 'false')
-;
*/