]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit_hold.js
now all STATELIB items are holdable regardless of type
[working/Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_permit_hold.js
1 function go() {
2
3 load_lib('circ/circ_lib.js');
4 log_vars('circ_permit_hold');
5
6 if( isTrue(patron.barred) ) 
7         result.events.push('PATRON_BARRED');
8
9 if( isTrue(copy.ref) ) 
10         result.events.push('ITEM_NOT_HOLDABLE');
11
12 if( !isTrue(copy.circulate) ) 
13         result.events.push('ITEM_NOT_HOLDABLE');
14
15 /* all STATELIB items are holdable regardless of type */
16 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
17
18 var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
19
20 log_info("circ-modifier = "+mod);
21
22 if( mod == 'bestsellernh' )
23         result.events.push('ITEM_NOT_HOLDABLE');
24
25 var marcItemType = getMARCItemType();
26 var isAnc;
27
28 if( ( marcItemType == 'g' || 
29                 marcItemType == 'i' || 
30                 marcItemType == 'j' || 
31                 mod == 'softwrlong' || 
32                 mod == 'music' || 
33                 mod == 'audiobook' || 
34                 mod == 'av' || 
35                 mod == 'cd' || 
36                 mod == 'dvd' || 
37                 isTrue(copy.deposit) || 
38                 mod == 'video-long' || 
39                 mod == 'video' ) ) {
40
41         isAnc = hasCommonAncestor( copy.circ_lib.id, patron.home_ou.id, 1 );
42
43         if( isAnc) {
44                 log_info("patron and copy circ_lib share a common ancestor, hold allowed");
45
46         } else {
47                 log_info("patron and copy circ_lib do NOT share a common ancestor");
48
49                 if( hasCommonAncestor( copy.circ_lib.id, holdRequestLib.id, 1) ) {
50                         log_info("request_lib and copy circ_lib DO share a common ancestor");
51
52                 } else {
53
54                         log_info("request_lib and copy circ_lib also do NOT share a common ancestor, hold on this type of material not allowed");
55                         result.events.push('ITEM_NOT_HOLDABLE');
56                 }
57         }
58 }
59
60
61 } go();
62