]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/patron/patron_display.js
first try at checkout receipt
[working/Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / patron / patron_display.js
1 sdump('D_TRACE','Loading patron_display.js\n');
2
3 function patron_display_init(p) {
4         sdump('D_PATRON_DISPLAY',"TESTING: patron_display.js: " + mw.G['main_test_variable'] + '\n');
5         sdump('D_CONSTRUCTOR',arg_dump(arguments));
6
7         // gives: p.clamshell, p.right_panel, p.left_panel
8         patron_display_clamshell_init(p);
9
10         // gives: p.patron_items, p.redraw_patron_items
11         patron_display_patron_items_init(p);
12
13         // gives: p.patron_checkout_items, p.redraw_patron_checkout_items
14         patron_display_patron_checkout_items_init(p);
15
16         // gives: p.patron_holds, p.redraw_patron_holds
17         patron_display_patron_holds_init(p);
18
19         // gives: p.patron_bills, p.redraw_patron_bills
20         patron_display_patron_bills_init(p);
21
22         // gives: p.patron_edit, p.redraw_patron_edit
23         patron_display_patron_edit_init(p);
24
25         p.set_patron = function (au) {
26                 p.patron_edit._patron = au;
27                 return p._patron = au;
28         }
29
30         p.display_patron = function (exceptions) {
31                 if (!exceptions) exceptions = {};
32                 if (!exceptions.all) {
33                         if (!exceptions.patron_checkout_items) p.redraw_patron_checkout_items();
34                         if (!exceptions.patron_items) p.redraw_patron_items();
35                         if (!exceptions.patron_holds) p.redraw_patron_holds();
36                         if (!exceptions.patron_bills) p.redraw_patron_bills();
37                         //if (!exceptions.patron_edit) p.redraw_patron_edit();
38                 }
39                 return render_fm(p.w.document, { 'au' : p._patron });
40         }
41
42         p.retrieve_patron_via_barcode = function (barcode) {
43                 if (!barcode) barcode = patron_get_barcode( p._patron );
44                 p.set_patron( retrieve_patron_by_barcode( barcode ) );
45                 return p.display_patron( {} );
46         }
47
48         p.retrieve_patron_via_id = function (id, exceptions) {
49                 p.set_patron( retrieve_patron_by_id( id ) );
50                 return p.display_patron(exceptions);
51         }
52
53         p.refresh = function(exceptions) {
54                 if (p._patron) p.retrieve_patron_via_id( p._patron.id(), exceptions );
55         }
56
57         set_patron_display_widgets(p);
58
59         if (p.patron) {
60                 if (typeof(p.patron) == 'object') {
61                         //p._patron = p.patron;
62                         p.set_patron( p.patron );
63                         p.display_patron();
64                 } else
65                         p.retrieve_patron_via_barcode( p.patron );
66         }
67
68         sdump('D_TRACE_EXIT',arg_dump(arguments));
69         return p;
70 }
71
72 function set_patron_display_widgets(p) {
73         p.commandset_node.getElementsByAttribute('id','cmd_patron_refresh')[0].addEventListener(
74                 'command',
75                 function (ev) {
76                         p.refresh();
77                 },
78                 false
79         );
80
81         function gen_func(i) {
82                 // because otherwise i would be 5 for each closure
83                 return function(ev) {
84                         p.clamshell.set_second_deck(i);
85                 };
86         }
87         var cmds = [ 'cmd_patron_checkout', 'cmd_patron_items', 'cmd_patron_holds', 
88                 'cmd_patron_bills', 'cmd_patron_edit', 'cmd_patron_info' ]
89         for (var i in cmds) {
90                 p.commandset_node.getElementsByAttribute('id',cmds[i])[0].addEventListener(
91                         'command',
92                         gen_func(i),
93                         false
94                 );
95         }
96         p.commandset_node.getElementsByAttribute('id','cmd_patron_checkout')[0].addEventListener(
97                 'command',
98                 function () {
99                         focus_widget( p.w.document, 'patron_checkout_barcode_entry_textbox' );
100                 },
101                 false
102         );
103         p.commandset_node.getElementsByAttribute('id','cmd_patron_bills')[0].addEventListener(
104                 'command',
105                 function () {
106                         focus_widget( p.w.document, 'bill_payment_amount_textbox' );
107                 },
108                 false
109         );
110         p.commandset_node.getElementsByAttribute('id','cmd_patron_edit')[0].addEventListener(
111                 'command',
112                 function () {
113                         p.redraw_patron_edit();
114                 },
115                 false
116         );
117
118
119
120
121 }
122
123
124 function patron_display_clamshell_init(p) {
125         p.clamshell = clam_shell_init( { 'w' : p.w, 'node' : p.clamshell_node, 'debug' : p.app } );
126         p.left_panel = p.clamshell.first_deck;
127         p.right_panel = p.clamshell.second_deck;
128 }
129
130 function patron_display_patron_items_init(p) {
131         p.patron_items = patron_items_init( { 'w' : p.w, 'node' : p.patron_items_node, 'debug' : p.app } );
132
133         p.w.document.getElementById('item_print').addEventListener(
134                 'command',
135                 function(ev) {
136                         var params = { 
137                                 'au' : p._patron, 
138                                 'lib' : mw.G.user_ou,
139                                 'staff' : mw.G.user,
140                                 'header' : mw.G.itemsout_header,
141                                 'line_item' : mw.G.itemsout_line_item,
142                                 'footer' : mw.G.itemsout_footer
143                         };
144                         mw.print_itemsout_receipt( params );
145                 }, false
146         );
147
148         p.redraw_patron_items = function() {
149                 p.patron_items.clear_patron_items();
150                 if (!p._patron.checkouts()) patron_get_checkouts( p._patron );
151                 for (var i = 0; i < p._patron.checkouts().length; i++) {
152                         p.patron_items.add_patron_items( [ i ] );
153                 }
154         }
155
156         p.patron_items.register_patron_items_select_callback(
157                 function (ev) {
158                         sdump('D_PATRON_DISPLAY','Firing patron_items_select_callback\n');
159                         sdump('D_PATRON_DISPLAY','ev.target = ' + ev.target + '\n');
160                         var patron_items = get_list_from_tree_selection( p.patron_items.paged_tree.tree );
161                         /* grab cover art for selected item? */
162                 }
163         );
164         p.patron_items.register_flesh_patron_items_function(
165                 function (treeitem) {
166                         sdump('D_PATRON_DISPLAY','Firing flesh_patron_items_function\n');
167                         var record_id = treeitem.getAttribute('record_id'); 
168                         p.patron_items.map_patron_items_to_cols( p._patron.checkouts()[ record_id ], treeitem );
169                 }
170         );
171         p.patron_items.register_item_context_builder(
172                 function (ev) {
173                         sdump('D_PATRON_DISPLAY','Firing context_builder for patron_items\n');
174                         sdump('D_PATRON_DISPLAY','ev.target = ' + ev.target + '\np.patron_items.paged_tree.popup = ' + p.patron_items.paged_tree.popup + '\n');
175                         empty_widget(p.patron_items.paged_tree.popup);
176                         var patron_items = get_list_from_tree_selection( p.patron_items.paged_tree.tree );
177                         sdump('D_PATRON_DISPLAY','patron_items.length = ' + patron_items.length + '\n');
178
179                         /*** RENEW ***/
180                         var menuitem_pi_r = p.patron_items.paged_tree.w.document.createElement('menuitem');
181                         p.patron_items.paged_tree.popup.appendChild( menuitem_pi_r );
182                         menuitem_pi_r.setAttribute('label',getString('circ.context_renew'));
183                         menuitem_pi_r.addEventListener(
184                                 'command',
185                                 function (ev) {
186                                         sdump('D_PATRON_DISPLAY','Firing renew context for patron_items\n');
187                                         for (var i = 0; i < patron_items.length; i++) {
188                                                 try {
189                                                         var idx = patron_items[i].getAttribute('record_id'); 
190                                                         var circ = p._patron.checkouts()[ idx ].circ;
191                                                         alert( js2JSON(renew_by_circ_id( circ.id() )) );
192                                                         p.refresh();
193                                                 } catch(E) {
194                                                         alert(E);
195                                                 }
196                                         }
197                                 },
198                                 false
199                         );
200
201                         /*** CHECKIN ***/
202                         var menuitem_pi_c = p.patron_items.paged_tree.w.document.createElement('menuitem');
203                         p.patron_items.paged_tree.popup.appendChild( menuitem_pi_c );
204                         menuitem_pi_c.setAttribute('label',getString('circ.context_checkin'));
205                         menuitem_pi_c.addEventListener(
206                                 'command',
207                                 function (ev) {
208                                         sdump('D_PATRON_DISPLAY','Firing checkin context for patron_items\n');
209                                         for (var i = 0; i < patron_items.length; i++) {
210                                                 try {
211                                                         var idx = patron_items[i].getAttribute('record_id'); 
212                                                         var copy = p._patron.checkouts()[ idx ].copy;
213                                                         checkin_by_copy_barcode( copy.barcode(), null );
214                                                         p.refresh();
215                                                 } catch(E) {
216                                                         alert(E);
217                                                 }
218                                         }
219                                 },
220                                 false
221                         );
222
223                         /* separator */
224                         var menuitem_pi_s = p.patron_items.paged_tree.w.document.createElement('menuseparator');
225                         p.patron_items.paged_tree.popup.appendChild( menuitem_pi_s );
226                         
227
228                         /*** COPY EDITOR ***/
229                         var menuitem_pi_ce = p.patron_items.paged_tree.w.document.createElement('menuitem');
230                         p.patron_items.paged_tree.popup.appendChild( menuitem_pi_ce );
231                         menuitem_pi_ce.setAttribute('label',getString('circ.context_edit'));
232                         menuitem_pi_ce.addEventListener(
233                                 'command',
234                                 function (ev) {
235                                         sdump('D_PATRON_DISPLAY','Firing copy editor context for patron_items\n');
236                                         for (var i = 0; i < patron_items.length; i++) {
237                                                 sdump('D_PATRON_DISPLAY','Firing copy edit context\n');
238                                         }
239                                 },
240                                 false
241                         );
242
243                         /*** OPAC ***/
244                         var menuitem_pi_o = p.patron_items.paged_tree.w.document.createElement('menuitem');
245                         p.patron_items.paged_tree.popup.appendChild( menuitem_pi_o );
246                         menuitem_pi_o.setAttribute('label',getString('circ.context_opac'));
247                         menuitem_pi_o.addEventListener(
248                                 'command',
249                                 function (ev) {
250                                         sdump('D_PATRON_DISPLAY','Firing opac context for patron_items\n');
251                                         for (var i = 0; i < patron_items.length; i++) {
252                                                 sdump('D_PATRON_DISPLAY','Firing opac context\n');
253                                         }
254                                 },
255                                 false
256                         );
257                         
258                 }
259         );
260 }
261
262 function patron_display_patron_checkout_items_init(p) {
263         p.patron_checkout_items = patron_checkout_items_init( { 'w' : p.w, 'node' : p.patron_checkout_items_node, 'debug' : p.app } );
264         var tb = p.patron_checkout_items_node.getElementsByAttribute('id','patron_checkout_barcode_entry_textbox')[0];
265         var submit_button = p.patron_checkout_items_node.getElementsByAttribute('id','patron_checkout_submit_barcode_button')[0];
266
267         var checkouts = [];
268
269         function print_receipt() {
270                 p._current_checkouts = checkouts;
271                 var params = { 
272                         'au' : p._patron, 
273                         'lib' : mw.G.user_ou,
274                         'staff' : mw.G.user,
275                         'header' : mw.G.itemsout_header,
276                         'line_item' : mw.G.itemsout_line_item,
277                         'footer' : mw.G.itemsout_footer
278                 };
279                 mw.print_checkout_receipt( params );
280         }
281
282         p.w.document.getElementById('checkout_print').addEventListener( 'command',print_receipt, false);
283
284         p.w.document.getElementById('checkout_done').addEventListener(
285                 'command',
286                 function () {
287                         print_receipt(); checkouts = []; p.redraw(); tb.focus();
288                 },
289                 false
290         );
291         p.attempt_checkout = function(barcode) {
292                 try {
293                         //if (! is_barcode_valid(barcode) ) throw('Invalid Barcode');
294                         var permit_check = checkout_permit( barcode, p._patron.id(), 0 );
295                         if (permit_check.status == 0) {
296                                 var check = checkout_by_copy_barcode( barcode, p._patron.id() );
297                                 if (check) {
298                                         checkouts.push( check );
299                                         p.patron_checkout_items.add_checkout_items( [ checkouts.length - 1 ] );
300                                         var temp = p._patron.checkouts();
301                                         temp.push( check );
302                                         p._patron.checkouts( temp );
303                                         render_fm(p.w.document, { 'au' : p._patron }); // p.display_patron();
304                                         p.redraw_patron_items();
305                                         tb.value = '';
306                                 }
307                         } else {
308                                 throw(permit_check.text);
309                         }
310                 } catch(E) {
311                         tb.select();
312                         handle_error(E);
313                 }
314                 tb.focus();
315         }
316
317         tb.addEventListener(
318                 'keypress',
319                 function(ev) {
320                         if (ev.keyCode == 13 || ev.keyCode == 77 ) { p.attempt_checkout( tb.value ); }
321                 },
322                 false
323         );
324         submit_button.addEventListener(
325                 'command',
326                 function(ev) {
327                         p.attempt_checkout( tb.value );
328                 },
329                 false
330         );
331
332         p.redraw_patron_checkout_items = function() {
333                 p.patron_checkout_items.clear_checkout_items();
334                 for (var i = 0; i < checkouts.length; i++) {
335                         p.patron_checkout_items.add_checkout_items( [ i ] );
336                 }
337         }
338
339         p.patron_checkout_items.register_patron_checkout_items_select_callback(
340                 function (ev) {
341                         sdump('D_PATRON_DISPLAY','Firing patron_checkout_items_select_callback\n');
342                         sdump('D_PATRON_DISPLAY','ev.target = ' + ev.target + '\n');
343                         var patron_checkout_items = get_list_from_tree_selection( p.patron_checkout_items.paged_tree.tree );
344                         /* grab cover art for selected item? */
345                 }
346         );
347         p.patron_checkout_items.register_flesh_patron_checkout_items_function(
348                 function (treeitem) {
349                         sdump('D_PATRON_DISPLAY','Firing flesh_patron_checkout_items_function\n');
350                         var record_id = treeitem.getAttribute('record_id'); 
351                         p.patron_checkout_items.map_patron_checkout_items_to_cols( checkouts[ record_id ], treeitem );
352                 }
353         );
354         p.patron_checkout_items.register_checkout_context_builder(
355                 function (ev) {
356                         sdump('D_PATRON_DISPLAY','Firing context_builder for patron_checkout_items\n');
357                         sdump('D_PATRON_DISPLAY','ev.target = ' + ev.target + '\np.patron_checkout_items.paged_tree.popup = ' + p.patron_checkout_items.paged_tree.popup + '\n');
358                         empty_widget(p.patron_checkout_items.paged_tree.popup);
359                         var patron_checkout_items = get_list_from_tree_selection( p.patron_checkout_items.paged_tree.tree );
360
361                         /*** CHECKIN ***/
362                         var menuitem_pci_c = p.patron_checkout_items.paged_tree.w.document.createElement('menuitem');
363                         p.patron_checkout_items.paged_tree.popup.appendChild( menuitem_pci_c );
364                         menuitem_pci_c.setAttribute('label',getString('circ.context_checkin'));
365                         menuitem_pci_c.addEventListener(
366                                 'command',
367                                 function (ev) {
368                                         sdump('D_PATRON_DISPLAY','Firing checkin context for patron_checkout_items\n');
369                                         var keep_these = [];
370                                         for (var i = 0; i < patron_checkout_items.length; i++) {
371                                                 try {
372                                                         var idx = patron_checkout_items[i].getAttribute('record_id'); 
373                                                         var copy = checkouts[ idx ].copy;
374                                                         var status = checkin_by_copy_barcode( copy.barcode(), null );
375                                                         if (status == null) { // change this to whatever it takes
376                                                                 keep_these.push( checkouts[ idx ] );    
377                                                         }
378                                                         checkouts = keep_these;
379                                                         alert( js2JSON( status ) );
380                                                         p.refresh();
381                                                 } catch(E) {
382                                                         alert(E);
383                                                 }
384                                         }
385                                 },
386                                 false
387                         );
388
389                         /* separator */
390                         var menuitem_pci_s = p.patron_checkout_items.paged_tree.w.document.createElement('menuseparator');
391                         p.patron_checkout_items.paged_tree.popup.appendChild( menuitem_pci_s );
392                         
393
394                         /*** COPY EDITOR ***/
395                         var menuitem_pci_ce = p.patron_checkout_items.paged_tree.w.document.createElement('menuitem');
396                         p.patron_checkout_items.paged_tree.popup.appendChild( menuitem_pci_ce );
397                         menuitem_pci_ce.setAttribute('label',getString('circ.context_edit'));
398                         menuitem_pci_ce.addEventListener(
399                                 'command',
400                                 function (ev) {
401                                         sdump('D_PATRON_DISPLAY','Firing copy editor context for patron_checkout_items\n');
402                                         for (var i = 0; i < patron_checkout_items.length; i++) {
403                                                 var idx = patron_checkout_items[i].getAttribute('record_id');
404                                                 sdump('D_PATRON_DISPLAY','Firing copy edit context\n');
405                                         }
406                                 },
407                                 false
408                         );
409
410                         /*** OPAC ***/
411                         var menuitem_pci_o = p.patron_checkout_items.paged_tree.w.document.createElement('menuitem');
412                         p.patron_checkout_items.paged_tree.popup.appendChild( menuitem_pci_o );
413                         menuitem_pci_o.setAttribute('label',getString('circ.context_opac'));
414                         menuitem_pci_o.addEventListener(
415                                 'command',
416                                 function (ev) {
417                                         sdump('D_PATRON_DISPLAY','Firing opac context for patron_checkout_items\n');
418                                         for (var i = 0; i < patron_checkout_items.length; i++) {
419                                                 var idx = patron_checkout_items[i].getAttribute('record_id');
420                                                 sdump('D_PATRON_DISPLAY','Firing opac context\n');
421                                         }
422                                 },
423                                 false
424                         );
425                         
426                 }
427         );
428 }
429
430 function patron_display_patron_holds_init(p) {
431         p.patron_holds = patron_holds_init( { 'w' : p.w, 'node' : p.patron_holds_node, 'debug' : p.app } );
432
433         p.redraw_patron_holds = function() {
434                 p.patron_holds.clear_patron_holds();
435                 if (!p._patron.hold_requests()) patron_get_holds( p._patron );
436                 for (var i = 0; i < p._patron.hold_requests().length; i++) {
437                         p.patron_holds.add_patron_holds( [ i ] );
438                 }
439         }
440
441         p.patron_holds.register_patron_holds_select_callback(
442                 function (ev) {
443                         sdump('D_PATRON_DISPLAY','Firing patron_holds_select_callback\n');
444                         sdump('D_PATRON_DISPLAY','ev.target = ' + ev.target + '\n');
445                         var patron_holds = get_list_from_tree_selection( p.patron_holds.paged_tree.tree );
446                         /* grab cover art for selected item? */
447                 }
448         );
449         p.patron_holds.register_flesh_patron_holds_function(
450                 function (treeitem) {
451                         sdump('D_PATRON_DISPLAY','Firing flesh_patron_holds_function\n');
452                         var record_id = treeitem.getAttribute('record_id'); 
453                         var hold = p._patron.hold_requests()[ record_id ];
454                         patron_get_hold_status(
455                                 hold,
456                                 function (request) {
457                                         var result = request.getResultObject();
458                                         hold.status( hold_status_as_text( result ) );
459                                         p.patron_holds.map_patron_holds_to_cols( hold, treeitem );
460                                 }
461                         );
462                 }
463         );
464         p.patron_holds.register_item_context_builder(
465                 function (ev) {
466                         sdump('D_PATRON_DISPLAY','Firing context_builder for patron_holds\n');
467                         sdump('D_PATRON_DISPLAY','ev.target = ' + ev.target + '\np.patron_holds.paged_tree.popup = ' + p.patron_holds.paged_tree.popup + '\n');
468                         empty_widget(p.patron_holds.paged_tree.popup);
469                         var patron_holds = get_list_from_tree_selection( p.patron_holds.paged_tree.tree );
470                         sdump('D_PATRON_DISPLAY','patron_holds.length = ' + patron_holds.length + '\n');
471
472                         /*** CANCEL HOLD ***/
473                         var menuitem_ph_ce = p.patron_holds.paged_tree.w.document.createElement('menuitem');
474                         p.patron_holds.paged_tree.popup.appendChild( menuitem_ph_ce );
475                         menuitem_ph_ce.setAttribute('label',getString('circ.context_cancel_hold'));
476                         menuitem_ph_ce.addEventListener(
477                                 'command',
478                                 function (ev) {
479                                         sdump('D_PATRON_DISPLAY','Firing cancel hold context for patron_holds\n');
480                                         for (var i = 0; i < patron_holds.length; i++) {
481                                                 sdump('D_PATRON_DISPLAY','Firing cancel edit context\n');
482                                                 var record_id = patron_holds[i].getAttribute('record_id');
483                                                 var hold = p._patron.hold_requests()[ record_id ];
484                                                 cancel_hold( hold );
485                                         }
486                                         p.refresh();
487                                 },
488                                 false
489                         );
490
491                         /* separator */
492                         var menuitem_ph_s = p.patron_holds.paged_tree.w.document.createElement('menuseparator');
493                         p.patron_holds.paged_tree.popup.appendChild( menuitem_ph_s );
494                         
495                         /*** COPY EDITOR ***/
496                         var menuitem_ph_ce = p.patron_holds.paged_tree.w.document.createElement('menuitem');
497                         p.patron_holds.paged_tree.popup.appendChild( menuitem_ph_ce );
498                         menuitem_ph_ce.setAttribute('label',getString('circ.context_edit'));
499                         menuitem_ph_ce.addEventListener(
500                                 'command',
501                                 function (ev) {
502                                         sdump('D_PATRON_DISPLAY','Firing copy editor context for patron_holds\n');
503                                         for (var i = 0; i < patron_holds.length; i++) {
504                                                 sdump('D_PATRON_DISPLAY','Firing copy edit context\n');
505                                         }
506                                 },
507                                 false
508                         );
509
510                         /*** OPAC ***/
511                         var menuitem_ph_o = p.patron_holds.paged_tree.w.document.createElement('menuitem');
512                         p.patron_holds.paged_tree.popup.appendChild( menuitem_ph_o );
513                         menuitem_ph_o.setAttribute('label',getString('circ.context_opac'));
514                         menuitem_ph_o.addEventListener(
515                                 'command',
516                                 function (ev) {
517                                         sdump('D_PATRON_DISPLAY','Firing opac context for patron_holds\n');
518                                         for (var i = 0; i < patron_holds.length; i++) {
519                                                 sdump('D_PATRON_DISPLAY','Firing opac context\n');
520                                         }
521                                 },
522                                 false
523                         );
524                         
525                 }
526         );
527 }
528
529 function patron_display_patron_bills_init(p) {
530         p.patron_bills = patron_bills_init( { 
531                 'w' : p.w, 
532                 'node' : p.patron_bills_node, 
533                 'debug' : p.app 
534         } );
535
536         p.patron_bills.refresh = function() { p.refresh(); }
537
538         p.redraw_patron_bills = function() {
539                 try {
540                         p.patron_bills.clear_patron_bills();
541                         if (!p._patron.bills) patron_get_bills( p._patron );
542                         p.patron_bills.add_patron_bills( p._patron.bills );
543                 } catch(E) {
544                         sdump('D_ERROR',js2JSON(E) + '\n');
545                 }
546         }
547 }
548
549 function patron_display_patron_edit_init(p) {
550         /*
551         p.patron_edit = patron_edit_init( { 
552                 'w' : p.w, 
553                 'node' : p.patron_edit_node, 
554                 'debug' : p.app
555         } );
556
557         p.patron_edit.redisplay = function() { p.display_patron( {'patron_edit':true} ); }
558         p.patron_edit.refresh = function() { p.refresh( {'patron_edit':true} ); }
559
560         p.redraw_patron_edit = function() {
561                 try {
562                         p.patron_edit.clear_patron_edit();
563                         p.patron_edit.add_rows( p._patron );
564                 } catch(E) {
565                         sdump('D_ERROR',js2JSON(E) + '\n');
566                 }
567         }
568         */
569         /* shoehorn in the old legacy stuff */
570         p.patron_edit = {};
571         p.redraw_patron_edit = function() { 
572                 empty_widget( p.patron_edit_node );
573                 setTimeout(
574                         function() {
575                                 var frame = p.w.document.createElement('iframe');
576                                 p.patron_edit_node.appendChild( frame );
577                                 frame.setAttribute('flex','1');
578                                 frame.setAttribute('src','chrome://evergreen/content/patron/patron_edit_legacy.xul');
579                                 frame.contentWindow.mw = mw;
580                                 frame.contentWindow.params = {};
581                                 var barcode = patron_get_barcode( p._patron );
582                                 frame.contentWindow.params.barcode = barcode;
583                                 frame.contentWindow.params._patron = p._patron;
584                                 frame.contentWindow.patron_save_callback = function ( params ) {
585                                         p._patron = params.au;
586                                         p.display_patron();
587                                 }
588                                 p.patron_edit.frame = frame;
589                         }, 0
590                 );
591         }
592 }
593