PROCESS "opac/parts/misc_util.tt2";
PROCESS get_library;
%]
+
<form action="[% ctx.opac_root %]/results" method="get">
<div id='adv_global_search' class='data_grid data_grid_center'>
<div id='adv_search_rows'>
</div>
[% END %]
+ <div class="adv_course_materials_filter" id='course_reserves_facet'>
+ <input type='checkbox' name="coursereserves" value="filtercoursereserves"
+ onclick="add_course_reserves_ids_to_query()"
+ [%- CGI.param('coursereserves').grep(filtercoursereserves).size ?
+ 'checked="checked"' : '' %]
+ id='opac.result.filterwithreserves' />
+ <label for='opac.result.filterwithreserves'>
+ [% l("Filter With Course Reserves") %]</label>
+ <input type='checkbox' name="query" value=""
+ [%- CGI.param('coursereserves').grep(filtercoursereserves).size ?
+ 'checked="checked"' : '' %] id='coursereservesvalue' hidden />
+ <input type='checkbox' name="qtype" value="keyword"
+ [%- CGI.param('coursereserves').grep(filtercoursereserves).size ?
+ 'checked="checked"' : '' %] id='coursereservesqtype' hidden />
+ <input type='checkbox' name="contains" value="contains"
+ [%- CGI.param('coursereserves').grep(filtercoursereserves).size ?
+ 'checked="checked"' : '' %] id='coursereservescontains' hidden />
+ </div>
+
[% CASE "copy_location" %]
<select id="adv_copy_location_selector"
title="[% l('Select Shelving Location') %]"
dojo.require("DojoSRF");
dojo.require("openils.CGI");
+
+var course_list_query=[];
+
+/**
+ * Query the database for the course reserves materials.
+ */
+function get_course_reserves(display_orgs) {
+ var params = [{
+ cache : 1,
+ fields : ['item'],
+ query : {course : display_orgs}
+ }];
+ new OpenSRF.ClientSession('open-ils.fielder').request({
+ method: 'open-ils.fielder.acmcm.atomic',
+ params: params,
+ async: true,
+ oncomplete: function(r) {
+ var resp = r.recv();
+ if (resp) {
+ var list = resp.content();
+ //List out all the items, and add them to a list.
+ dojo.forEach(list, function(item, index) {
+ if(index == 0){ //If this is the first entry, create the string.
+ course_list_query = "(id:"+item.item+") ";
+ } else{ course_list_query += "|| (id:"+item.item+") ";}
+ })
+ filter_reserves();
+ }
+ }
+ }).send();
+}
+
+
+/**
+ * Add the query to the filterwithreserves checkbox
+ */
+function filter_reserves() {
+ dojo.byId("coursereservesvalue").setAttribute('value',course_list_query)
+}
+
+
+window.add_course_reserves_ids_to_query = add_course_reserves_ids_to_query;
+function add_course_reserves_ids_to_query() {
+ course_reserves = dojo.byId("opac.result.filterwithreserves");
+
+ if(!course_reserves.getAttribute("checked") || course_reserves.getAttribute("checked")=="") {
+ console.log("Checked", course_reserves.getAttribute("checked") )
+ course_reserves.setAttribute("checked", 'checked')
+ dojo.byId("coursereservesvalue").setAttribute("checked", 'checked')
+ dojo.byId("coursereservesqtype").setAttribute("checked", 'checked')
+ dojo.byId("coursereservescontains").setAttribute("checked", 'checked')
+ }else {
+ console.log("Unchecked", course_reserves.getAttribute("checked") )
+ course_reserves.setAttribute("checked", '')
+ dojo.byId("coursereservesvalue").setAttribute("checked", '')
+ dojo.byId("coursereservesqtype").setAttribute("checked", '')
+ dojo.byId("coursereservescontains").setAttribute("checked", '')
+ }
+}
+
// called on initial page load and when the advance search org unit
// selector is changed.
function apply_adv_copy_locations() {
display_orgs.push(org_unit.id);
collect_parent_orgs(org_unit.parent_ou);
fetch_adv_copy_locations(display_orgs);
+ get_course_reserves(display_orgs)
}
function fetch_adv_copy_locations(org_ids) {
} else {
dojo.addClass('adv_chunk_copy_location', 'hidden');
}
- }
+ }
}).send();
}
if (!dojo.isArray(url_selected))
url_selected = [url_selected];
}
-
dojo.removeClass('adv_chunk_copy_location', 'hidden');
-
+
// sort by name
locations = locations.sort(
function(a, b) {return a.name < b.name ? -1 : 1}