From: Jeff Godin Date: Mon, 16 Apr 2012 14:47:49 +0000 (-0400) Subject: Use available copy summary in record detail page X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=162eef6951f4e152b5125279067a3a3fd1864fd4;p=evergreen%2Ftadl.git Use available copy summary in record detail page Having removed the copy info matrix/table from the record detail page, we now replace it with the new available copy summary from the search results page. When there are copies at multiple libraries, display a total count of available copies at each library. When there are copies available at only one library (which also happens when search is scoped to one library), display a count of available copies grouped by copy shelving location and call number label. Signed-off-by: Jeff Godin --- diff --git a/Open-ILS/web/opac/skin/tadlv3/xml/rdetail/rdetail_summary.xml b/Open-ILS/web/opac/skin/tadlv3/xml/rdetail/rdetail_summary.xml index 91f1bf19cf..d88fd592be 100644 --- a/Open-ILS/web/opac/skin/tadlv3/xml/rdetail/rdetail_summary.xml +++ b/Open-ILS/web/opac/skin/tadlv3/xml/rdetail/rdetail_summary.xml @@ -122,6 +122,185 @@ + + + Copy Availability + + + + = max_items) { + // return output.innerHTML; + //} + if (vol.getAttribute('deleted') == 't') { + return; + } + if (vol.getAttribute('opac_visible') == 'f') { + return; + } + dojo.query('uri', vol).forEach(function (uri) { + var urihref = uri.getAttribute('href'); + var urilabel = uri.getAttribute('label'); + if (urihref.substring(0,20) == "http://via.tadl.org/") { + var uri_entry = dojo.create('div', {"style":"padding-bottom: 5px;"}); + var link = dojo.create('a', {"class":"css_button", "href": urihref}, uri_entry); + if (urilabel.substring(0,7) == "http://") { + // Provide a default label if label appears to be a URL + urilabel = "Connect to this resource online"; + } + var link_text = dojo.doc.createTextNode(urilabel); + link.appendChild(link_text); + output.appendChild(uri_entry); + } + }); + dojo.query('copy', vol).forEach(function (cp) { + var cp_status; + var cp_location; + var cp_circ_lib; + //if (item_cnt >= max_items) { + // return; + //} + if (cp.getAttribute('deleted') == 't') { + return; + } + if (cp.getAttribute('opac_visible') == 'f') { + return; + } + + /* Ensure the status is visible */ + var visible_status; + dojo.query('status', cp).forEach(function (status) { + visible_status = status.getAttribute('opac_visible'); + cp_status = status; + }); + if (visible_status == 'f') { + return; + } + + /* Ensure the circulation library is visible */ + var lib_vis; + dojo.query('circ_lib', cp).forEach(function (circ_lib) { + lib_vis = circ_lib.getAttribute('opac_visible'); + cp_circ_lib = circ_lib; + }); + if (lib_vis != 't') { + return; + } + + var loc_visible; + dojo.query('location', cp).forEach(function (location) { + loc_visible = location.getAttribute('opac_visible'); + cp_location = location; + }); + if (loc_visible != 't') { + return; + } + // at this point we have vol, cp_circ_lib, cp_location, cp_status + var status_id = cp_status.getAttribute('ident'); + if (!(status_id in {0:1, 7:1, 109:1})) { + count_copies_unavail++; + return; + } else { + count_copies_avail++; + } + var libkey = cp_circ_lib.getAttribute('name'); + var lockey = BT.textContent(cp_location); + var cnkey = vol.getAttribute('label'); + + if (!copySummaryObj[libkey]) { + copySummaryObj[libkey] = new Object(); + } + if (!copySummaryObj[libkey][lockey]) { + copySummaryObj[libkey][lockey] = new Object(); + } + if (!copySummaryObj[libkey][lockey][cnkey]) { + copySummaryObj[libkey][lockey][cnkey] = new Object(); + copySummaryObj[libkey][lockey][cnkey]['count'] = 0; + } + copySummaryObj[libkey][lockey][cnkey]['count']++; + + item_cnt++; + //if (item_cnt >= max_items) { + // dojo.create('br', null, cp_entry); + // cp_entry.appendChild(dojo.doc.createTextNode(opac_strings.MORE_COPIES_FULL_RECORD)); + //} + //output.appendChild(cp_entry); + }); + }); + var numLibs = 0; + for (var lib in copySummaryObj) { + numLibs++; + } + if (numLibs == 0) { return; } + if (numLibs == 1) { + var lines_output = 0; + var sumdiv = dojo.create('div', { "style": "font-weight: bold;" }); + // output the grouped-by-location summary + for (var sumlib in copySummaryObj) { + //output the "at lib" + var atlib = dojo.create('div', null, sumdiv); + atlib.appendChild(dojo.doc.createTextNode('At ' + sumlib)); + for (var sumloc in copySummaryObj[sumlib]) { + for (var sumcn in copySummaryObj[sumlib][sumloc]) { + // available copies in each location, by cn label + if (max_lines && lines_output >= max_lines) { + var morediv = dojo.create('div', { "style": "font-weight: bold;" }, sumdiv); + morediv.appendChild(dojo.doc.createTextNode("additional copies available - click title for details")); + } else { + var sumcount = copySummaryObj[sumlib][sumloc][sumcn]['count']; + var summary_line = sumcount + ' available in ' + sumloc + ', call number ' + sumcn; + var locdiv = dojo.create('div', null, sumdiv); + locdiv.appendChild(dojo.doc.createTextNode(summary_line)); + lines_output++; + } + } + } + } + output.appendChild(sumdiv); + } else { + // output the grouped-by-library summary + for (var libname in copySummaryObj) { + var copycount = 0; + for (var loc in copySummaryObj[libname]) { + for (var cn in copySummaryObj[libname][loc]) { + copycount = copycount + copySummaryObj[libname][loc][cn]['count']; + } + } + } + var libdiv = dojo.create('div'); + var libcontent = dojo.create('span', { "style": "font-weight: bold;" }); + var libtext = dojo.doc.createTextNode(copycount + ' available at ' + libname); + libcontent.appendChild(libtext); + libdiv.appendChild(libcontent); + output.appendChild(libdiv); + } + // display the count of unavailable items, if any + if (count_copies_unavail > 0) { + other_or_null = (count_copies_avail > 0) ? 'other ' : ' '; + item_or_items = (count_copies_unavail > 1) ? 'items' : 'item'; + output.appendChild( + dojo.doc.createTextNode( + count_copies_unavail + " " + other_or_null + item_or_items + " not currently available" + ) + ); + } + return output.innerHTML; + ]]> + + + + + Current Holds