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 );
23 alert( '(' + barcode + ') => ' + $('user_not_found').innerHTML );
28 holdsDrawWindow( currentHoldRecord, null );
31 function holdsDrawWindow(recid, type) {
34 recid = currentHoldRecord;
35 if(recid == null) return;
37 currentHoldRecord = recid;
39 //if(isXUL() && holdRecipient == null ) {
40 if(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, depth) {
95 var selector = $('holds_org_selector');
96 var index = selector.options.length;
99 var pre = elem("pre");
100 for(var x=2; x <= findOrgType(node.ou_type()).depth(); x++) {
101 pre.appendChild(text(" "));
103 pre.appendChild(text(node.name()));
104 var select = new Option("", node.id());
105 selector.options[index] = select;
106 select.appendChild(pre);
109 var pad = (findOrgType(node.ou_type()).depth() - 1) * 12;
111 var select = new Option(node.name(), node.id());
112 select.setAttribute("style", "padding-left: "+pad+'px;');
113 selector.options[index] = select;
116 if( node.id() == holdRecipient.home_ou() ) {
117 selector.selectedIndex = index;
118 selector.options[index].selected = true;
121 for( var i in node.children() ) {
122 var child = node.children()[i];
124 holdsBuildOrgSelector(child, depth+1);
129 function holdsPlaceHold() {
131 var org = $('holds_org_selector').options[
132 $('holds_org_selector').selectedIndex].value;
134 var hold = new ahr();
135 hold.pickup_lib(org);
136 hold.request_lib(org);
137 hold.requestor(holdRequestor.id());
138 hold.usr(holdRecipient.id());
140 hold.email_notify(holdRecipient.email());
141 hold.phone_notify(holdRecipient.day_phone());
142 hold.target(currentHoldRecord);
144 var req = new Request( CREATE_HOLD, holdRequestor.session, hold );
146 var res = req.result();
148 if( res == '1' ) alert($('holds_success').innerHTML);
149 else alert($('holds_failure').innerHTML);
152 holdRecipient = null;
153 holdRequestor = null;
156 function holdsCancel(holdid, user) {
157 if(!user) user = G.user;
158 var req = new Request(CANCEL_HOLD, user.session, holdid);