]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/display.js
search_form.xul can take and make URI query components
[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                                         'PatronNavBar' : [
120                                                 ['render'],
121                                                 function(e) {
122                                                         return function() {}
123                                                 }
124                                         ],
125                                 }
126                         }
127                 );
128
129                 if (obj.barcode) {
130                         var frame = obj.left_deck.set_iframe(
131                                 urls.remote_patron_summary
132                                 +'?session=' + window.escape(obj.session)
133                                 +'&barcode=' + window.escape(obj.barcode), 
134                                 {},
135                                 {
136                                         'on_finished' : function(patron) {
137                                                 obj.patron = patron; obj.controller.render();
138                                         }
139                                 }
140                         );
141                         obj.summary_window = frame.contentWindow;
142                 } else {
143                         obj.controller.view.PatronNavBar.hidden = true;
144                         var frame = obj.left_deck.set_iframe(
145                                 urls.remote_patron_search_form
146                                 +'?session=' + window.escape(obj.session),
147                                 {},
148                                 {
149                                 }
150                         );
151                         obj.search_window = frame.contentWindow;        
152                 }
153         },
154 }
155
156 dump('exiting patron/display.js\n');