]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_item_config.js
added check for staff to apply the staff max/recurring fines levels
[Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_item_config.js
1 load_lib('circ/circ_lib.js');
2 log_debug('loading circ_item_config.js ...');
3
4
5 /* SIP media types
6 000 Other
7 001 Book
8 002 Magazine
9 003 Bound journal
10 004 Audio tape
11 005 Video tape
12 006 CD/CDROM
13 007 Diskette
14 008 Book with diskette
15 009 Book with CD
16 010 Book with audio tape
17 */
18
19 /* ----------------------------------------------------------------------------- 
20         Configure the duration rules for the various item types and circ modifiers
21
22         MARC Fixed Field info:
23         http://www.oclc.org/bibformats/en/fixedfield/
24
25         ----------------------------------------------------------------------------- */
26
27 var MARC_ITEM_TYPE_MAP = {
28
29         a : { /* Language material [Books] */
30                 SIPMediaType                    : '001',
31                 magneticMedia                   : 'f',
32                 durationRule                    : '14_days_2_renew',
33                 recurringFinesRule      : '10_cent_per_day',
34                 maxFine                                 : 'overdue_mid'
35         },
36
37         t : { /* Manuscript language material [Books] */
38                 SIPMediaType                    : '001',
39                 magneticMedia                   : 'f',
40                 durationRule                    : '14_days_2_renew',
41                 recurringFinesRule      : '10_cent_per_day',
42                 maxFine                                 : 'overdue_mid'
43         },
44
45         g : { /* Projected medium [Videos, etc.] */
46                 SIPMediaType                    : '005',
47                 magneticMedia                   : 'f',
48                 durationRule                    : '7_days_0_renew',
49                 recurringFinesRule      : '10_cent_per_day',
50                 maxFine                                 : 'overdue_mid'
51         },
52
53         k : { /* Two-dimensional nonprojectable graphic [Card, charts, etc.] */
54                 SIPMediaType                    : '001',
55                 magneticMedia                   : 'f',
56                 durationRule                    : '3_month_0_renew',
57                 recurringFinesRule      : '10_cent_per_day',
58                 maxFine                                 : 'overdue_mid'
59         },
60
61         r : { /* Three-dimensional artifact or naturally occurring object [Models, games, etc.] */ 
62                 SIPMediaType                    : '001',
63                 magneticMedia                   : 'f',
64                 durationRule                    : '14_days_2_renew',
65                 recurringFinesRule      : '10_cent_per_day',
66                 maxFine                                 : 'overdue_mid'
67         },
68
69         o : { /* Kit [Mixture of item types] */
70                 SIPMediaType                    : '001',
71                 magneticMedia                   : 'f',
72                 durationRule                    : '14_days_2_renew',
73                 recurringFinesRule      : '10_cent_per_day',
74                 maxFine                                 : 'overdue_mid'
75         },
76
77         p : { /* Mixed materials [Mixture of item types] */
78                 SIPMediaType                    : '001',
79                 magneticMedia                   : 'f',
80                 durationRule                    : '14_days_2_renew',
81                 recurringFinesRule      : '10_cent_per_day',
82                 maxFine                                 : 'overdue_mid'
83         },
84
85         e : { /* Cartographic material [Map] */
86                 SIPMediaType                    : '001',
87                 magneticMedia                   : 'f',
88                 durationRule                    : '7_days_2_renew',
89                 recurringFinesRule      : '50_cent_per_day',
90                 maxFine                                 : 'overdue_mid'
91         },
92
93         f : { /* Manuscript cartographic material [Map] */
94                 SIPMediaType                    : '001',
95                 magneticMedia                   : 'f',
96                 durationRule                    : '3_days_1_renew',
97                 recurringFinesRule      : '50_cent_per_day',
98                 maxFine                                 : 'overdue_mid'
99         },
100
101         c : { /* Notated music [Printed music] */
102                 SIPMediaType                    : '001',
103                 magneticMedia                   : 'f',
104                 durationRule                    : '14_days_2_renew',
105                 recurringFinesRule      : '10_cent_per_day',
106                 maxFine                                 : 'overdue_mid'
107         },
108
109         d : { /* Manuscript notated music [Printed music] */
110                 SIPMediaType                    : '001',
111                 magneticMedia                   : 'f',
112                 durationRule                    : '14_days_2_renew',
113                 recurringFinesRule      : '10_cent_per_day',
114                 maxFine                                 : 'overdue_mid'
115         },
116
117         i : { /* Nonmusical sound recording [Audiobooks, sound effects, etc.] */
118                 SIPMediaType                    : '001',
119                 magneticMedia                   : 'f',
120                 durationRule                    : '14_days_2_renew',
121                 recurringFinesRule      : '10_cent_per_day',
122                 maxFine                                 : 'overdue_mid'
123         },
124
125         j : { /* Musical sound recording [Music] */
126                 SIPMediaType                    : '001',
127                 magneticMedia                   : 'f',
128                 durationRule                    : '14_days_2_renew',
129                 recurringFinesRule      : '10_cent_per_day',
130                 maxFine                                 : 'overdue_mid'
131         },
132
133         m : { /* Computer file */
134                 SIPMediaType                    : '001',
135                 magneticMedia                   : 'f',
136                 durationRule                    : '14_days_2_renew',
137                 recurringFinesRule      : '10_cent_per_day',
138                 maxFine                                 : 'overdue_mid'
139         }
140 }
141
142
143 var CIRC_MOD_MAP = {
144
145         'art'           : {
146                 SIPMediaType                    : '000',
147                 magneticMedia                   : 'f',
148                 durationRule                    : '3_month_0_renew',
149                 recurringFinesRule      : '10_cent_per_day',
150                 maxFine                                 : 'overdue_mid'
151         },
152
153         'atlas'         : {
154                 SIPMediaType                    : '000',
155                 magneticMedia                   : 'f',
156                 durationRule                    : '7_days_2_renew',
157                 recurringFinesRule      : '50_cent_per_day',
158                 maxFine                                 : 'overdue_mid'
159         },
160
161         'audiobook' : {
162                 SIPMediaType                    : '004',
163                 magneticMedia                   : 'f',
164                 durationRule                    : '14_days_2_renew',
165                 recurringFinesRule      : '10_cent_per_day',
166                 maxFine                                 : 'overdue_mid'
167         },
168
169         'av' : {
170                 SIPMediaType                    : '005',
171                 magneticMedia                   : 'f',
172                 durationRule                    : '7_days_2_renew',
173                 recurringFinesRule      : '50_cent_per_day',
174                 maxFine                                 : 'overdue_mid'
175         },
176
177         'bestseller'                            : {
178                 SIPMediaType                    : '001',
179                 magneticMedia                   : 'f',
180                 durationRule                    : '7_days_2_renew',
181                 recurringFinesRule      : '50_cent_per_day',
182                 maxFine                                 : 'overdue_mid'
183         },
184
185         'bestsellernh'                          : {
186                 SIPMediaType                    : '001',
187                 magneticMedia                   : 'f',
188                 durationRule                    : '7_days_2_renew',
189                 recurringFinesRule      : '50_cent_per_day',
190                 maxFine                                 : 'overdue_mid'
191         },
192
193         'book'                                          : {
194                 SIPMediaType                    : '001',
195                 magneticMedia                   : 'f',
196                 durationRule                    : '14_days_2_renew',
197                 recurringFinesRule      : '10_cent_per_day',
198                 maxFine                                 : 'overdue_mid'
199         },
200
201         'cd'                            : {
202                 SIPMediaType                    : '006',
203                 magneticMedia                   : 'f',
204                 durationRule                    : '14_days_2_renew',
205                 recurringFinesRule      : '10_cent_per_day',
206                 maxFine                                 : 'overdue_mid'
207         },
208
209         'dvd'                                                   : {
210                 SIPMediaType                    : '006',
211                 magneticMedia                   : 'f',
212                 durationRule                    : '7_days_0_renew',
213                 recurringFinesRule      : '50_cent_per_day',
214                 maxFine                                 : 'overdue_mid'
215         },
216
217         'e-book' : {
218                 SIPMediaType                    : '001',
219                 magneticMedia                   : 'f',
220                 durationRule                    : '3_days_1_renew',
221                 recurringFinesRule      : '50_cent_per_day',
222                 maxFine                                 : 'overdue_mid'
223         },
224
225         'equipment' : { 
226                 SIPMediaType                    : '000',
227                 magneticMedia                   : 'f',
228                 durationRule                    : '3_days_1_renew',
229                 recurringFinesRule      : '50_cent_per_day',
230                 maxFine                                 : 'overdue_mid'
231         },
232
233         'filmstrip'                                     : {
234                 SIPMediaType                    : '000',
235                 magneticMedia                   : 'f',
236                 durationRule                    : '14_days_2_renew',
237                 recurringFinesRule      : '10_cent_per_day',
238                 maxFine                                 : 'overdue_mid'
239         },
240
241         'kit' : {
242                 SIPMediaType                    : '000',
243                 magneticMedia                   : 'f',
244                 durationRule                    : '14_days_2_renew',
245                 recurringFinesRule      : '10_cent_per_day',
246                 maxFine                                 : 'overdue_mid'
247         },
248
249         'magazine'      : {
250                 SIPMediaType                    : '002',
251                 magneticMedia                   : 'f',
252                 durationRule                    : '14_days_2_renew',
253                 recurringFinesRule      : '10_cent_per_day',
254                 maxFine                                 : 'overdue_mid'
255         },
256
257         'map' : {
258                 SIPMediaType                    : '000',
259                 magneticMedia                   : 'f',
260                 durationRule                    : '3_days_1_renew',
261                 recurringFinesRule      : '50_cent_per_day',
262                 maxFine                                 : 'overdue_mid'
263         },
264
265         'microform' : {
266                 SIPMediaType                    : '000',
267                 magneticMedia                   : 'f',
268                 durationRule                    : '14_days_2_renew',
269                 recurringFinesRule      : '10_cent_per_day',
270                 maxFine                                 : 'overdue_mid'
271         },
272
273         'music' : {
274                 SIPMediaType                    : '004',
275                 magneticMedia                   : 'f',
276                 durationRule                    : '14_days_2_renew',
277                 recurringFinesRule      : '10_cent_per_day',
278                 maxFine                                 : 'overdue_mid'
279         },
280
281         'record'                                                : {
282                 SIPMediaType                    : '000',
283                 magneticMedia                   : 'f',
284                 durationRule                    : '14_days_2_renew',
285                 recurringFinesRule      : '10_cent_per_day',
286                 maxFine                                 : 'overdue_mid'
287         },
288
289         'software' : {
290                 SIPMediaType                    : '006',
291                 magneticMedia                   : 'f',
292                 durationRule                    : '7_days_2_renew',
293                 recurringFinesRule      : '10_cent_per_day',
294                 maxFine                                 : 'overdue_mid'
295         },
296
297         'talking book'                          : {  
298                 SIPMediaType                    : '006',
299                 magneticMedia                   : 'f',
300                 durationRule                    : 'unlimited',
301         },
302
303         'toy'                                                   : {
304                 SIPMediaType                    : '000',
305                 magneticMedia                   : 'f',
306                 durationRule                    : '7_days_2_renew',
307                 recurringFinesRule      : '50_cent_per_day',
308                 maxFine                                 : 'overdue_mid'
309         },
310
311         'video' : {
312                 SIPMediaType                    : '005',
313                 magneticMedia                   : 'f',
314                 durationRule                    : '7_days_0_renew',
315                 recurringFinesRule      : '50_cent_per_day',
316                 maxFine                                 : 'overdue_mid'
317         },
318 }
319
320
321 /* Set up rules for legacy types */
322 CIRC_MOD_MAP['DEPOSIT']         = CIRC_MOD_MAP['book'];
323 CIRC_MOD_MAP['E-AUDIO']         = CIRC_MOD_MAP['book'];
324 CIRC_MOD_MAP['EQUIP']           = CIRC_MOD_MAP['book'];
325 CIRC_MOD_MAP['FACBESTSLR'] = CIRC_MOD_MAP['book'];
326 CIRC_MOD_MAP['FACNEWBK']        = CIRC_MOD_MAP['book'];
327 CIRC_MOD_MAP['MAG-CIRC']        = CIRC_MOD_MAP['book'];
328 CIRC_MOD_MAP['MAG-NOCIRC'] = CIRC_MOD_MAP['book'];
329 CIRC_MOD_MAP['NEW-AV']          = CIRC_MOD_MAP['book'];
330 CIRC_MOD_MAP['NEW-BOOK']        = CIRC_MOD_MAP['book'];
331 CIRC_MOD_MAP['NEWSPAPER']       = CIRC_MOD_MAP['book'];
332 CIRC_MOD_MAP['NILS-ITEM']       = CIRC_MOD_MAP['book'];
333 CIRC_MOD_MAP['OUTREACH']        = CIRC_MOD_MAP['book'];
334 CIRC_MOD_MAP['PAMPHLET']        = CIRC_MOD_MAP['book'];
335 CIRC_MOD_MAP['PAPERBACK']       = CIRC_MOD_MAP['book'];
336 CIRC_MOD_MAP['REALIA']          = CIRC_MOD_MAP['book'];
337 CIRC_MOD_MAP['RESERVE']         = CIRC_MOD_MAP['book'];
338 CIRC_MOD_MAP['STATE-BOOK'] = {
339         SIPMediaType                    : '001',
340         magneticMedia                   : 'f',
341         durationRule                    : '35_days_1_renew',
342         recurringFinesRule      : "10_cent_per_day",
343         maxFine                                 : "overdue_mid"
344 };
345 CIRC_MOD_MAP['STATE-MFRM'] =  {
346         SIPMediaType                    : '001',
347         magneticMedia                   : 'f',
348         durationRule                    : '14_days_2_renew',
349         recurringFinesRule      : "10_cent_per_day",
350         maxFine                                 : "overdue_mid"
351 };
352
353 /* this will set defaults even if no one asked for them */
354 log_debug("Calling getItemConfig() to force defaults..");
355 getItemConfig();
356 log_debug("getItemConfig() set magneticMedia to "+result.magneticMedia);
357
358
359 function getItemConfig() {
360
361         /* ----------------------------------------------------------------------------------- 
362                 If a circ_modifier is defined on the copy and we have config info for the
363                 provided circ_modifier, use that config.  Otherwise fall back on the MARC item type
364                 ----------------------------------------------------------------------------------- */
365         var marcType    = getMARCItemType();
366         var circMod             = copy.circ_modifier;
367         var itemForm    = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";
368         
369         var config;
370         
371         if( circMod && CIRC_MOD_MAP[circMod.toLowerCase()] ) {
372                 /* if we have a config for the given circ_modifier, use it */
373                 log_debug("a circ_mod config exists for the copy: " + circMod);
374                 config = CIRC_MOD_MAP[circMod];
375         
376         } else {
377                 /* otherwise, fall back on the MARC item type */
378         
379                 if( circMod ) {
380                         log_debug("no circ_mod config found for "
381                                 +circMod+", falling back to MARC");
382                 }
383                 config = MARC_ITEM_TYPE_MAP[marcType];
384         }
385
386         /* if no config could be found, default to 'book' */
387         if(!config) {
388                 log_warn("item_config found no circ_mod OR MARC config, defaulting to 'book'");
389                 config = CIRC_MOD_MAP['book'];
390         }
391
392         /* go ahead and set some default result 
393                 data (which may be overidden) */
394         for( var i in config ) {
395                 log_debug("item_config setting result defaults: "+i+" = " +config[i]);
396                 result[i] = config[i];
397         }
398
399         return config;
400 }
401
402