}
sub fetch_callnumber {
- my( $self, $id ) = @_;
+ my( $self, $id, $flesh ) = @_;
my $evt = undef;
my $e = OpenILS::Event->new( 'ASSET_CALL_NUMBER_NOT_FOUND', id => $id );
'open-ils.cstore.direct.asset.call_number.retrieve', $id );
$evt = $e unless $cn;
+ if ($flesh && $cn) {
+ $cn->prefix(
+ $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.asset.call_number_prefix.retrieve', $cn->prefix
+ )
+ );
+ $cn->suffix(
+ $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.asset.call_number_suffix.retrieve', $cn->suffix
+ )
+ );
+ $cn->label_class(
+ $self->simplereq(
+ 'open-ils.cstore',
+ 'open-ils.cstore.direct.asset.call_number_class.retrieve', $cn->label_class
+ )
+ );
+ }
+
return ( $cn, $evt );
}
$search_hash->{deleted} = 'f';
my $e = new_editor();
- my $vols = $e->search_asset_call_number([$search_hash, { 'order_by' => {
- 'acn' => 'oils_text_as_bytea(label_sortkey), oils_text_as_bytea(label), id, owning_lib'
- } } ] );
+ my $vols = $e->search_asset_call_number([
+ $search_hash,
+ {
+ flesh => 1,
+ flesh_fields => { acn => ['prefix','suffix','label_class'] },
+ 'order_by' => { 'acn' => 'oils_text_as_bytea(label_sortkey), oils_text_as_bytea(label), id, owning_lib' }
+ }
+ ]);
my @volumes;
flesh => 2,
flesh_fields => {
acp => ['call_number'],
- acn => ['record']
+ acn => ['record','prefix','suffix','label_class']
}
}
]) or return $e->event;
}
__PACKAGE__->register_method(
+ method => "fetch_fleshed_cn",
+ api_name => "open-ils.search.callnumber.fleshed.retrieve",
+ authoritative => 1,
+ notes => "retrieves a callnumber based on ID, fleshing prefix, suffix, and label_class",
+);
+
+sub fetch_fleshed_cn {
+ my( $self, $client, $id ) = @_;
+ my( $cn, $evt ) = $apputils->fetch_callnumber( $id, 1 );
+ return $evt if $evt;
+ return $cn;
+}
+
+
+__PACKAGE__->register_method(
method => "fetch_copy_by_cn",
api_name => 'open-ils.search.copies_by_call_number.retrieve',
signature => q/
'CHECKOUT_RENEW' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.renew' },
'CIRC_MODIFIER_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circ_modifier.retrieve.all' },
'CLEAR_HOLD_SHELF' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.clear_shelf.process', 'secure' : false },
- 'FM_ACN_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve', 'secure' : false },
- 'FM_ACN_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve.authoritative', 'secure' : false },
+ 'FM_ACN_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.fleshed.retrieve', 'secure' : false },
+ 'FM_ACN_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.fleshed.retrieve.authoritative', 'secure' : false },
'FM_ACN_TREE_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.fleshed.batch.update' },
'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve', 'secure' : false },
'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve.authoritative', 'secure' : false },
'init' : function (params) {
var obj = this;
+ obj.scratch_data = {};
JSAN.use('util.widgets');
if (typeof params.map_row_to_column == 'function') {
- label = params.map_row_to_column(params.row,this.columns[i]);
+ label = params.map_row_to_column(params.row,this.columns[i],this.scratch_data);
} else if (typeof this.map_row_to_column == 'function') {
- label = this.map_row_to_column(params.row,this.columns[i]);
+ label = this.map_row_to_column(params.row,this.columns[i],this.scratch_data);
}
if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); }
if (typeof params.map_row_to_columns == 'function') {
- labels = params.map_row_to_columns(params.row,this.columns);
+ labels = params.map_row_to_columns(params.row,this.columns,this.scratch_data);
} else if (typeof this.map_row_to_columns == 'function') {
- labels = this.map_row_to_columns(params.row,this.columns);
+ labels = this.map_row_to_columns(params.row,this.columns,this.scratch_data);
}
for (var i = 0; i < labels.length; i++) {
var value = '';
if (typeof params.map_row_to_column == 'function') {
- value = params.map_row_to_column(params.row,this.columns[i]);
+ value = params.map_row_to_column(params.row,this.columns[i],this.scratch_data);
} else {
if (typeof this.map_row_to_column == 'function') {
- value = this.map_row_to_column(params.row,this.columns[i]);
+ value = this.map_row_to_column(params.row,this.columns[i],this.scratch_data);
}
}
if (typeof value == 'string' || typeof value == 'number') {
},
// Default for the map_row_to_columns function for .init
'std_map_row_to_columns' : function(error_value) {
- return function(row,cols) {
+ return function(row,cols,scratch) {
// row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
// cols contains all of the objects listed above in columns
+ // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in)
+ if (!scratch) { scratch = {}; }
var obj = {};
JSAN.use('util.error'); obj.error = new util.error();
try {
for (var i = 0; i < cols.length; i++) {
switch (typeof cols[i].render) {
- case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
+ case 'function': try { values[i] = cols[i].render(my,scratch); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
}
'due_date',
'owning_lib',
'circ_lib',
+ 'label_class',
+ 'prefix',
'call_number',
+ 'suffix',
'copy_number',
'location',
'barcode',
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.acp && my.acp.call_number() == -1) {
+ 'editable' : false, 'render' : function(my,scratch_data) {
+ var acn_id;
+ if (my.acn) {
+ if (typeof my.acn == 'object') {
+ acn_id = my.acn.id();
+ } else {
+ acn_id = my.acn;
+ }
+ } else if (my.acp) {
+ if (typeof my.acp.call_number() == 'object') {
+ acn_id = my.acp.call_number().id();
+ } else {
+ acn_id = my.acp.call_number();
+ }
+ }
+ if (!acn_id && acn_id != 0) {
+ return '';
+ } else if (acn_id == -1) {
return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
- } else if (my.acp && my.acp.call_number() == -2) {
+ } else if (acn_id == -2) {
return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
} else {
if (!my.acn) {
- var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
- if (x.ilsevent) {
- return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
+ if (typeof scratch_data['acn_map'] == 'undefined') {
+ scratch_data['acn_map'] = {};
+ }
+ if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') {
+ var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]);
+ if (x.ilsevent) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
+ } else {
+ my.acn = x;
+ scratch_data['acn_map'][ acn_id ] = my.acn;
+ }
} else {
- my.acn = x; return x.label();
+ my.acn = scratch_data['acn_map'][ acn_id ];
}
- } else {
- return my.acn.label();
}
+ return my.acn.label();
}
},
'persist' : 'hidden width ordinal'
'persist' : 'hidden width ordinal'
},
{
+ 'id' : 'prefix',
+ 'fm_class' : 'acn',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.prefix'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (typeof my.acn == 'undefined') return '';
+ return (typeof my.acn.prefix() == 'object') ? my.acn.prefix().label() : my.acn.prefix();
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'suffix',
+ 'fm_class' : 'acn',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.suffix'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (typeof my.acn == 'undefined') return '';
+ return (typeof my.acn.suffix() == 'object') ? my.acn.suffix().label() : my.acn.suffix();
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'label_class',
+ 'fm_class' : 'acn',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.label_class'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (typeof my.acn == 'undefined') return '';
+ return (typeof my.acn.label_class() == 'object') ? my.acn.label_class().name() : my.acn.label_class();
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+
+ {
'id' : 'copy_number',
'fm_class' : 'acp',
'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
};
*/
circ.util.std_map_row_to_columns = function(error_value) {
- return function(row,cols) {
+ return function(row,cols,scratch) {
// row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
// cols contains all of the objects listed above in columns
+ // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in)
+ if (!scratch) { scratch = {}; }
var obj = {};
JSAN.use('util.error'); obj.error = new util.error();
try {
for (var i = 0; i < cols.length; i++) {
switch (typeof cols[i].render) {
- case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
+ case 'function': try { values[i] = cols[i].render(my,scratch); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
}
staff.circ.utils.not_cataloged=Not Cataloged
staff.circ.utils.retrieving=Retrieving...
staff.circ.utils.owning_lib=Owning Library
+staff.circ.utils.prefix=Prefix
+staff.circ.utils.suffix=Suffix
+staff.circ.utils.label_class=Classification
staff.circ.utils.loan_duration.short=Short
staff.circ.utils.loan_duration.normal=Normal
staff.circ.utils.loan_duration.long=Long
}
patron.util.std_map_row_to_columns = function(error_value) {
- return function(row,cols) {
+ return function(row,cols,scratch) {
// row contains { 'my' : { 'au' : {} } }
// cols contains all of the objects listed above in columns
+ // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in)
var obj = {}; obj.OpenILS = {};
JSAN.use('util.error'); obj.error = new util.error();