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