]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/backend/circ/circ_lib.js
updated to work with new scriptrunner layout
[Evergreen.git] / Open-ILS / src / javascript / backend / circ / circ_lib.js
1
2 var __scratchKey = 0;
3 var __SCRATCH = {};
4
5 /* useful functions for creating wrappers around system functions */
6 function scratchKey()           { return '_' + __scratchKey++; };
7 function scratchPad(key)        { return '__SCRATCH.'+ key; }
8 function getScratch(key)        { return __SCRATCH[ key ]; }
9 function scratchClear()         { for( var o in __SCRATCH ) __SCRATCH[o] = null; }
10
11
12 /* note: returns false if the value is 'f' or 'F' ... */
13 function isTrue(d) {
14         if(     d && 
15                         d != "0" && 
16                         d != "f" &&
17                         d != "F" )
18                         return true;
19         return false;
20 }
21
22
23
24 /* collect the useful variables */
25 var result                              = environment.result = {};
26 result.event                    = 'SUCCESS';
27 result.events                   = [];
28 result.fatalEvents      = [];
29 result.infoEvents               = [];
30
31 var copy                                        = environment.copy;
32 var volume                              = environment.volume;
33 var title                               = environment.title;
34 var recDescriptor               = environment.titleDescriptor;
35 var patron                              = environment.patron;
36 var isRenewal                   = environment.isRenewal;
37 var patronItemsOut      = environment.patronItemsOut;
38 var patronOverdueCount  = environment.patronOverdueCount;
39 var patronFines         = environment.patronFines;
40 var patronProfile;
41 var copyStatus;
42
43 if( patron.profile ) patronProfile = patron.profile.name.toLowerCase();
44 if( copy.status ) copyStatus = copy.status.name.toLowerCase();
45
46
47
48 /*
49 - at some point we should add a library of objects that map 
50 codes to names (item_form, item_type, etc.)
51 load_lib('item_form_map.js');
52 var form_name = item_form_map[env.record_descriptor.item_form];
53 */
54
55
56
57 /* logs a load of info */
58 function log_vars( prefix ) {
59
60         var str = prefix + ' : ';
61
62         if(patron) {
63                 str += ' Patron=' + patron.id;
64                 str += ', Patron Barcode='      + patron.card.barcode;
65                 str += ', Patron Username='+ patron.usrname;
66                 str += ', Patron Library='      + patron.home_ou.name;
67                 str += ', Patron Fines='        + patronFines;
68                 str += ', Patron OverdueCount=' + patronOverdueCount;
69                 str += ', Patron Items Out=' + patronItemsOut;
70         }
71
72         if(copy)        {
73                 str += ', Copy=' + copy.id;
74                 str += ', Copy Barcode=' + copy.barcode;
75                 str += ', Copy status=' + copyStatus;
76                 str += ', Copy location=' + copy.location.name;
77         }
78
79         if(volume)                      str += ', Volume='      + volume.id;
80         if(title)                       str += ', Record='      + title.id;
81
82         if(recDescriptor)       {
83                 str += ', Record Descriptor=' + recDescriptor.id;
84                 str += ', Item Type='                   + recDescriptor.item_type;
85                 str += ', Item Form='                   + recDescriptor.item_form;
86                 str += ', Item Lang='                   + recDescriptor.item_lang;
87                 str += ', Item Audience='               + recDescriptor.audience;
88         }
89
90         str += ' Is Renewal: '  + ( (isTrue(isRenewal)) ? "yes" : "no" );
91
92         log_debug(str);
93 }
94
95