From 0a80fb0db402b5c37d07d9398fd491677dc07ef7 Mon Sep 17 00:00:00 2001 From: dbwells Date: Wed, 21 Jul 2010 20:35:37 +0000 Subject: [PATCH] - Add 'status' to serial.item table, other small schema edits - Updated and functional receive/bind method - Minor changes to 'Items' tab git-svn-id: svn://svn.open-ils.org/ILS/branches/seials-integration@17003 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 15 +- .../src/perlmods/OpenILS/Application/Serial.pm | 346 ++++++++++++++++----- Open-ILS/src/sql/Pg/210.schema.serials.sql | 8 +- .../xul/staff_client/server/serial/manage_items.js | 182 ++++++----- .../staff_client/server/serial/manage_items.xul | 37 +-- 5 files changed, 394 insertions(+), 194 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index aac171bd8d..c07e787da7 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3052,6 +3052,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + @@ -3063,6 +3066,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + @@ -3241,6 +3247,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -3286,8 +3293,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - + + @@ -3306,7 +3313,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + @@ -3326,7 +3333,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm b/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm index bd0c4020fb..379d99f3c6 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm @@ -119,7 +119,7 @@ sub fleshed_item_alter { $item->edit_date('now'); if( $item->isdeleted ) { - $evt = _delete_item( $editor, $override, $item); + $evt = _delete_sitem( $editor, $override, $item); } elsif( $item->isnew ) { # TODO: reconsider this # if the item has a new issuance, create the issuance first @@ -127,10 +127,10 @@ sub fleshed_item_alter { fleshed_issuance_alter($self, $conn, $auth, [$item->issuance]); } _cleanse_dates($item, ['date_expected','date_received']); - $evt = _create_item( $editor, $item ); + $evt = _create_sitem( $editor, $item ); } else { _cleanse_dates($item, ['date_expected','date_received']); - $evt = _update_item( $editor, $override, $item ); + $evt = _update_sitem( $editor, $override, $item ); } } @@ -145,14 +145,14 @@ sub fleshed_item_alter { return 1; } -sub _delete_item { +sub _delete_sitem { my ($editor, $override, $item) = @_; $logger->info("item-alter: delete item ".OpenSRF::Utils::JSON->perl2JSON($item)); return $editor->event unless $editor->delete_serial_item($item); return 0; } -sub _create_item { +sub _create_sitem { my ($editor, $item) = @_; $item->creator($editor->requestor->id); @@ -163,7 +163,7 @@ sub _create_item { return 0; } -sub _update_item { +sub _update_sitem { my ($editor, $override, $item) = @_; $logger->info("item-alter: retrieving item ".$item->id); @@ -241,13 +241,13 @@ sub fleshed_issuance_alter { $issuance->edit_date('now'); if( $issuance->isdeleted ) { - $evt = _delete_issuance( $editor, $override, $issuance); + $evt = _delete_siss( $editor, $override, $issuance); } elsif( $issuance->isnew ) { _cleanse_dates($issuance, ['date_published']); - $evt = _create_issuance( $editor, $issuance ); + $evt = _create_siss( $editor, $issuance ); } else { _cleanse_dates($issuance, ['date_published']); - $evt = _update_issuance( $editor, $override, $issuance ); + $evt = _update_siss( $editor, $override, $issuance ); } } @@ -262,14 +262,14 @@ sub fleshed_issuance_alter { return 1; } -sub _delete_issuance { +sub _delete_siss { my ($editor, $override, $issuance) = @_; $logger->info("issuance-alter: delete issuance ".OpenSRF::Utils::JSON->perl2JSON($issuance)); return $editor->event unless $editor->delete_serial_issuance($issuance); return 0; } -sub _create_issuance { +sub _create_siss { my ($editor, $issuance) = @_; $issuance->creator($editor->requestor->id); @@ -280,7 +280,7 @@ sub _create_issuance { return 0; } -sub _update_issuance { +sub _update_siss { my ($editor, $override, $issuance) = @_; $logger->info("issuance-alter: retrieving issuance ".$issuance->id); @@ -612,7 +612,7 @@ sub _revive_holding { } __PACKAGE__->register_method( - method => 'receive_items', + method => 'unitize_items', api_name => 'open-ils.serial.receive_items', api_level => 1, argc => 1, @@ -631,90 +631,274 @@ __PACKAGE__->register_method( } ); -sub receive_items { +sub unitize_items { my ($self, $conn, $auth, $items) = @_; - my $last_distribution; - my $last_mfhd; - my %sres_to_save; - my %mfhds_to_save; my( $reqr, $evt ) = $U->checkses($auth); return $evt if $evt; my $editor = new_editor(requestor => $reqr, xact => 1); + $self->api_name =~ /serial\.(\w*)_items/; + my $mode = $1; + + my %found_unit_ids; + my %found_stream_ids; + my %found_types; + + my %stream_ids_by_unit_id; + + my %unit_map; + my %sdist_by_unit_id; + my %sdist_by_stream_id; + + my $new_unit_id; # id for '-2' units to share foreach my $item (@$items) { - # unflesh unit if fleshed - $item->unit( $item->unit->id ) if ref($item->unit); + # for debugging only, TODO: delete + if (!ref $item) { # hopefully we got an id instead + $item = $editor->retrieve_serial_item($item); + } + # get ids + my $unit_id = ref($item->unit) ? $item->unit->id : $item->unit; + my $stream_id = ref($item->stream) ? $item->stream->id : $item->stream; + my $issuance_id = ref($item->issuance) ? $item->issuance->id : $item->issuance; + #TODO: evt on any missing ids + + if ($mode eq 'receive') { + $item->date_received('now'); + $item->status('Received'); + } else { + $item->status('Bindery'); + } - $item->date_received('now'); + # check for types to trigger summary updates + my $scap; + if (!ref $item->issuance) { + my $scaps = $editor->search_serial_caption_and_pattern([{"+siss" => {"id" => $issuance_id}}, { "join" => {"siss" => {}} }]); + $scap = $scaps->[0]; + } elsif (!ref $item->issuance->caption_and_pattern) { + $scap = $editor->retrieve_serial_caption_and_pattern($item->issuance->caption_and_pattern); + } else { + $scap = $editor->issuance->caption_and_pattern; + } + if (!exists($found_types{$stream_id})) { + $found_types{$stream_id} = {}; + } + $found_types{$stream_id}->{$scap->type} = 1; # create unit if needed - if ($item->unit == -1) { # create by "volume" (first item division) - #TODO - } elsif ($item->unit == -2) { # create by "issue" (second item division) - #TODO + if ($unit_id == -1 or (!$new_unit_id and $unit_id == -2)) { # create unit per item + my $unit; + my $sdists = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_id}}, { "join" => {"sstr" => {}} }]); + $unit = _build_unit($editor, $sdists->[0], $mode); + my $evt = _create_sunit($editor, $unit); + return $evt if $evt; + if ($unit_id == -2) { + $new_unit_id = $unit->id; + $unit_id = $new_unit_id; + } else { + $unit_id = $unit->id; + } + $item->unit($unit_id); + + # get unit with 'DEFAULT's and save unit and sdist for later use + $unit = $editor->retrieve_serial_unit($unit->id); + $unit_map{$unit_id} = $unit; + $sdist_by_unit_id{$unit_id} = $sdists->[0]; + $sdist_by_stream_id{$stream_id} = $sdists->[0]; + } elsif ($unit_id == -2) { # create one unit for all '-2' items + $unit_id = $new_unit_id; + } + + $found_unit_ids{$unit_id} = 1; + $found_stream_ids{$stream_id} = 1; + + # save the stream_id for this unit_id + # TODO: prevent items from different streams in same unit? (perhaps in interface) + $stream_ids_by_unit_id{$unit_id} = $stream_id; + + my $evt = _update_sitem($editor, undef, $item); + return $evt if $evt; + } + + # deal with unit level labels + foreach my $unit_id (keys %found_unit_ids) { + + # get all the needed issuances for unit + my $issuances = $editor->search_serial_issuance([ {"+sitem" => {"unit" => $unit_id, "status" => "Received"}}, {"join" => {"sitem" => {}}, "order_by" => {"siss" => "date_published"}} ]); + #TODO: evt on search failure + + my ($mfhd, $formatted_parts) = _summarize_contents($editor, $issuances); + + # special case for single formatted_part (may have summarized version) + if (@$formatted_parts == 1) { + #TODO: MFHD.pm should have a 'format_summary' method for this } - my $mfhd; - my $sre; - if ($item->distribution == $last_distribution) { - # use cached record - $mfhd = $last_mfhd; - } else { # get MFHD record - my $sdist = $editor->retrieve_serial_distribution([$item->distribution]); - $sre = $editor->retrieve_serial_record_entry([$sdist->record_entry]); - - #convert from marc_xml to marc - my $marc = MARC::Record->new_from_xml($sre->marc); - - #turn into MFHD record object - $mfhd = MFHD->new($marc); - $sres_to_save{$sre->id} = $sre; - $mfhds_to_save{$sre->id} = $mfhd; + # retrieve and update unit contents + my $sunit; + my $sdist; + + # if we just created the unit, we will already have it and the distribution stored + if (exists $unit_map{$unit_id}) { + $sunit = $unit_map{$unit_id}; + $sdist = $sdist_by_unit_id{$unit_id}; + } else { + $sunit = $editor->retrieve_serial_unit($unit_id); + $sdist = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_ids_by_unit_id{$unit_id}}}, { "join" => {"sstr" => {}} }]); + $sdist = $sdist->[0]; } - my $item_holding = _revive_holding($mfhd, $item->holding_code); + $sunit->detailed_contents($sdist->unit_label_prefix . ' ' + . join(', ', @$formatted_parts) . ' ' + . $sdist->unit_label_suffix); + + $sunit->summary_contents($sunit->detailed_contents); #TODO: change this when real summary contents are available + + # create sort_key by left padding numbers to 6 digits + my $sort_key = $sunit->detailed_contents; + $sort_key =~ s/(\d+)/sprintf '%06d', $1/eg; # this may need improvement + $sunit->sort_key($sort_key); - # get all current holdings for this linked caption - my @curr_holdings = $mfhd->holdings($item_holding->tag, $item_holding->caption->link_id); - # short-circuit logic : if holding is the next one, increment the last current holding - my $next_holding_values = $curr_holdings[-1]->next; - if ($next_holding_values and $item_holding->matches($next_holding_values)) { - $curr_holdings[-1]->extend; - } else { # not the next expected, do full replacement - $mfhd->append_fields($item_holding); -# my @updated_holdings = $mfhd->get_compressed_holdings($captions_ref->{$link_id}); - my @updated_holdings = $mfhd->get_compressed_holdings($item_holding->caption); - # set reference point to top of current holdings - my $marker_field = MARC::Field->new(500, '', '','a' => 'Temporary Marker'); - $mfhd->insert_fields_before($curr_holdings[0], $marker_field); - foreach my $holding (@curr_holdings) { - $mfhd->delete_field($holding); - } - $mfhd->delete_field($item_holding); - $mfhd->insert_fields_before($marker_field, @updated_holdings); - # delete reference point - $mfhd->delete_field($marker_field); - } - - $last_distribution = $item->distribution; - $last_mfhd = $mfhd; - _update_item($editor, undef, $item); + if ($mode eq 'bind') { + $sunit->status(2); # set to 'Bindery' status + } + + my $evt = _update_sunit($editor, undef, $sunit); + return $evt if $evt; } - foreach my $sre_id (keys %sres_to_save) { - #TODO: update '005' to current date - my $sre = $sres_to_save{$sre_id}; - (my $xml = $mfhds_to_save{$sre_id}->as_xml_record()) =~ s/\n//sog; - $xml =~ s/^<\?xml.+\?\s*>//go; - $sre->marc($xml); - $sre->ischanged(1); - $editor->update_serial_record_entry($sre); + # TODO: cleanup 'dead' units (units which are now emptied of their items) + + if ($mode eq 'receive') { # the summary holdings do not change when binding + # deal with stream level summaries + # summaries will be built from the "primary" stream only, that is, the stream with the lowest ID per distribution + # (TODO: consider direct designation) + my %primary_streams_by_sdist; + my %streams_by_sdist; + + # see if we have primary streams, and if so, associate them with their distributions + foreach my $stream_id (keys %found_stream_ids) { + my $sdist; + if (exists $sdist_by_stream_id{$stream_id}) { + $sdist = $sdist_by_stream_id{$stream_id}; + } else { + $sdist = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_id}}, { "join" => {"sstr" => {}} }]); + $sdist = $sdist->[0]; + } + my $streams; + if (!exists($streams_by_sdist{$sdist->id})) { + $streams = $editor->search_serial_stream([{"distribution" => $sdist->id}, {"order_by" => {"sstr" => "id"}}]); + $streams_by_sdist{$sdist->id} = $streams; + } else { + $streams = $streams_by_sdist{$sdist->id}; + } + $primary_streams_by_sdist{$sdist->id} = $streams->[0] if ($stream_id == $streams->[0]->id); + } + + # retrieve and update summaries for each affected primary stream's distribution + foreach my $sdist_id (keys %primary_streams_by_sdist) { + my $stream = $primary_streams_by_sdist{$sdist_id}; + my $stream_id = $stream->id; + # get all the needed issuances for stream + # FIXME: search in Bindery/Bound/Not Published? as well as Received + foreach my $type (keys %{$found_types{$stream_id}}) { + my $issuances = $editor->search_serial_issuance([ {"+sitem" => {"stream" => $stream_id, "status" => "Received"}, "+scap" => {"type" => $type}}, {"join" => {"sitem" => {}, "scap" => {}}, "order_by" => {"siss" => "date_published"}} ]); + #TODO: evt on search failure + + my ($mfhd, $formatted_parts) = _summarize_contents($editor, $issuances); + + # retrieve and update the generated_coverage of the summary + my $search_method = "search_serial_${type}_summary"; + my $summary = $editor->$search_method([{"distribution" => $sdist_id}]); + $summary = $summary->[0]; + $summary->generated_coverage(join(', ', @$formatted_parts)); + my $update_method = "update_serial_${type}_summary"; + return $editor->event unless $editor->$update_method($summary); + } + } } $editor->commit; return scalar @$items; } +sub _build_unit { + my $editor = shift; + my $sdist = shift; + my $mode = shift; + + my $attr = $mode . '_unit_template'; + my $template = $editor->retrieve_asset_copy_template($sdist->$attr); + + my @parts = qw( circ_lib status location loan_duration fine_level age_protect circulate deposit ref holdable deposit_amount price circ_modifier circ_as_type alert_message opac_visible floating mint_condition ); + + my $unit = new Fieldmapper::serial::unit; + foreach my $part (@parts) { + my $value = $template->$part; + next if !defined($value); + $unit->$part($value); + } + if (!$template->circ_lib) { + $unit->circ_lib($sdist->holding_lib); + } + $unit->creator($editor->requestor->id); + $unit->editor($editor->requestor->id); + $attr = $mode . '_call_number'; + $unit->call_number($sdist->$attr); + $unit->barcode('AUTO'); + $unit->sort_key(''); + $unit->summary_contents(''); + $unit->detailed_contents(''); + + return $unit; +} + + +sub _summarize_contents { + my $editor = shift; + my $issuances = shift; + + # create MFHD record + my $mfhd = MFHD->new(MARC::Record->new()); + my %scaps; + my %scap_fields; + my @scap_fields_ordered; + my $seqno = 1; + my $link_id = 1; + foreach my $issuance (@$issuances) { + my $scap_id = $issuance->caption_and_pattern; + next if (!$scap_id); # skip issuances with no caption/pattern + + my $scap; + my $scap_field; + # if this is the first appearance of this scap, retrieve it and add it to the temporary record + if (!exists $scaps{$issuance->caption_and_pattern}) { + $scaps{$scap_id} = $editor->retrieve_serial_caption_and_pattern($scap_id); + $scap = $scaps{$scap_id}; + $scap_field = _revive_caption($scap); + $scap_fields{$scap_id} = $scap_field; + push(@scap_fields_ordered, $scap_field); + $scap_field->update('8' => $link_id); + $mfhd->append_fields($scap_field); + $link_id++; + } else { + $scap = $scaps{$scap_id}; + $scap_field = $scap_fields{$scap_id}; + } + + $mfhd->append_fields(_revive_holding($issuance->holding_code, $scap_field, $seqno)); + $seqno++; + } + + my @formatted_parts; + foreach my $scap_field (@scap_fields_ordered) { #TODO: use generic MFHD "summarize" method, once available + my @updated_holdings = $mfhd->get_compressed_holdings($scap_field); + foreach my $holding (@updated_holdings) { + push(@formatted_parts, $holding->format); + } + } + + return ($mfhd, \@formatted_parts); +} ########################################################################## # note methods @@ -1225,6 +1409,18 @@ sub _create_sdist { $logger->info("distribution-alter: new distribution ".OpenSRF::Utils::JSON->perl2JSON($sdist)); return $editor->event unless $editor->create_serial_distribution($sdist); + + # create summaries too + my $summary = new Fieldmapper::serial::basic_summary; + $summary->distribution($sdist->id); + return $editor->event unless $editor->create_serial_basic_summary($summary); + $summary = new Fieldmapper::serial::supplement_summary; + $summary->distribution($sdist->id); + return $editor->event unless $editor->create_serial_supplement_summary($summary); + $summary = new Fieldmapper::serial::index_summary; + $summary->distribution($sdist->id); + return $editor->event unless $editor->create_serial_index_summary($summary); + return 0; } diff --git a/Open-ILS/src/sql/Pg/210.schema.serials.sql b/Open-ILS/src/sql/Pg/210.schema.serials.sql index 69766f0b3c..2535ed7884 100644 --- a/Open-ILS/src/sql/Pg/210.schema.serials.sql +++ b/Open-ILS/src/sql/Pg/210.schema.serials.sql @@ -219,6 +219,10 @@ CREATE TABLE serial.item ( DEFERRABLE INITIALLY DEFERRED, date_expected TIMESTAMP WITH TIME ZONE, date_received TIMESTAMP WITH TIME ZONE + status TEXT CONSTRAINT valid_status CHECK + ( + status IN ('Bindery', 'Bound', 'Claimed', 'Discarded', 'Expected', 'Not Held', 'Not Published', 'Received') + ) DEFAULT 'Expected' ); CREATE TABLE serial.item_note ( @@ -236,7 +240,7 @@ CREATE TABLE serial.item_note ( value TEXT NOT NULL ); -CREATE TABLE serial.bib_summary ( +CREATE TABLE serial.basic_summary ( id SERIAL PRIMARY KEY, distribution INT NOT NULL REFERENCES serial.distribution (id) @@ -246,7 +250,7 @@ CREATE TABLE serial.bib_summary ( textual_holdings TEXT ); -CREATE TABLE serial.sup_summary ( +CREATE TABLE serial.supplement_summary ( id SERIAL PRIMARY KEY, distribution INT NOT NULL REFERENCES serial.distribution (id) diff --git a/Open-ILS/xul/staff_client/server/serial/manage_items.js b/Open-ILS/xul/staff_client/server/serial/manage_items.js index 67176934fe..a944aff4c3 100644 --- a/Open-ILS/xul/staff_client/server/serial/manage_items.js +++ b/Open-ILS/xul/staff_client/server/serial/manage_items.js @@ -83,7 +83,7 @@ serial.manage_items.prototype = { // get latest sdist id list based on library drowdown obj.set_sdist_ids(); obj.refresh_list('main'); - obj.refresh_list('sunit'); + obj.refresh_list('workarea'); }, false ); @@ -228,12 +228,11 @@ serial.manage_items.prototype = { var list = util.functional.map_list( obj.retrieve_ids, function (o) { - return obj.list_sitem_map[o.sitem_id]; + var item = obj.list_sitem_map[o.sitem_id]; + item.unit('-1'); //FIXME: hard-coded unit (-1 is AUTO) + return item; } ); - for (var i = 0; i < list.length; i++) { - list[i].unit('1'); //FIXME: hard-coded unit - } var robj = obj.network.request( 'open-ils.serial', @@ -244,7 +243,7 @@ serial.manage_items.prototype = { alert('Successfully received '+robj+' item(s)'); obj.refresh_list('main'); - obj.refresh_list('sunit'); + obj.refresh_list('workarea'); } catch(E) { obj.error.standard_unexpected_error_alert('cmd_receive_items failed!',E); @@ -275,13 +274,13 @@ serial.manage_items.prototype = { 'cmd_items_print' : [ ['command'], function() { obj.items_print(obj.selected_list); } ], 'cmd_items_export' : [ ['command'], function() { obj.items_export(obj.selected_list); } ], - 'cmd_refresh_list' : [ ['command'], function() { obj.refresh_list('main'); obj.refresh_list('sunit'); } ] + 'cmd_refresh_list' : [ ['command'], function() { obj.refresh_list('main'); obj.refresh_list('workarea'); } ] } } ); obj.retrieve('main'); // retrieve main list - obj.retrieve('sunit'); // retrieve shelving unit list + obj.retrieve('workarea'); // retrieve shelving unit list obj.controller.view.sel_clip.setAttribute('disabled','true'); @@ -317,7 +316,7 @@ serial.manage_items.prototype = { JSAN.use('circ.util'); var columns = item_columns({}); - + function retrieve_row(params) { try { var row = params.row; @@ -380,18 +379,18 @@ serial.manage_items.prototype = { } ); obj.lists.main.sitem_retrieve_params = {'date_received' : null }; - obj.lists.main.sitem_sort_params ={'order_by' : {'sitem' : 'date_expected ASC'}}; + obj.lists.main.sitem_extra_params ={'order_by' : {'sitem' : 'date_expected ASC, stream ASC'}}; - obj.lists.sunit = new util.list('sunit_tree'); - obj.lists.sunit.init( + obj.lists.workarea = new util.list('workarea_tree'); + obj.lists.workarea.init( { 'columns' : columns, 'map_row_to_columns' : circ.util.std_map_row_to_columns(), 'retrieve_row' : retrieve_row, 'on_select' : function(ev) { - obj.selected_list = 'sunit'; + obj.selected_list = 'workarea'; JSAN.use('util.functional'); - var sel = obj.lists.sunit.retrieve_selection(); + var sel = obj.lists.workarea.retrieve_selection(); obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1); var list = util.functional.map_list( sel, @@ -409,8 +408,8 @@ serial.manage_items.prototype = { } } ); - obj.lists.sunit.sitem_retrieve_params = {'unit' : 1, 'date_received' : {"!=" : null}}; //FIXME: hard-coded shelving unit - obj.lists.sunit.sitem_sort_params ={'order_by' : {'sitem' : 'date_received DESC'}}; + obj.lists.workarea.sitem_retrieve_params = {'date_received' : {"!=" : null}}; + obj.lists.workarea.sitem_extra_params ={'order_by' : {'sitem' : 'date_received DESC'}, 'limit' : 30}; }, 'refresh_list' : function(list_name) { @@ -431,35 +430,31 @@ serial.manage_items.prototype = { 'retrieve' : function(list_name) { var obj = this; var list = obj.lists[list_name]; - if (window.xulG && window.xulG.items) { - obj.items = window.xulG.items; - } else { - obj.items = []; //FIXME: not using this - - var rparams = list.sitem_retrieve_params; - var robj; - if (obj.sdist_ids.length > 0) { - rparams['+sstr'] = { "distribution" : {"in" : obj.sdist_ids} }; - var other_params = list.sitem_sort_params; - other_params.join = 'sstr'; - - robj = obj.network.simple_request( - 'FM_SITEM_ID_LIST', - [ ses(), rparams, other_params ] - ); - } -/* if (typeof robj.ilsevent!='undefined') { - obj.error.standard_unexpected_error_alert('FIXME: Catch edit control with no distribution',E); - }*/ - } + + if (!obj.sdist_ids.length) { // no sdists to retrieve items for + return; + } + + var rparams = list.sitem_retrieve_params; + var robj; + rparams['+sstr'] = { "distribution" : obj.sdist_ids }; + var other_params = list.sitem_extra_params; + other_params.join = 'sstr'; + + robj = obj.network.simple_request( + 'FM_SITEM_ID_LIST', + [ ses(), rparams, other_params ] + ); + if (typeof robj.ilsevent!='undefined') { + obj.error.standard_unexpected_error_alert('Failed to retrieve serial item ID list',E); + } if (!robj) { robj = []; - }else if (!robj.length) { + } else if (!robj.length) { robj = [robj]; } list.clear(); - for (i = 0; i < robj.length; i++) { list.append( { 'row' : { 'my' : { 'sitem_id' : robj[i] } }, 'to_bottom' : true, 'no_auto_select' : true } ); } @@ -471,6 +466,9 @@ serial.manage_items.prototype = { var obj = this; + /*obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','false'); + obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');*/ + obj.retrieve_ids = list; } } @@ -491,67 +489,31 @@ function item_columns(modify,params) { 'persist' : 'hidden width ordinal' }, { - 'id' : 'creator', - 'label' : 'Creator', - 'flex' : 1, - 'primary' : false, - 'hidden' : true, - 'persist' : 'hidden width ordinal', - 'render' : function(my) { return my.sitem.creator().usrname(); } - }, - { - 'id' : 'create_date', - 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'), - 'flex' : 1, - 'primary' : false, - 'hidden' : true, - 'persist' : 'hidden width ordinal', - 'render' : function(my) { return my.sitem.create_date().substr(0,10); } - }, - { - 'id' : 'editor', - 'label' : 'Editor', - 'flex' : 1, - 'primary' : false, - 'hidden' : false, - 'persist' : 'hidden width ordinal', - 'render' : function(my) { return my.sitem.editor().usrname(); } - }, - { - 'id' : 'edit_date', - 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'), + 'id' : 'label', + 'label' : 'Issuance Label', 'flex' : 1, 'primary' : false, 'hidden' : false, - 'persist' : 'hidden width ordinal', - 'render' : function(my) { return my.sitem.edit_date().substr(0,10); } + 'render' : function(my) { return my.sitem.issuance().label(); }, + 'persist' : 'hidden width ordinal' }, { 'id' : 'distribution', 'label' : 'Distribution', 'flex' : 1, 'primary' : false, - 'hidden' : true, + 'hidden' : false, 'persist' : 'hidden width ordinal', 'render' : function(my) { return my.sitem.stream().distribution().label(); } }, { - 'id' : 'unit', - 'label' : 'Unit', + 'id' : 'stream_id', + 'label' : 'Stream ID', 'flex' : 1, 'primary' : false, 'hidden' : false, 'persist' : 'hidden width ordinal', - 'render' : function(my) { return my.sitem.unit().call_number().label(); } - }, - { - 'id' : 'label', - 'label' : 'Issuance Label', - 'flex' : 1, - 'primary' : false, - 'hidden' : false, - 'render' : function(my) { return my.sitem.issuance().label(); }, - 'persist' : 'hidden width ordinal' + 'render' : function(my) { return my.sitem.stream().id(); } }, { 'id' : 'date_published', @@ -590,6 +552,60 @@ function item_columns(modify,params) { 'persist' : 'hidden width ordinal' }, { + 'id' : 'call_number', + 'label' : 'Call Number', + 'flex' : 1, + 'primary' : false, + 'hidden' : false, + 'persist' : 'hidden width ordinal', + 'render' : function(my) { return my.sitem.unit().call_number().label(); } + }, + { + 'id' : 'unit_id_contents', + 'label' : 'Unit ID / Contents', + 'flex' : 1, + 'primary' : false, + 'hidden' : false, + 'render' : function(my) { return '[' + my.sitem.unit().id() + '] ' + my.sitem.unit().summary_contents() ; }, + 'persist' : 'hidden width ordinal' + }, + { + 'id' : 'creator', + 'label' : 'Creator', + 'flex' : 1, + 'primary' : false, + 'hidden' : true, + 'persist' : 'hidden width ordinal', + 'render' : function(my) { return my.sitem.creator().usrname(); } + }, + { + 'id' : 'create_date', + 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'), + 'flex' : 1, + 'primary' : false, + 'hidden' : true, + 'persist' : 'hidden width ordinal', + 'render' : function(my) { return my.sitem.create_date().substr(0,10); } + }, + { + 'id' : 'editor', + 'label' : 'Editor', + 'flex' : 1, + 'primary' : false, + 'hidden' : true, + 'persist' : 'hidden width ordinal', + 'render' : function(my) { return my.sitem.editor().usrname(); } + }, + { + 'id' : 'edit_date', + 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'), + 'flex' : 1, + 'primary' : false, + 'hidden' : false, + 'persist' : 'hidden width ordinal', + 'render' : function(my) { return my.sitem.edit_date().substr(0,10); } + }, + { 'id' : 'holding_code', 'label' : 'Holding Code', 'flex' : 1, diff --git a/Open-ILS/xul/staff_client/server/serial/manage_items.xul b/Open-ILS/xul/staff_client/server/serial/manage_items.xul index dc5ec88bc5..dde0fedc6d 100644 --- a/Open-ILS/xul/staff_client/server/serial/manage_items.xul +++ b/Open-ILS/xul/staff_client/server/serial/manage_items.xul @@ -83,53 +83,30 @@ vim:noet:sw=4:ts=4: - +