weirdness with overflow, and toward patron search
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / display.js
1 dump('entering patron/display.js\n');
2
3 if (typeof patron == 'undefined') patron = {};
4 patron.display = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('main.window'); this.window = new main.window();
8         JSAN.use('main.network'); this.network = new main.network();
9         this.w = window;
10 }
11
12 patron.display.prototype = {
13
14         'init' : function( params ) {
15
16                 var obj = this;
17
18                 obj.session = params['session'];
19                 obj.barcode = params['barcode'];
20
21                 JSAN.use('OpenILS.data'); this.OpenILS = {}; 
22                 obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
23
24                 JSAN.use('util.deck'); 
25                 obj.right_deck = new util.deck('patron_right_deck');
26                 obj.left_deck = new util.deck('patron_left_deck');
27
28                 JSAN.use('main.controller'); obj.controller = new main.controller();
29                 obj.controller.init(
30                         {
31                                 control_map : {
32                                         'cmd_broken' : [
33                                                 ['command'],
34                                                 function() { alert('Not Yet Implemented'); }
35                                         ],
36                                         'cmd_patron_refresh' : [
37                                                 ['command'],
38                                                 function(ev) {
39                                                         obj.controller.view.patron_name.setAttribute(
40                                                                 'value','Retrieving...'
41                                                         );
42                                                         obj.summary_window.g.summary.retrieve();
43                                                 }
44                                         ],
45                                         'cmd_patron_checkout' : [
46                                                 ['command'],
47                                                 function(ev) {
48                                                         obj.right_deck.set_iframe(
49                                                                 urls.remote_checkout
50                                                                 + '?session=' + window.escape( obj.session )
51                                                                 + '&patron_id=' + window.escape( obj.patron.id() ),
52                                                                 {},
53                                                                 { 
54                                                                         'on_checkout' : function(checkout) {
55                                                                                 var c = obj.summary_window.g.summary.patron.checkouts();
56                                                                                 c.push( checkout );
57                                                                                 obj.summary_window.g.summary.patron.checkouts( c );
58                                                                                 obj.summary_window.g.summary.controller.render('patron_checkouts');
59                                                                         }
60                                                                 }
61                                                         );
62                                                         dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
63                                                 }
64                                         ],
65                                         'cmd_patron_items' : [
66                                                 ['command'],
67                                                 function(ev) {
68                                                         obj.right_deck.set_iframe(urls.remote_patron_items);
69                                                         dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
70                                                 }
71                                         ],
72                                         'cmd_patron_holds' : [
73                                                 ['command'],
74                                                 function(ev) {
75                                                         obj.right_deck.set_iframe(urls.remote_patron_holds);
76                                                         dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
77                                                 }
78                                         ],
79                                         'cmd_patron_bills' : [
80                                                 ['command'],
81                                                 function(ev) {
82                                                         obj.right_deck.set_iframe(urls.remote_patron_bills);
83                                                         dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
84                                                 }
85                                         ],
86                                         'cmd_patron_edit' : [
87                                                 ['command'],
88                                                 function(ev) {
89                                                         obj.right_deck.set_iframe(urls.remote_patron_edit);
90                                                         dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
91                                                 }
92                                         ],
93                                         'cmd_patron_info' : [
94                                                 ['command'],
95                                                 function(ev) {
96                                                         obj.right_deck.set_iframe(urls.remote_patron_info);
97                                                         dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
98                                                 }
99                                         ],
100                                         'patron_name' : [
101                                                 ['render'],
102                                                 function(e) {
103                                                         return function() { 
104                                                                 e.setAttribute('value',
105                                                                         obj.patron.family_name() + ', ' + obj.patron.first_given_name()
106                                                                 );
107                                                                 e.setAttribute('style','background-color: lime');
108                                                                 if (obj.summary_window) {
109                                                                         //FIXME//bills should become a virtual field
110                                                                         if (obj.summary_window.g.summary.patron.bills.length > 0)
111                                                                                 e.setAttribute('style','background-color: yellow');
112                                                                         if (obj.summary_window.g.summary.patron.standing() == 2)
113                                                                                 e.setAttribute('style','background-color: lightred');
114                                                                 }
115
116                                                         };
117                                                 }
118                                         ],
119                                 }
120                         }
121                 );
122
123                 if (obj.barcode) {
124                         var frame = obj.left_deck.set_iframe(
125                                 urls.remote_patron_summary
126                                 +'?session=' + window.escape(obj.session)
127                                 +'&barcode=' + window.escape(obj.barcode), 
128                                 {},
129                                 {
130                                         'on_finished' : function(patron) {
131                                                 obj.patron = patron; obj.controller.render();
132                                         }
133                                 }
134                         );
135                         obj.summary_window = frame.contentWindow;
136                 } else {
137                         var frame = obj.left_deck.set_iframe(
138                                 urls.remote_patron_search_form
139                                 +'?session=' + window.escape(obj.session),
140                                 {},
141                                 {
142                                 }
143                         );
144                         obj.search_window = frame.contentWindow;        
145                 }
146         },
147 }
148
149 dump('exiting patron/display.js\n');