);
sub lineitems_related_by_bib {
- my($self, $conn, $auth, $id_value, $options) = @_;
+ my($self, $conn, $auth, $test_value, $options) = @_;
my $e = new_editor(authtoken => $auth);
return $e->event unless $e->checkauth;
my $perm_orgs = $U->user_has_work_perm_at($e, 'VIEW_PURCHASE_ORDER', {descendants =>1}, $e->requestor->id);
- if ($self->api_name =~ /by_lineitem_id/) {
- my $orig = retrieve_lineitem($self, $conn, $auth, $id_value) or
- return $e->die_event;
- $id_value = $orig->eg_bib_id;
- }
-
my $query = {
"select"=>{"jub"=>["id"]},
"from"=>{"jub"=>"acqpo"},
"where"=>{
- "eg_bib_id"=>$id_value,
"+acqpo"=>{
"ordering_agency"=>{
"in"=>$perm_orgs
"order_by"=>[{"class"=>"jub", "field"=>"create_time", "direction"=>"desc"}]
};
+ # Be sure we just return the original LI if no related bibs
+ if ($self->api_name =~ /by_lineitem_id/) {
+ my $orig = retrieve_lineitem($self, $conn, $auth, $test_value) or
+ return $e->die_event;
+ if ($test_value = $orig->eg_bib_id) {
+ $query->{"where"}->{"eg_bib_id"} = $test_value;
+ } else {
+ $query->{"where"}->{"id"} = $orig->id;
+ }
+ } elsif ($test_value) {
+ $query->{"where"}->{"eg_bib_id"} = $test_value;
+ } else {
+ $e->disconnect;
+ return new OpenILS::Event("BAD_PARAMS", "Null bib id");
+ }
+
if ($options && defined $options->{lineitem_state}) {
$query->{'where'}{'jub'}{'state'} = $options->{lineitem_state};
}
"flesh_attrs", additionaly return the list of flattened attributes
"clear_marc", discards the raw MARC data to reduce data size
"flesh_notes", flesh lineitem notes
+ "flesh_cancel_reason", flesh cancel_reason
/,
type => 'hash'}
],
my $entry;
my $flesh = {};
- if($$options{flesh_attrs} or $$options{flesh_notes}) {
+ if($$options{flesh_attrs} or $$options{flesh_notes} or $$options{flesh_cancel_reason}) {
$flesh = {flesh => 2, flesh_fields => {jub => []}};
if($$options{flesh_notes}) {
push(@{$flesh->{flesh_fields}->{jub}}, 'lineitem_notes');
$flesh->{flesh_fields}->{acqlin} = ['alert_text'];
}
push(@{$flesh->{flesh_fields}->{jub}}, 'attributes') if $$options{flesh_attrs};
+ push @{$flesh->{flesh_fields}->{jub}}, 'cancel_reason' if $$options{flesh_cancel_reason};
}
$entry = $e->retrieve_acq_lineitem([$id, $flesh]);
var state_cell = nodeByName("li_state", row);
if (li.state() == "cancelled") {
- var holds_state = dojo.create(
- "span", {
- "style": "border-bottom: 1px dashed #000;",
- "innerHTML": li.state()
- }, state_cell, "only"
- );
- new dijit.Tooltip(
- {
- "label": "<em>" + li.cancel_reason().label() +
- "</em><br />" + li.cancel_reason().description(),
- "connectId": [holds_state]
- }, dojo.create("span", null, state_cell, "last")
- );
+ if (typeof li.cancel_reason() == "object") {
+ var holds_state = dojo.create(
+ "span", {
+ "style": "border-bottom: 1px dashed #000;",
+ "innerHTML": li.state()
+ }, state_cell, "only"
+ );
+ new dijit.Tooltip(
+ {
+ "label": "<em>" + li.cancel_reason().label() +
+ "</em><br />" + li.cancel_reason().description(),
+ "connectId": [holds_state]
+ }, dojo.create("span", null, state_cell, "last")
+ );
+ } else {
+ state_cell.innerHTML = li.state(); // TODO i18n state labels
+ }
} else {
state_cell.innerHTML = li.state(); // TODO i18n state labels
}
"params": [openils.User.authtoken, liId, {
"flesh_attrs": true,
"flesh_li_details": true,
- "flesh_fund_debit": true
+ "flesh_fund_debit": true,
+ "flesh_cancel_reason": true
}],
"oncomplete": function(r) {
drawLiInfo(openils.Util.readResponse(r));
["open-ils.acq", "open-ils.acq.lineitems_for_bib.by_lineitem_id"], {
"async": true,
"params": [openils.User.authtoken, liId, {
- "flesh_attrs": true, "flesh_notes": true
+ "flesh_attrs": true,
+ "flesh_notes": true,
+ "flesh_cancel_reason": true
}],
"onresponse": function(r) {
var resp = openils.Util.readResponse(r);