return ($note, $evt);
}
+sub fetch_call_numbers_by_title {
+ my( $self, $titleid ) = @_;
+ $logger->info("Fetching call numbers by title $titleid");
+ return $self->storagereq(
+ 'open-ils.storage.direct.asset.call_number.search.record.atomic', $titleid);
+}
+
+sub fetch_copies_by_call_number {
+ my( $self, $cnid ) = @_;
+ $logger->info("Fetching copies by call number $cnid");
+ return $self->storagereq(
+ 'open-ils.storage.direct.asset.copy.search.call_number.atomic', $cnid );
+}
1;
}
+__PACKAGE__->register_method(
+ method => 'note_batch',
+ api_name => 'open-ils.circ.biblio_notes.public.batch.retrieve',
+ signature => q/
+ Returns a set of notes for a given set of titles, volumes, and copies.
+ @param titleid The id of the title who's notes are retrieving
+ @return A list like so:
+ {
+ "titles" : [ { id : $id, notes : [ n1, n2 ] },... ]
+ "volumes" : [ { id : $id, notes : [ n1, n2 ] },... ]
+ "copies" : [ { id : $id, notes : [ n1, n2 ] },... ]
+ }
+ /
+);
+
+sub note_batch {
+ my( $self, $conn, $titleid ) = @_;
+
+ my @copies;
+ my $cns = $U->storagereq(
+ 'open-ils.storage.id_list.asset.call_number.search.record.atomic', $titleid );
+
+ for my $c (@$cns) {
+ my $copyids = $U->storagereq(
+ 'open-ils.storage.id_list.asset.copy.search.call_number.atomic', $c);
+ push(@copies, @$copyids);
+ }
+
+ return _note_batch( { titles => [$titleid], volumes => $cns, copies => \@copies} );
+}
+
+
+sub _note_batch {
+ my $args = shift;
+
+ my %resp;
+ $resp{titles} = [];
+ $resp{volumes} = [];
+ $resp{copies} = [];
+
+ my $titles = (ref($$args{titles})) ? $$args{titles} : [];
+ my $volumes = (ref($$args{volumes})) ? $$args{volumes} : [];
+ my $copies = (ref($$args{copies})) ? $$args{copies} : [];
+
+ for my $title (@$titles) {
+ my $notes = $U->storagereq(
+ 'open-ils.storage.direct.biblio.record_note.search_where.atomic',
+ { record => $title, pub => 't' });
+ push(@{$resp{titles}}, {id => $title, notes => $notes}) if @$notes;
+ }
+
+ for my $volume (@$volumes) {
+ my $notes = $U->storagereq(
+ 'open-ils.storage.direct.asset.call_number_note.search_where.atomic',
+ { call_number => $volume, pub => 't' });
+ push( @{$resp{volumes}}, {id => $volume, notes => $notes} ) if @$notes;
+ }
+
+
+ for my $copy (@$copies) {
+ $logger->debug("Fetching copy notes for copy $copy");
+ my $notes = $U->storagereq(
+ 'open-ils.storage.direct.asset.copy_note.search_where.atomic',
+ { owning_copy => $copy, pub => 't' });
+ push( @{$resp{copies}}, { id => $copy, notes => $notes }) if @$notes;
+ }
+
+ return \%resp;
+}
+
+
+
+
+
1;
var FLESH_PUBLIC_CONTAINER = 'open-ils.actor:open-ils.actor.container.public.flesh';
var FETCH_COPY = 'open-ils.search:open-ils.search.asset.copy.retrieve';
var CHECK_HOLD_POSSIBLE = 'open-ils.circ:open-ils.circ.title_hold.is_possible';
+var FETCH_BIBLIO_NOTES = 'open-ils.circ:open-ils.circ.biblio_notes.public.batch.retrieve';
/* ---------------------------------------------------------------------------- */
var defaultCN;
var callnumberCache = {};
var rdetailLocalOnly = true;
+var globalCNCache = {};
var nextContainerIndex;
function rdetailDraw() {
-
-
copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
statusRow = G.ui.rdetail.cp_status.parentNode;
hideMe($('rdetail_marc_div'));
hideMe($('cn_browse'));
hideMe($('rdetail_cn_browse_div'));
+ hideMe($('rdetail_notes_div'));
var req;
switch(type) {
unHideMe($('rdetail_cn_browse_div'));
rdetailShowCNBrowse(defaultCN, null, true);
break;
+
+ case 'notes':
+ unHideMe($('rdetail_notes_div'));
+ break;
}
}
for( var i = 0; i < summary.length; i++ ) {
var arr = summary[i];
+ globalCNCache[arr[1]] = 1;
var thisOrg = findOrgUnit(arr[0]);
var rowNode = $("cp_info_" + thisOrg.id());
+ if(!rowNode) continue;
if(rowNode.getAttribute("used")) {
if(!found) unHideMe(G.ui.rdetail.cp_info_none);
+ /* now that we know what CN's we have, grab the associated notes */
+ rdetailFetchNotes();
+}
+
+function rdetailFetchNotes() {
+ var req = new Request(FETCH_BIBLIO_NOTES, record.doc_id());
+ req.callback(rdetailDrawNotes);
+ req.send();
+}
+
+var rdetailNotesTemplate;
+function rdetailDrawNotes(r) {
+ var notes = r.getResultObject();
+
+ var tbody = $('rdetail_notes_tbody');
+ if(!rdetailNotesTemplate)
+ rdetailNotesTemplate = tbody.removeChild($('rdetail_notes_row'));
+
+ var found = false;
+ for( var t in notes.titles ) {
+ var note = notes.copies[c];
+ /* these need to go into a title notes
+ section different from the copy/cn notes (on the title summary?) */
+ }
+
+ for( var v in notes.volumes ) {
+ var note = notes.copies[c];
+ var row = rdetailNotesTemplate.cloneNode(true);
+ found = true;
+ }
+
+ for( var c in notes.copies ) {
+ found = true;
+ var copynode = notes.copies[c];
+ var copy = copynode.id;
+ var nts = copynode.notes;
+ for( var n in nts ) {
+ var note = nts[n];
+ var row = rdetailNotesTemplate.cloneNode(true);
+ $n(row, 'rdetail_notes_title').appendChild(text(note.title()));
+ $n(row, 'rdetail_notes_value').appendChild(text(note.value()));
+ tbody.appendChild(row);
+ }
+ }
+
+ if(found) unHideMe($('rdetail_viewnotes_link'));
}
function rdetailBuildBrowseInfo(row, cn, local) {
class='classic_link'>Annotation</a>
</td>
+ <td id='rdetail_viewnotes_link' class='hide_me rdetail_extras_td'
+ style='padding-right: 15px; padding-left: 15px;' >
+ <a href='javascript:rdetailShowExtra("notes");'
+ class='classic_link'>Item Notes</a>
+ </td>
+
<td id='rdetail_viewmarc_link' class='rdetail_extras_td'
style='padding-right: 15px; padding-left: 15px;' >
<a href='javascript:rdetailShowExtra("marc");'
class='classic_link'>MARC Record</a>
</td>
+
</tr>
</thead>
</table>
<!--#include virtual="../common/cn_browse.xml"-->
</div>
+ <!--#include virtual="rdetail_notes.xml"-->
+
</div>
</div>
--- /dev/null
+<div id='rdetail_notes_div' class='rdetail_extras_div hide_me'>
+ <table class='data_grid'>
+ <tbody id='rdetail_notes_tbody'>
+ <tr id='rdetail_notes_row'>
+ <td name='rdetail_notes_title'/>
+ <td name='rdetail_notes_value'/>
+ <td name='rdetail_notes_cn'/>
+ <td name='rdetail_notes_barcode'/>
+ <td name='rdetail_notes_owner'/>
+ </tr>
+ </tbody>
+ </table>
+</div>