]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/src/javascript/backend/circ/circ_permit_hold.js
41e3374a72011665f1f1b008c6dd3a936ca33928
[Evergreen.git] / Evergreen / 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
7 /* is a staff member placing this hold? */
8 var isStaffHold = isGroupDescendant('Staff', patronProfile);
9
10
11 /* non-staff members are allowed 50 open holds at most */
12 if( ! isStaffHold ) {
13    var count = userHoldCount(patron.id);
14    log_info("patron has " + count + " open holds");
15    if( count >= 50 ) 
16       result.events.push('MAX_HOLDS');
17
18
19
20 if( isTrue(patron.barred) ) 
21         result.events.push('PATRON_BARRED');
22
23 if( isTrue(copy.ref) ) 
24         result.events.push('ITEM_NOT_HOLDABLE');
25
26 if( !isTrue(copy.circulate) ) 
27         result.events.push('ITEM_NOT_HOLDABLE');
28
29 /* all STATELIB items are holdable regardless of type */
30 if( isOrgDescendent('STATELIB', copy.circ_lib.id) ) return;
31
32
33 var mod = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : "";
34 var marcItemType = getMARCItemType();
35
36
37 log_info("circ-modifier = "+mod);
38 log_info("marc-type = "+marcItemType);
39
40
41 if( mod == 'bestsellernh' )
42         result.events.push('ITEM_NOT_HOLDABLE');
43
44
45 if( ( marcItemType == 'g' || 
46                 marcItemType == 'i' || 
47                 marcItemType == 'j' || 
48                 mod == 'softwrlong' || 
49                 mod == 'music' || 
50                 mod == 'audiobook' || 
51                 mod == 'av' || 
52                 mod == 'new-av' || 
53                 mod == 'cd' || 
54                 mod == 'kit' || 
55                 mod == 'dvd' || 
56                 mod == 'deposit' || 
57                 mod == 'atlas' || 
58                 mod == 'magazine' || 
59                 mod == 'equipment' || 
60                 mod == 'equip-long' || 
61                 mod == 'microform' || 
62                 mod == 'record' || 
63                 isTrue(copy.deposit) || 
64                 mod == 'video-long' || 
65                 mod == 'video' ) ) {
66
67
68         log_info("this is a range-protected item...");
69
70     if( ! hasCommonAncestor( volume.owning_lib, holdPickupLib, 1 ) ) {
71
72         /* we don't want these items to transit to the pickup lib */
73         result.events.push('ITEM_NOT_HOLDABLE');
74             log_info("pickup_lib is not in the owning_lib's region...NOT OK");
75
76     } else { /* pickup lib is in the owning region */
77
78         if( isStaffHold && hasCommonAncestor( volume.owning_lib, holdRequestLib.id, 1) ) {
79
80             /* staff in the region can place holds for patrons outside the region with local pickup lib */
81             log_info("local, staff-placed hold is allowed with local pickup_lib...OK");
82
83         } else {
84
85             if( hasCommonAncestor( volume.owning_lib, patron.home_ou.id, 1 ) ) {
86
87                 /* patrons can hold the item if they are registered 
88                     in the region and pickup lib is local */  
89                 log_info("patron's home_ou is in the owning region...OK");
90
91             } else {
92
93                 log_info("patron's home_ou lies outside the owning region...NOT OK");
94                 result.events.push('ITEM_NOT_HOLDABLE');
95             }
96         }
97     }
98 }
99
100
101
102
103 } go();
104
105
106