]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
Improve Firefox/XULRunner Support
[Evergreen.git] / Open-ILS / xul / staff_client / server / circ / print_list_template_editor.js
1 dump('entering print_list_template_editor.js\n');
2 // vim:noet:sw=4:ts=4:
3
4 if (typeof circ == 'undefined') circ = {};
5 circ.print_list_template_editor = function (params) {
6     try {
7         JSAN.use('util.error'); this.error = new util.error();
8     } catch(E) {
9         dump('print_list: ' + E + '\n');
10     }
11 }
12
13 circ.print_list_template_editor.prototype = {
14
15     'init' : function( params ) {
16
17         try {
18             var obj = this;
19
20             JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
21             this.test_patron = new au();
22             this.test_patron.family_name('Doe');
23             this.test_patron.first_given_name('John');
24             this.test_patron.alias('Curly');
25             this.test_card = new ac();
26             this.test_card.barcode('123456789');
27             this.test_patron.card( this.test_card );
28
29             this.test_data = {
30                 'payment' : {
31                     'original_balance' : '16.36',
32                     'payment_type' : 'Cash',
33                     'payment_received' : '0.00',
34                     'payment_applied' : '0.00',
35                     'voided_balance' : '0.50',
36                     'change_given' : '0.00',
37                     'credit_given' : '0.00',
38                     'note' : "We refunded this because...",
39                     'new_balance' : '16.36'
40                 }
41             }
42
43             this.test_list = {
44             
45                 'items' : [
46                 {"uses":"undefined","alert_message":"","author":"Annixter, Jane.","barcode":"3635300990263","call_number":"F","checkin_time":"   ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:15-0400","circ_as_type":"","circ_id":"19907","circ_lib":"URRLS-SC","circ_modifier":"","circulate":"Yes","acp_id":"34","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"13","due_date":"2006-08-23","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":"   ","opac_visible":"Yes","owning_lib":"URRLS-SC","price":"10.00","pubdate":"1961","publisher":"Longmans","ref":"No","renewal_remaining":"0","route_to":"   ","status":"Checked out","tcn":"PIN01000015 ","title":"Peace comes to Castle Oak ","xact_finish":""},
47                 {"uses":"undefined","alert_message":"","author":"Josephson, Matthew","barcode":"33207002163014","call_number":"NONFIC 330.922 JOSEPHSO","checkin_time":"   ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:23-0400","circ_as_type":"","circ_id":"19908","circ_lib":"ARL-ATH","circ_modifier":"","circulate":"Yes","acp_id":"1658","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"250","due_date":"2006-09-06","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":"   ","opac_visible":"Yes","owning_lib":"ARL-ATH","price":"10.95","pubdate":"[c1934]","publisher":"Harcourt, Brace and company","ref":"No","renewal_remaining":"0","route_to":"   ","status":"Checked out","tcn":"PIN01000311 ","title":"The  robber barons :  the great American capitalists, 1861-1901","xact_finish":""},
48                 {"uses":"undefined","alert_message":"","author":"Payne, Emmy","barcode":"33034001434539","call_number":"EJ PAYNE","checkin_time":"   ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:36:54-0400","circ_as_type":"","circ_id":"19904","circ_lib":"SHRL-RM","circ_modifier":"","circulate":"Yes","acp_id":"6165596","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"1220497","due_date":"2006-09-06","edition":"Reinforced ed.","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"075872926X (BWI bdg.)","loan_duration":"Short","location":"Adult","message":"   ","opac_visible":"Yes","owning_lib":"SHRL-RM","price":"0.00","pubdate":"1944","publisher":"Houghton Mifflin","ref":"No","renewal_remaining":"0","route_to":"   ","status":"Checked out","tcn":"PIN01000377 ","title":"Katy no-pocket ","xact_finish":""},
49                 {"uses":"undefined","alert_message":"","author":"Ames, Leslie","barcode":"31039000791757","call_number":"AF AME","checkin_time":"   ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:07-0400","circ_as_type":"","circ_id":"19906","circ_lib":"ORLS-TEL","circ_modifier":"","circulate":"Yes","acp_id":"28","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"8","due_date":"2006-09-06","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":"   ","opac_visible":"Yes","owning_lib":"ORLS-TEL","price":"5.95","pubdate":"","publisher":"Lenox Hill","ref":"No","renewal_remaining":"0","route_to":"   ","status":"Checked out","tcn":"PIN01000009 ","title":"King's Castle ","xact_finish":""},
50                 {"uses":"undefined","alert_message":"","author":"Payne, Emmy","barcode":"33034001434539","call_number":"EJ PAYNE","checkin_time":"   ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:36:54-0400","circ_as_type":"","circ_id":"19903","circ_lib":"SHRL-RM","circ_modifier":"","circulate":"Yes","acp_id":"6165596","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"1220497","due_date":"2006-09-06","edition":"Reinforced ed.","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"075872926X (BWI bdg.)","loan_duration":"Short","location":"Adult","message":"   ","opac_visible":"Yes","owning_lib":"SHRL-RM","price":"0.00","pubdate":"1944","publisher":"Houghton Mifflin","ref":"No","renewal_remaining":"0","route_to":"   ","status":"Checked out","tcn":"PIN01000377 ","title":"Katy no-pocket ","xact_finish":""}],
51                 'holds' : [{"author":"Wells, H. G. ","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:14:53-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:14:53-0400","current_copy":"33207003884402","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"57","holdable_formats":"","isbn":"0192828266 :","notify_time":"","notify_count":"0","patron_name":"23500000023053 Stompro, Josh","phone_notify":"218-233-3757","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-02T16:15:11-0400","pubdate":"1995","publisher":"Oxford University Press","request_time":"2006-05-20","request_timestamp":"2006-05-20","requestor":"1000000","selection_depth":"0","status":"Ready for pickup","tcn":"PIN03002240 ","target":"131469","title":"The  war of the worlds","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1000567"},
52                 {"author":"Kramer, Kathryn.","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:32:58-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:32:58-0400","current_copy":"33207004030757","edition":"1st ed.","email_notify":"No","expire_time":"","fulfillment_time":"","id":"470","holdable_formats":"","isbn":"0375400834","notify_time":"2006-08-24T15:12:30-0400","notify_count":"1","patron_name":"21034000217210 Jenkins, George","phone_notify":"229-985-3464","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-03T12:15:03-0400","pubdate":"1998","publisher":"Knopf","request_time":"2006-07-28","request_timestamp":"2006-07-28","requestor":"3","selection_depth":"0","status":"Ready for pickup","tcn":"PIN03053147 ","target":"313678","title":"Sweet water ","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1001151"},
53                 {"author":"Silva, Daniel","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:39:35-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:39:35-0400","current_copy":"33207004323517","edition":"1st ed.","email_notify":"No","expire_time":"","fulfillment_time":"","id":"448","holdable_formats":"","isbn":"0375500898 (alk. paper)","notify_time":"","notify_count":"0","patron_name":"21099000002755 Broome, Sandra","phone_notify":"706-236-4632","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-02T17:16:39-0400","pubdate":"c1999","publisher":"Random House","request_time":"2006-07-27","request_timestamp":"2006-07-27","requestor":"1000001","selection_depth":"0","status":"Ready for pickup","tcn":"ocm40444117 ","target":"77772","title":"The  marching season :  a novel","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1000846"},
54                 {"author":"Seuss","available_time":"2006-08-13","available_timestamp":"2006-08-13T20:55:02-0400","capture_time":"2006-08-13","capture_timestamp":"2006-08-13T20:55:02-0400","current_copy":"20070805","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"1697","holdable_formats":"","isbn":"039480001X :","notify_time":"","notify_count":"0","patron_name":"4545 Tripper, Jack","phone_notify":"444-333-2222","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-13T20:45:09-0400","pubdate":"1992, c1957","publisher":"Seedlings Braille Books for Children","request_time":"2006-08-13","request_timestamp":"2006-08-13","requestor":"1000000","selection_depth":"0","status":"Ready for pickup","tcn":"ocm47673093 ","target":"1534993","title":"The  cat in the hat","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1002261"},
55                 {"author":"Potter, Sally.","available_time":"2006-08-09","available_timestamp":"2006-08-09T18:06:10-0400","capture_time":"2006-08-09","capture_timestamp":"2006-08-09T18:06:10-0400","current_copy":"31001000843129","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"1004","holdable_formats":"","isbn":"0783262663","notify_time":"2006-08-10T15:24:46-0400","notify_count":"12","patron_name":"2222233333 Erickson, Bill","phone_notify":"999-999-9999","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-09T12:15:27-0400","pubdate":"c2001","publisher":"Universal Studios","request_time":"2006-08-08","request_timestamp":"2006-08-08","requestor":"3","selection_depth":"0","status":"Ready for pickup","tcn":"ocm48683123 ","target":"1572303","title":"The  man who cried","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"3"}],
56                 'bills' : [{"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","mbts_id":"9","last_billing_ts":"2006-05-08 18:53","last_billing_note":"test","last_billing_type":"Miscellaneous charges","last_payment_ts":"2006-05-08 18:53","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"5.00","xact_type":"grocery","usr":"Id = 1000502"},
57                 {"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","mbts_id":"11","last_billing_ts":"2006-05-08 19:11","last_billing_note":"test","last_billing_type":"Miscellaneous","last_payment_ts":"2006-05-08 19:12","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"5.00","xact_type":"grocery","usr":"Id = 1000502"},
58                 {"balance_owed":"-50.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","mbts_id":"18","last_billing_ts":"2006-05-08 20:20","last_billing_note":"","last_billing_type":"Miscellaneous","last_payment_ts":"2006-05-08 21:27","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"50.00","xact_type":"grocery","usr":"Id = 1000502"},
59                 {"balance_owed":"1.00","xact_finish":"2006-06-14","xact_start":"2006-06-14","mbts_id":"451","last_billing_ts":"2006-06-14 16:49","last_billing_note":"SYSTEM GENERATED","last_billing_type":"Lost Materials","last_payment_ts":"2006-06-14 16:49","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"6.00","total_paid":"5.00","xact_type":"circulation","usr":"Id = 1000502"},
60                 {"balance_owed":"-1.00","xact_finish":"2006-06-17","xact_start":"2006-06-17","mbts_id":"3689","last_billing_ts":"2006-06-17 04:01","last_billing_note":"","last_billing_type":"Miscellaneous","last_payment_ts":"2006-06-17 18:51","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"10.00","total_paid":"11.00","xact_type":"grocery","usr":"Id = 1000502"},
61                 {"balance_owed":".66","xact_finish":"","xact_start":"2006-06-27","mbts_id":"5589","last_billing_ts":"2006-08-22 00:00","last_billing_note":"Overdue Fine","last_billing_type":"Overdue materials","last_payment_ts":"2006-09-04 17:31","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"5.60","total_paid":"4.94","xact_type":"circulation","usr":"Id = 1000502"},
62                 {"balance_owed":".70","xact_finish":"","xact_start":"2006-06-27","mbts_id":"5593","last_billing_ts":"2006-08-22 00:00","last_billing_note":"Overdue Fine","last_billing_type":"Overdue materials","last_payment_ts":"2006-08-16 11:01","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"5.50","total_paid":"4.80","xact_type":"circulation","usr":"Id = 1000502"},
63                 {"balance_owed":"5.00","xact_finish":"","xact_start":"2006-08-16","mbts_id":"14834","last_billing_ts":"2006-08-16 12:25","last_billing_note":"","last_billing_type":"Damaged material","last_payment_ts":"","last_payment_note":"","last_payment_type":"","total_owed":"5.00","total_paid":"0.00","xact_type":"grocery","usr":"Id = 1000502"},
64                 {"balance_owed":"10.00","xact_finish":"","xact_start":"2006-08-16","mbts_id":"14858","last_billing_ts":"2006-08-16 12:34","last_billing_note":"","last_billing_type":"Damaged material","last_payment_ts":"","last_payment_note":"","last_payment_type":"","total_owed":"10.00","total_paid":"0.00","xact_type":"grocery","usr":"Id = 1000502"}],
65                 'payment' : [{"bill_id":5559,"payment":"-0.04","last_billing_type":"Overdue materials","last_billing_note":"Overdue Fine","title":"Hali Bote Azikaban de tao fan","barcode":"a16"},{"bill_id":5589,"payment":"0.04","last_billing_type":"Overdue materials","last_billing_note":"Overdue Fine","title":"Hali Bote Azikaban de tao fan","barcode":"a47"}],
66                 'patrons' : [],
67                 'transits' : [{"transit_item_author":"Arvetis, Chris.","transit_item_barcode":"3947801748348","transit_item_callnumber":"JE ARV","transit_item_title":"Why do birds sing?","transit_target_copy":"2385751","transit_dest_lib":"PIED-WIN","transit_id":"25","transit_source":"ARL-ATH","transit_source_send_time":"2006-05-24T16:37:09-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
68                 {"transit_item_author":"Pine, Tillie S.","transit_item_barcode":"3635300990762","transit_item_callnumber":"F","transit_item_title":"Water all around ","transit_target_copy":"1","transit_dest_lib":"URRLS-SC","transit_id":"26","transit_source":"ARL-ATH","transit_source_send_time":"2006-05-27T22:49:40-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
69                 {"transit_item_author":"","transit_item_barcode":"31057000861941","transit_item_callnumber":"CD J 781.5246 CASPE","transit_item_title":"Casper's spookiest songs and sounds  10 spooky songs plus creepy sound effects","transit_target_copy":"7923932","transit_dest_lib":"WGRL-LS","transit_id":"98","transit_source":"ARL-ATH","transit_source_send_time":"2006-06-29T16:34:38-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
70                 {"transit_item_author":"Davidson, MaryJanice.","transit_item_barcode":"31027005649112","transit_item_callnumber":"AC DAV","transit_item_title":"Undead and unreturnable ","transit_target_copy":"7924995","transit_dest_lib":"HCLS-LG","transit_id":"100","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-07T16:02:32-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
71                 {"transit_item_author":"Evanovich, Janet.","transit_item_barcode":"31001001097295","transit_item_callnumber":"813/.54","transit_item_title":"Two for the dough","transit_target_copy":"8000335","transit_dest_lib":"ARL-BOG","transit_id":"102","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-11T12:12:11-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
72                 {"transit_item_author":"Edwards, Anne","transit_item_barcode":"39021423853564","transit_item_callnumber":"780.92 STREISAND","transit_item_title":"Streisand a biography","transit_target_copy":"949781","transit_dest_lib":"ECGR-BKM","transit_id":"110","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-14T10:00:01-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
73                 {"transit_item_author":"Riese, Randall.","transit_item_barcode":"31025900460205","transit_item_callnumber":"921 STREISAND 1993","transit_item_title":"Her name is Barbra an intimate portrait of the real Barbra Streisand","transit_target_copy":"2210566","transit_dest_lib":"HALL-BPL","transit_id":"112","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-14T10:01:39-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
74                 {"transit_item_author":"Rowling, J. K.","transit_item_barcode":"a45","transit_item_callnumber":"JROWLING2","transit_item_title":"Hali Bote Azikaban de tao fan","transit_target_copy":"8000297","transit_dest_lib":"WGRL-LS","transit_id":"118","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-19T13:52:38-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
75                 {"transit_item_author":"Some Author","transit_item_barcode":"321","transit_item_callnumber":"UNCATALOGED","transit_item_title":"Big Book","transit_target_copy":"8000387","transit_dest_lib":"ROCK-NG","transit_id":"119","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-19T13:58:21-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
76                 {"transit_item_author":"Thomas, Joyce Carol.","transit_item_barcode":"31036000522216","transit_item_callnumber":"E THOMAS","transit_item_title":"The  gospel Cinderella","transit_target_copy":"7422951","transit_dest_lib":"NCLS-COVTN","transit_id":"200","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:20:00-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
77                 {"transit_item_author":"Robinson, Barbara","transit_item_barcode":"31036000545159","transit_item_callnumber":"J ROBINSON","transit_item_title":"The  best Halloween ever","transit_target_copy":"7487432","transit_dest_lib":"NCLS-COVTN","transit_id":"206","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:44-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
78                 {"transit_item_author":"Robinson, Barbara","transit_item_barcode":"31036000545142","transit_item_callnumber":"J ROBINSON","transit_item_title":"The  best Halloween ever","transit_target_copy":"7487431","transit_dest_lib":"NCLS-COVTN","transit_id":"207","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:49-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
79                 {"transit_item_author":"Grafton, Sue.","transit_item_barcode":"31036000527900","transit_item_callnumber":"F GRAFTON","transit_item_title":"\"H\" is for homicide","transit_target_copy":"7273824","transit_dest_lib":"NCLS-COVTN","transit_id":"208","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:58-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
80                 {"transit_item_author":"Beaumont, Karen.","transit_item_barcode":"31036000521853","transit_item_callnumber":"E BEAUMONT","transit_item_title":"I like myself!","transit_target_copy":"7387328","transit_dest_lib":"NCLS-COVTN","transit_id":"211","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:26:08-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
81                 {"transit_item_author":"Sandler, Martin W.","transit_item_barcode":"31036000522612","transit_item_callnumber":"J 388.42 SANDLER","transit_item_title":"Straphanging in the USA trolleys and subways in American life","transit_target_copy":"7360328","transit_dest_lib":"NCLS-COVTN","transit_id":"212","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:35:17-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},
82                 {"transit_item_author":"Bohjalian, Christopher A.","transit_item_barcode":"31036000538303","transit_item_callnumber":"F BOHJALIAN","transit_item_title":"Before you know kindness :  a novel","transit_target_copy":"7544549","transit_dest_lib":"NCLS-COVTN","transit_id":"218","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-26T10:23:20-0400","capture_time":"   ","capture_timestamp":"   ","expire_time":"   ","patron_name":"undefined undefined, undefined","request_time":"   ","request_timestamp":"   ","hold_type":"   "},],
83                 'offline_checkout' : [],
84                 'offline_checkin' : [],
85                 'offline_renew' : [],
86                 'offline_inhouse_use' : []
87             }
88
89             obj.controller_init();
90             obj.controller.render(); obj.controller.view.template_name_menu.focus();
91
92             obj.post_init();
93
94         } catch(E) {
95             alert('init: ' + E);
96             this.error.sdump('D_ERROR','print_list.init: ' + E + '\n');
97         }
98     },
99
100     'post_init' : function() {
101         var obj = this;
102         setTimeout(
103             function() {
104                 var tmp = obj.data.print_list_templates[ obj.controller.view.template_name_menu.value ];
105                 if (tmp.inherit) {
106                     tmp = obj.data.print_list_templates[ tmp.inherit ];
107                     // if someone wants to implement recursion later, feel free
108                 }
109                 obj.controller.view.template_type_menu.value = tmp.type;
110                 obj.controller.view.header.value = tmp.header;
111                 obj.controller.view.line_item.value = tmp.line_item;
112                 obj.controller.view.footer.value = tmp.footer;
113                 obj.controller.view.template_context_menu.value = tmp.context;
114                 obj.preview();
115             }, 0
116         );
117     },
118
119     'controller_init' : function() {
120         try {
121             var obj = this;
122             JSAN.use('util.controller'); obj.controller = new util.controller();
123             obj.controller.init(
124                 {
125                     control_map : {
126                         'sample' : [ ['command'], function() { } ],
127                         'header' : [ ['change'], function() { obj.preview(); } ],
128                         'line_item' : [ ['change'], function() { obj.preview(); } ],
129                         'footer' : [ ['change'], function() { obj.preview(); } ],
130                         'preview' : [
131                             ['command'],
132                             function() {
133                                 obj.preview();
134                             }
135                         ],
136                         'save' : [
137                             ['command'],
138                             function() {
139                                 obj.save_template( obj.controller.view.template_name_menu.value );
140                             }
141                         ],
142                         'export' : [
143                             ['command'],
144                             function() {
145                                 obj.export_templates();
146                             }
147                         ],
148                         'import' : [
149                             ['command'],
150                             function() {
151                                 obj.import_templates();
152                             }
153                         ],
154                         'default' : [
155                             ['command'],
156                             function() {
157                                 obj.data.print_list_defaults();
158                                 obj.post_init();
159                             }
160                         ],
161                         'macros' : [
162                             ['command'],
163                             function() {
164                                 try {
165                                     JSAN.use('util.functional');
166                                     var template_type = obj.controller.view.template_type_menu.value;
167                                     var macros = [];
168                                     switch(template_type) {
169                                         case 'items':
170                                             JSAN.use('circ.util');
171                                             macros = util.functional.map_list(
172                                                 circ.util.columns( {} ),
173                                                 function(o) {
174                                                     return '%' + o.id + '%';
175                                                 }
176                                             );
177                                         break;
178                                         case 'holds':
179                                             JSAN.use('circ.util');
180                                             macros = util.functional.map_list(
181                                                 circ.util.hold_columns( {} ),
182                                                 function(o) {
183                                                     return '%' + o.id + '%';
184                                                 }
185                                             );
186                                         break;
187                                         case 'transits':
188                                             JSAN.use('circ.util');
189                                             macros = util.functional.map_list(
190                                                 circ.util.transit_columns( {} ),
191                                                 function(o) {
192                                                     return '%' + o.id + '%';
193                                                 }
194                                             );
195                                         break;
196                                         case 'offline_checkout':
197                                             JSAN.use('circ.util');
198                                             macros = util.functional.map_list(
199                                                 circ.util.offline_checkout_columns( {} ),
200                                                 function(o) {
201                                                     return '%' + o.id + '%';
202                                                 }
203                                             );
204                                         break;
205                                         case 'offline_checkin':
206                                             JSAN.use('circ.util');
207                                             macros = util.functional.map_list(
208                                                 circ.util.offline_checkin_columns( {} ),
209                                                 function(o) {
210                                                     return '%' + o.id + '%';
211                                                 }
212                                             );
213                                         break;
214                                         case 'offline_renew':
215                                             JSAN.use('circ.util');
216                                             macros = util.functional.map_list(
217                                                 circ.util.offline_renew_columns( {} ),
218                                                 function(o) {
219                                                     return '%' + o.id + '%';
220                                                 }
221                                             );
222                                         break;
223                                         case 'offline_inhouse_use':
224                                             JSAN.use('circ.util');
225                                             macros = util.functional.map_list(
226                                                 circ.util.offline_inhouse_use_columns( {} ),
227                                                 function(o) {
228                                                     return '%' + o.id + '%';
229                                                 }
230                                             );
231                                         break;
232                                         case 'bills':
233                                             JSAN.use('patron.util');
234                                             macros = util.functional.map_list(
235                                                 patron.util.mbts_columns( {} ),
236                                                 function(o) {
237                                                     return '%' + o.id + '%';
238                                                 }
239                                             );
240                                         break;
241                                         case 'patrons':
242                                             JSAN.use('patron.util');
243                                             macros = util.functional.map_list(
244                                                 patron.util.columns( {} ),
245                                                 function(o) {
246                                                     return '%' + o.id + '%';
247                                                 }
248                                             );
249                                         break;
250                                         case 'payment' : 
251                                             macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%voided_balance%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%', '%title%' ];
252                                         break;
253                                     }
254                                     var macro_string = macros.join(', ');
255                                     JSAN.use('util.window');
256                                     var win = new util.window();
257                                     win.open('data:text/html,'
258                                         + window.escape(
259                                             '<html style="width: 600; height: 400;">'
260                                             + '<head><title>' 
261                                             + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.title')
262                                             + '</title></head>'
263                                             + '<body onload="document.getElementById(\'btn\').focus()">'
264                                             + '<h1>' 
265                                             + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.heading')
266                                             + '</h1>'
267                                             + '<p>%LIBRARY%, %SHORTNAME%, %LINE_NO%, '
268                                             + '%STAFF_FIRSTNAME%, %STAFF_LASTNAME%, %STAFF_BARCODE%, %STAFF_PROFILE%, '
269                                             + '%PATRON_FIRSTNAME%, %PATRON_ALIAS%, %PATRON_ALIAS_OR_FIRSTNAME%, %PATRON_LASTNAME%, '
270                                             + '%PATRON_BARCODE%, %patron_barcode%, '
271                                             + '%TODAY%, %TODAY_TRIM%, %TODAY_m%, %TODAY_d%, %TODAY_Y%, %TODAY_H%, %TODAY_I%, '
272                                             + '%TODAY_M%, %TODAY_D%, %TODAY_F% '
273                                             + '</p>'
274                                             + '<h1>'
275                                             + document.getElementById('circStrings').getFormattedString('staff.circ.print_list_template.window.template_type', [template_type])
276                                             + '</h1>'
277                                             + '<p>' 
278                                             + macro_string 
279                                             + '</p>'
280                                             + '<button id="btn" onclick="window.close()">'
281                                             + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.close')
282                                             + '</button>'
283                                             + '</body></html>'
284                                         ), 'title', 'chrome,resizable');
285                                 } catch(E) {
286                                     alert(E);
287                                 }
288                             }
289                         ],
290                         'template_name_menu_placeholder' : [
291                             ['render'],
292                             function(e) {
293                                 return function() {
294                                     JSAN.use('util.widgets'); JSAN.use('util.functional');
295                                     util.widgets.remove_children(e);
296                                     var ml = util.widgets.make_menulist(
297                                         util.functional.map_object_to_list(
298                                             obj.data.print_list_templates,
299                                             function(o,i) { return [i,i]; }
300                                         )
301                                     );
302                                     ml.setAttribute('id','template_name_menu');
303                                     //ml.setAttribute('editable','true');
304                                     ml.setAttribute('flex','1');
305                                     e.appendChild(ml);
306                                     obj.controller.view.template_name_menu = ml;
307                                     ml.addEventListener(
308                                         'command',
309                                         function(ev) {
310                                             var tmp = obj.data.print_list_templates[ ev.target.value ];
311                                             if (tmp.inherit) {
312                                                 tmp = obj.data.print_list_templates[ tmp.inherit ];
313                                                 // if someone wants to implement recursion later, feel free
314                                             }
315                                             obj.controller.view.template_type_menu.value = tmp.type;
316                                             obj.controller.view.header.value = tmp.header;
317                                             obj.controller.view.line_item.value = tmp.line_item;
318                                             obj.controller.view.footer.value = tmp.footer;
319                                             obj.controller.view.template_context_menu.value = tmp.context;
320                                             obj.preview();
321                                         },
322                                         false
323                                     );
324                                 }
325                             }
326                         ],
327                         'template_type_menu_placeholder' : [
328                             ['render'],
329                             function(e) {
330                                 return function() {
331                                     JSAN.use('util.widgets'); JSAN.use('util.functional');
332                                     util.widgets.remove_children(e);
333                                     var ml = util.widgets.make_menulist(
334                                         util.functional.map_list(
335                                             obj.data.print_list_types,
336                                             function(o) { return [o,o]; }
337                                         )
338                                     );
339                                     ml.setAttribute('id','template_types_menu');
340                                     ml.setAttribute('disabled','true');
341                                     e.appendChild(ml);
342                                     obj.controller.view.template_type_menu = ml;
343                                 }
344                             }
345                         ],
346                         'template_context_menu_placeholder' : [
347                             ['render'],
348                             function(e) {
349                                 return function() {
350                                     JSAN.use('util.widgets'); JSAN.use('util.functional');
351                                     util.widgets.remove_children(e);
352                                     var ml = util.widgets.make_menulist(
353                                         [['',null]].concat(
354                                             util.functional.map_list(
355                                                 obj.data.print_list_contexts,
356                                                 function(o) { return [o,o]; }
357                                             )
358                                         )
359                                     );
360                                     ml.setAttribute('id','template_context_menu');
361                                     e.appendChild(ml);
362                                     obj.controller.view.template_context_menu = ml;
363                                 }
364                             }
365                         ]
366
367
368                     }
369                 }
370             );
371         } catch(E) {
372             alert('controller_init: ' + E );
373         }
374     },
375
376     'preview' : function () { 
377         try {
378             var list = this.test_list[ this.controller.view.template_type_menu.value ];
379             if (typeof list == 'undefined') list = [];
380             var data = this.test_data[ this.controller.view.template_type_menu.value ];
381             if (typeof data == 'undefined') data = {};
382
383             var params = { 
384                 'patron' : this.test_patron, 
385                 'lib' : this.data.hash.aou[ this.data.list.au[0].ws_ou() ],
386                 'staff' : this.data.list.au[0],
387                 'header' : this.controller.view.header.value,
388                 'line_item' : this.controller.view.line_item.value,
389                 'footer' : this.controller.view.footer.value,
390                 'type' : this.controller.view.template_type_menu.value,
391                 'list' : list,
392                 'data' : data,
393                 'sample_frame' : this.controller.view.sample
394             };
395             JSAN.use('util.print'); var print = new util.print();
396             print.tree_list( params );
397         } catch(E) {
398             this.error.sdump('D_ERROR', document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
399             alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
400         }
401     },
402
403     'save_template' : function(name) {
404         var obj = this;
405         obj.data.print_list_templates[name].inherit = null;
406         obj.data.print_list_templates[name].header = obj.controller.view.header.value;
407         obj.data.print_list_templates[name].line_item = obj.controller.view.line_item.value;
408         obj.data.print_list_templates[name].footer = obj.controller.view.footer.value;
409         obj.data.print_list_templates[name].type = obj.controller.view.template_type_menu.value;
410         obj.data.print_list_templates[name].context = obj.controller.view.template_context_menu.value;
411         obj.data.stash( 'print_list_templates' );
412         JSAN.use('util.file'); var file = new util.file('print_list_templates');
413         file.set_object(obj.data.print_list_templates); file.close();
414         alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.save') + '\n' + js2JSON(obj.data.print_list_templates[name]));
415     },
416
417     'export_templates' : function() {
418         try {
419             var obj = this;
420             JSAN.use('util.file'); var f = new util.file('');
421             f.export_file( { 'title' : document.getElementById('circStrings').getString('staff.circ.print_list_template.save_as'), 'data' : obj.data.print_list_templates } );
422
423         } catch(E) {
424             this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.export.error'),E);
425         }
426     },
427
428     'import_templates' : function() {
429         try {
430             var obj = this;
431             JSAN.use('util.file'); var f = new util.file('');
432             var temp = f.import_file( { 'title' : document.getElementById('circStrings').getString('staff.circ.print_list_template.import') } );
433             if (!temp) { return; }
434             var s = '';
435             function set_t(k,v) {
436                 obj.data.print_list_templates[k] = v;
437                 if (s) s+= ', '; s += k;
438             }
439             for (var i in temp) { set_t(i,temp[i]); }
440             obj.data.stash('print_list_templates');
441             alert(document.getElementById('circStrings').getFormattedString('staff.circ.print_list_template.import_results', [s]));
442             if (xulG) { 
443                 xulG.set_tab(xulG.url_prefix('XUL_PRINT_LIST_TEMPLATE_EDITOR'), {}, {});
444             } else {
445                 alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.reload'));
446             }
447     
448         } catch(E) {
449             this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.import.error'),E);
450         }
451     }
452
453 }
454
455 dump('exiting print_list_template_editor.js\n');