]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_permit_hold.js
added some new limited range circ mods
[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 == 'kit' || 
37                 mod == 'dvd' || 
38                 mod == 'deposit' || 
39                 mod == 'atlas' || 
40                 mod == 'magazine' || 
41                 mod == 'equipment' || 
42                 mod == 'equip-long' || 
43                 mod == 'microform' || 
44                 mod == 'record' || 
45                 isTrue(copy.deposit) || 
46                 mod == 'video-long' || 
47                 mod == 'video' ) ) {
48
49         isAnc = hasCommonAncestor( copy.circ_lib.id, patron.home_ou.id, 1 );
50
51         if( isAnc) {
52                 log_info("patron and copy circ_lib share a common ancestor, hold allowed");
53
54         } else {
55                 log_info("patron and copy circ_lib do NOT share a common ancestor");
56
57                 if( hasCommonAncestor( copy.circ_lib.id, holdRequestLib.id, 1) ) {
58                         log_info("request_lib and copy circ_lib DO share a common ancestor");
59
60                 } else {
61
62                         log_info("request_lib and copy circ_lib also do NOT share a common ancestor, hold on this type of material not allowed");
63                         result.events.push('ITEM_NOT_HOLDABLE');
64                 }
65         }
66 }
67
68
69 } go();
70