3 var currentHoldRecordObj;
4 var holdsOrgSelectorBuilt = false;
11 function holdsHandleStaff() {
12 swapCanvas($('xulholds_box'));
13 $('xul_recipient_barcode').focus();
14 $('xul_recipient_barcode').onkeypress = function(evt)
15 {if(userPressedEnter(evt)) { _holdsHandleStaff(); } };
16 $('xul_recipient_barcode_submit').onclick = _holdsHandleStaff;
19 function _holdsHandleStaff() {
20 var barcode = $('xul_recipient_barcode').value;
21 var user = grabUserByBarcode( G.user.session, barcode );
22 var code = checkILSEvent(user);
24 alertILSEvent(code, barcode);
29 holdsDrawWindow( currentHoldRecord, null );
32 function holdsDrawWindow(recid, type) {
35 recid = currentHoldRecord;
36 if(recid == null) return;
38 currentHoldRecord = recid;
40 if(isXUL() && holdRecipient == null ) {
45 if( holdRecipient == null ) holdRecipient = G.user;
46 if( holdRequestor == null ) holdRequestor = G.user;
48 if(!(holdRequestor && holdRequestor.session)) {
50 detachAllEvt('common','locationChanged');
51 attachEvt('common','loggedIn', holdsDrawWindow)
57 swapCanvas($('check_holds_box'));
58 setTimeout( function() { holdsCheckPossibility(recid, type); }, 10 );
61 function _holdsDrawWindow(recid, type) {
63 swapCanvas($('holds_box'));
65 var rec = findRecord( recid, type );
66 currentHoldsRecordObj = rec;
68 if(!holdsOrgSelectorBuilt) {
69 holdsBuildOrgSelector(null,0);
70 holdsOrgSelectorBuilt = true;
73 appendClear($('holds_recipient'), text(
74 holdRecipient.family_name() + ', ' +
75 holdRecipient.first_given_name()));
76 appendClear($('holds_title'), text(rec.title()));
77 appendClear($('holds_author'), text(rec.author()));
79 removeChildren($('holds_format'));
80 for( var i in rec.types_of_resource() ) {
81 var res = rec.types_of_resource()[i];
82 var img = elem("img");
83 setResourcePic(img, res);
84 $('holds_format').appendChild(text(' '+res+' '));
85 $('holds_format').appendChild(img);
86 $('holds_format').appendChild(text(' '));
89 appendClear( $('holds_phone'), text(holdRecipient.day_phone()));
90 appendClear( $('holds_email'), text(holdRecipient.email()));
91 $('holds_cancel').onclick = showCanvas;
92 $('holds_submit').onclick = holdsPlaceHold;
96 function holdsCheckPossibility(recid, type) {
97 var req = new Request(CHECK_HOLD_POSSIBLE, G.user.session,
98 { titleid : recid, patronid : G.user.id(), depth : 0 } );
100 var res = req.result();
102 if(res) _holdsDrawWindow(recid, type);
107 function holdsBuildOrgSelector(node) {
109 if(!node) node = globalOrgTree;
111 var selector = $('holds_org_selector');
112 var index = selector.options.length;
114 var indent = findOrgType(node.ou_type()).depth() - 1;
115 setSelectorVal( selector, index, node.name(), node.id(), null, indent );
117 if( node.id() == holdRecipient.home_ou() ) {
118 selector.selectedIndex = index;
119 selector.options[index].selected = true;
122 for( var i in node.children() ) {
123 var child = node.children()[i];
124 if(child) holdsBuildOrgSelector(child);
128 function holdsPlaceHold() {
130 var org = $('holds_org_selector').options[
131 $('holds_org_selector').selectedIndex].value;
133 var hold = new ahr();
134 hold.pickup_lib(org);
135 hold.request_lib(org);
136 hold.requestor(holdRequestor.id());
137 hold.usr(holdRecipient.id());
139 hold.email_notify(holdRecipient.email());
140 hold.phone_notify(holdRecipient.day_phone());
141 hold.target(currentHoldRecord);
143 var req = new Request( CREATE_HOLD, holdRequestor.session, hold );
145 var res = req.result();
147 if( res == '1' ) alert($('holds_success').innerHTML);
148 else alert($('holds_failure').innerHTML);
151 holdRecipient = null;
152 holdRequestor = null;
155 function holdsCancel(holdid, user) {
156 if(!user) user = G.user;
157 var req = new Request(CANCEL_HOLD, user.session, holdid);