]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_item_config.js
a6010025e3da9a39903cf787213010cf1715cd44
[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         'dvd-long'                                                      : {
218                 SIPMediaType                    : '006',
219                 magneticMedia                   : 'f',
220                 durationRule                    : '14_days_2_renew',
221                 recurringFinesRule      : '10_cent_per_day',
222                 maxFine                                 : 'overdue_mid'
223         },
224
225
226         'e-book' : {
227                 SIPMediaType                    : '001',
228                 magneticMedia                   : 'f',
229                 durationRule                    : '3_days_1_renew',
230                 recurringFinesRule      : '50_cent_per_day',
231                 maxFine                                 : 'overdue_mid'
232         },
233
234         'equipment' : { 
235                 SIPMediaType                    : '000',
236                 magneticMedia                   : 'f',
237                 durationRule                    : '3_days_1_renew',
238                 recurringFinesRule      : '50_cent_per_day',
239                 maxFine                                 : 'overdue_mid'
240         },
241
242         'filmstrip'                                     : {
243                 SIPMediaType                    : '000',
244                 magneticMedia                   : 'f',
245                 durationRule                    : '14_days_2_renew',
246                 recurringFinesRule      : '10_cent_per_day',
247                 maxFine                                 : 'overdue_mid'
248         },
249
250         'kit' : {
251                 SIPMediaType                    : '000',
252                 magneticMedia                   : 'f',
253                 durationRule                    : '14_days_2_renew',
254                 recurringFinesRule      : '10_cent_per_day',
255                 maxFine                                 : 'overdue_mid'
256         },
257
258         'magazine'      : {
259                 SIPMediaType                    : '002',
260                 magneticMedia                   : 'f',
261                 durationRule                    : '14_days_2_renew',
262                 recurringFinesRule      : '10_cent_per_day',
263                 maxFine                                 : 'overdue_mid'
264         },
265
266         'map' : {
267                 SIPMediaType                    : '000',
268                 magneticMedia                   : 'f',
269                 durationRule                    : '3_days_1_renew',
270                 recurringFinesRule      : '50_cent_per_day',
271                 maxFine                                 : 'overdue_mid'
272         },
273
274         'microform' : {
275                 SIPMediaType                    : '000',
276                 magneticMedia                   : 'f',
277                 durationRule                    : '14_days_2_renew',
278                 recurringFinesRule      : '10_cent_per_day',
279                 maxFine                                 : 'overdue_mid'
280         },
281
282         'music' : {
283                 SIPMediaType                    : '004',
284                 magneticMedia                   : 'f',
285                 durationRule                    : '14_days_2_renew',
286                 recurringFinesRule      : '10_cent_per_day',
287                 maxFine                                 : 'overdue_mid'
288         },
289
290         'record'                                                : {
291                 SIPMediaType                    : '000',
292                 magneticMedia                   : 'f',
293                 durationRule                    : '14_days_2_renew',
294                 recurringFinesRule      : '10_cent_per_day',
295                 maxFine                                 : 'overdue_mid'
296         },
297
298         'software' : {
299                 SIPMediaType                    : '006',
300                 magneticMedia                   : 'f',
301                 durationRule                    : '7_days_2_renew',
302                 recurringFinesRule      : '10_cent_per_day',
303                 maxFine                                 : 'overdue_mid'
304         },
305
306         'talking book'                          : {  
307                 SIPMediaType                    : '006',
308                 magneticMedia                   : 'f',
309                 durationRule                    : 'unlimited',
310         },
311
312         'toy'                                                   : {
313                 SIPMediaType                    : '000',
314                 magneticMedia                   : 'f',
315                 durationRule                    : '7_days_2_renew',
316                 recurringFinesRule      : '50_cent_per_day',
317                 maxFine                                 : 'overdue_mid'
318         },
319
320         'video' : {
321                 SIPMediaType                    : '005',
322                 magneticMedia                   : 'f',
323                 durationRule                    : '7_days_0_renew',
324                 recurringFinesRule      : '50_cent_per_day',
325                 maxFine                                 : 'overdue_mid'
326         },
327
328         'video-long'    : {
329                 SIPMediaType                    : '005',
330                 magneticMedia                   : 'f',
331                 durationRule                    : '14_days_2_renew',
332                 recurringFinesRule      : '50_cent_per_day',
333                 maxFine                                 : 'overdue_mid'
334         },
335 }
336
337
338 /* Set up rules for legacy types */
339 CIRC_MOD_MAP['DEPOSIT']         = CIRC_MOD_MAP['book'];
340 CIRC_MOD_MAP['E-AUDIO']         = CIRC_MOD_MAP['book'];
341 CIRC_MOD_MAP['EQUIP']           = CIRC_MOD_MAP['book'];
342 CIRC_MOD_MAP['FACBESTSLR'] = CIRC_MOD_MAP['book'];
343 CIRC_MOD_MAP['FACNEWBK']        = CIRC_MOD_MAP['book'];
344 CIRC_MOD_MAP['MAG-CIRC']        = CIRC_MOD_MAP['book'];
345 CIRC_MOD_MAP['MAG-NOCIRC'] = CIRC_MOD_MAP['book'];
346 CIRC_MOD_MAP['NEW-AV']          = CIRC_MOD_MAP['book'];
347 CIRC_MOD_MAP['NEW-BOOK']        = CIRC_MOD_MAP['book'];
348 CIRC_MOD_MAP['NEWSPAPER']       = CIRC_MOD_MAP['book'];
349 CIRC_MOD_MAP['NILS-ITEM']       = CIRC_MOD_MAP['book'];
350 CIRC_MOD_MAP['OUTREACH']        = CIRC_MOD_MAP['book'];
351 CIRC_MOD_MAP['PAMPHLET']        = CIRC_MOD_MAP['book'];
352 CIRC_MOD_MAP['PAPERBACK']       = CIRC_MOD_MAP['book'];
353 CIRC_MOD_MAP['REALIA']          = CIRC_MOD_MAP['book'];
354 CIRC_MOD_MAP['RESERVE']         = CIRC_MOD_MAP['book'];
355 CIRC_MOD_MAP['STATE-BOOK'] = {
356         SIPMediaType                    : '001',
357         magneticMedia                   : 'f',
358         durationRule                    : '35_days_1_renew',
359         recurringFinesRule      : "10_cent_per_day",
360         maxFine                                 : "overdue_mid"
361 };
362 CIRC_MOD_MAP['STATE-MFRM'] =  {
363         SIPMediaType                    : '001',
364         magneticMedia                   : 'f',
365         durationRule                    : '14_days_2_renew',
366         recurringFinesRule      : "10_cent_per_day",
367         maxFine                                 : "overdue_mid"
368 };
369
370 /* this will set defaults even if no one asked for them */
371 log_debug("Calling getItemConfig() to force defaults..");
372 getItemConfig();
373 log_debug("getItemConfig() set magneticMedia to "+result.magneticMedia);
374
375
376 function getItemConfig() {
377
378         /* ----------------------------------------------------------------------------------- 
379                 If a circ_modifier is defined on the copy and we have config info for the
380                 provided circ_modifier, use that config.  Otherwise fall back on the MARC item type
381                 ----------------------------------------------------------------------------------- */
382         var marcType    = getMARCItemType();
383         var circMod             = (copy.circ_modifier) ? copy.circ_modifier.toLowerCase() : '';
384         var itemForm    = (marcXMLDoc) ? extractFixedField(marcXMLDoc,'Form') : "";
385         
386         var config;
387         
388         if( circMod && CIRC_MOD_MAP[circMod] ) {
389                 /* if we have a config for the given circ_modifier, use it */
390                 log_debug("a circ_mod config exists for the copy: " + circMod);
391                 config = CIRC_MOD_MAP[circMod];
392         
393         } else {
394                 /* otherwise, fall back on the MARC item type */
395         
396                 if( circMod ) {
397                         log_debug("no circ_mod config found for "
398                                 +circMod+", falling back to MARC");
399                 }
400                 config = MARC_ITEM_TYPE_MAP[marcType];
401         }
402
403         /* if no config could be found, default to 'book' */
404         if(!config) {
405                 log_warn("item_config found no circ_mod OR MARC config, defaulting to 'book'");
406                 config = CIRC_MOD_MAP['book'];
407         }
408
409         /* go ahead and set some default result 
410                 data (which may be overidden) */
411         for( var i in config ) {
412                 log_debug("item_config setting result defaults: "+i+" = " +config[i]);
413                 result[i] = config[i];
414         }
415
416         return config;
417 }
418
419