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 ) {
41 //if(holdRecipient == null ) {
46 if( holdRecipient == null ) holdRecipient = G.user;
47 if( holdRequestor == null ) holdRequestor = G.user;
49 if(!(holdRequestor && holdRequestor.session)) {
51 detachAllEvt('common','locationChanged');
52 attachEvt('common','loggedIn', holdsDrawWindow)
56 swapCanvas($('holds_box'));
58 var rec = findRecord( recid, type );
59 currentHoldsRecordObj = rec;
61 if(!holdsOrgSelectorBuilt) {
62 holdsBuildOrgSelector(null,0);
63 holdsOrgSelectorBuilt = true;
66 appendClear($('holds_recipient'), text(
67 holdRecipient.family_name() + ', ' +
68 holdRecipient.first_given_name()));
69 appendClear($('holds_title'), text(rec.title()));
70 appendClear($('holds_author'), text(rec.author()));
72 //removeChildren($('holds_format'));
73 for( var i in rec.types_of_resource() ) {
74 var res = rec.types_of_resource()[i];
75 var img = elem("img");
76 setResourcePic(img, res);
77 $('holds_format').appendChild(text(' '+res+' '));
78 $('holds_format').appendChild(img);
79 $('holds_format').appendChild(text(' '));
82 appendClear( $('holds_phone'), text(holdRecipient.day_phone()));
83 appendClear( $('holds_email'), text(holdRecipient.email()));
84 $('holds_cancel').onclick = showCanvas;
85 $('holds_submit').onclick = holdsPlaceHold;
89 function holdsBuildOrgSelector(node, depth) {
96 var selector = $('holds_org_selector');
97 var index = selector.options.length;
100 var pre = elem("pre");
101 for(var x=2; x <= findOrgType(node.ou_type()).depth(); x++) {
102 pre.appendChild(text(" "));
104 pre.appendChild(text(node.name()));
105 var select = new Option("", node.id());
106 selector.options[index] = select;
107 select.appendChild(pre);
110 var pad = (findOrgType(node.ou_type()).depth() - 1) * 12;
112 var select = new Option(node.name(), node.id());
113 select.setAttribute("style", "padding-left: "+pad+'px;');
114 selector.options[index] = select;
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];
125 holdsBuildOrgSelector(child, depth+1);
130 function holdsPlaceHold() {
132 var org = $('holds_org_selector').options[
133 $('holds_org_selector').selectedIndex].value;
135 var hold = new ahr();
136 hold.pickup_lib(org);
137 hold.request_lib(org);
138 hold.requestor(holdRequestor.id());
139 hold.usr(holdRecipient.id());
141 hold.email_notify(holdRecipient.email());
142 hold.phone_notify(holdRecipient.day_phone());
143 hold.target(currentHoldRecord);
145 var req = new Request( CREATE_HOLD, holdRequestor.session, hold );
147 var res = req.result();
149 if( res == '1' ) alert($('holds_success').innerHTML);
150 else alert($('holds_failure').innerHTML);
153 holdRecipient = null;
154 holdRequestor = null;
157 function holdsCancel(holdid, user) {
158 if(!user) user = G.user;
159 var req = new Request(CANCEL_HOLD, user.session, holdid);