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)
55 swapCanvas($('holds_box'));
57 var rec = findRecord( recid, type );
58 currentHoldsRecordObj = rec;
60 if(!holdsOrgSelectorBuilt) {
61 holdsBuildOrgSelector(null,0);
62 holdsOrgSelectorBuilt = true;
65 appendClear($('holds_recipient'), text(
66 holdRecipient.family_name() + ', ' +
67 holdRecipient.first_given_name()));
68 appendClear($('holds_title'), text(rec.title()));
69 appendClear($('holds_author'), text(rec.author()));
71 //removeChildren($('holds_format'));
72 for( var i in rec.types_of_resource() ) {
73 var res = rec.types_of_resource()[i];
74 var img = elem("img");
75 setResourcePic(img, res);
76 $('holds_format').appendChild(text(' '+res+' '));
77 $('holds_format').appendChild(img);
78 $('holds_format').appendChild(text(' '));
81 appendClear( $('holds_phone'), text(holdRecipient.day_phone()));
82 appendClear( $('holds_email'), text(holdRecipient.email()));
83 $('holds_cancel').onclick = showCanvas;
84 $('holds_submit').onclick = holdsPlaceHold;
88 function holdsBuildOrgSelector(node) {
90 if(!node) node = globalOrgTree;
92 var selector = $('holds_org_selector');
93 var index = selector.options.length;
95 var indent = findOrgType(node.ou_type()).depth() - 1;
96 setSelectorVal( selector, index, node.name(), node.id(), null, indent );
98 if( node.id() == holdRecipient.home_ou() ) {
99 selector.selectedIndex = index;
100 selector.options[index].selected = true;
103 for( var i in node.children() ) {
104 var child = node.children()[i];
105 if(child) holdsBuildOrgSelector(child);
109 function holdsPlaceHold() {
111 var org = $('holds_org_selector').options[
112 $('holds_org_selector').selectedIndex].value;
114 var hold = new ahr();
115 hold.pickup_lib(org);
116 hold.request_lib(org);
117 hold.requestor(holdRequestor.id());
118 hold.usr(holdRecipient.id());
120 hold.email_notify(holdRecipient.email());
121 hold.phone_notify(holdRecipient.day_phone());
122 hold.target(currentHoldRecord);
124 var req = new Request( CREATE_HOLD, holdRequestor.session, hold );
126 var res = req.result();
128 if( res == '1' ) alert($('holds_success').innerHTML);
129 else alert($('holds_failure').innerHTML);
132 holdRecipient = null;
133 holdRequestor = null;
136 function holdsCancel(holdid, user) {
137 if(!user) user = G.user;
138 var req = new Request(CANCEL_HOLD, user.session, holdid);