]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
Mostly finish off server/circ i18n work
[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                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
8                 JSAN.use('util.error'); this.error = new util.error();
9         } catch(E) {
10                 dump('print_list: ' + E + '\n');
11         }
12 }
13
14 circ.print_list_template_editor.prototype = {
15
16         'init' : function( params ) {
17
18                 try {
19                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
20
21                         var obj = this;
22
23                         JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
24                         this.test_patron = new au();
25                         this.test_patron.family_name('Doe');
26                         this.test_patron.first_given_name('John');
27                         this.test_card = new ac();
28                         this.test_card.barcode('123456789');
29                         this.test_patron.card( this.test_card );
30
31                         this.test_data = {
32                                 'payment' : {
33                                         'original_balance' : '16.36',
34                                         'payment_type' : 'Cash',
35                                         'payment_received' : '0.00',
36                                         'payment_applied' : '0.00',
37                                         'voided_balance' : '0.50',
38                                         'change_given' : '0.00',
39                                         'credit_given' : '0.00',
40                                         'note' : "We refunded this because...",
41                                         'new_balance' : '16.36',
42                                 },
43                         }
44
45                         this.test_list = {
46                         
47                                 'items' : [
48                                 {"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":""},
49                                 {"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":""},
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":"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":""},
51                                 {"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":""},
52                                 {"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":""}],
53                                 '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"},
54                                 {"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"},
55                                 {"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"},
56                                 {"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"},
57                                 {"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"}],
58                                 'bills' : [{"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","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"},
59                                 {"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","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"},
60                                 {"balance_owed":"-50.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","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"},
61                                 {"balance_owed":"1.00","xact_finish":"2006-06-14","xact_start":"2006-06-14","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"},
62                                 {"balance_owed":"-1.00","xact_finish":"2006-06-17","xact_start":"2006-06-17","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"},
63                                 {"balance_owed":".66","xact_finish":"","xact_start":"2006-06-27","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"},
64                                 {"balance_owed":".70","xact_finish":"","xact_start":"2006-06-27","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"},
65                                 {"balance_owed":"5.00","xact_finish":"","xact_start":"2006-08-16","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"},
66                                 {"balance_owed":"10.00","xact_finish":"","xact_start":"2006-08-16","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"}],
67                                 '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"}],
68                                 'patrons' : [],
69                                 '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":"   "},
70                                 {"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":"   "},
71                                 {"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":"   "},
72                                 {"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":"   "},
73                                 {"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":"   "},
74                                 {"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":"   "},
75                                 {"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":"   "},
76                                 {"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":"   "},
77                                 {"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":"   "},
78                                 {"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":"   "},
79                                 {"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":"   "},
80                                 {"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":"   "},
81                                 {"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":"   "},
82                                 {"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":"   "},
83                                 {"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":"   "},
84                                 {"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":"   "},],
85                                 'offline_checkout' : [],
86                                 'offline_checkin' : [],
87                                 'offline_renew' : [],
88                                 'offline_inhouse_use' : [],
89                         }
90
91                         obj.controller_init();
92                         obj.controller.render(); obj.controller.view.template_name_menu.focus();
93
94                         obj.post_init();
95
96                 } catch(E) {
97                         alert('init: ' + E);
98                         this.error.sdump('D_ERROR','print_list.init: ' + E + '\n');
99                 }
100         },
101
102         'post_init' : function() {
103                 var obj = this;
104                 setTimeout(
105                         function() {
106                                 var tmp = obj.data.print_list_templates[ obj.controller.view.template_name_menu.value ];
107                                 obj.controller.view.template_type_menu.value = tmp.type;
108                                 obj.controller.view.header.value = tmp.header;
109                                 obj.controller.view.line_item.value = tmp.line_item;
110                                 obj.controller.view.footer.value = tmp.footer;
111                                 obj.preview();
112                         }, 0
113                 );
114         },
115
116         'controller_init' : function() {
117                 try {
118                         var obj = this;
119                         JSAN.use('util.controller'); obj.controller = new util.controller();
120                         obj.controller.init(
121                                 {
122                                         control_map : {
123                                                 'sample' : [ ['command'], function() { } ],
124                                                 'header' : [ ['change'], function() { obj.preview(); } ],
125                                                 'line_item' : [ ['change'], function() { obj.preview(); } ],
126                                                 'footer' : [ ['change'], function() { obj.preview(); } ],
127                                                 'preview' : [
128                                                         ['command'],
129                                                         function() {
130                                                                 obj.preview();
131                                                         }
132                                                 ],
133                                                 'save' : [
134                                                         ['command'],
135                                                         function() {
136                                                                 obj.save_template( obj.controller.view.template_name_menu.value );
137                                                         }
138                                                 ],
139                                                 'export' : [
140                                                         ['command'],
141                                                         function() {
142                                                                 obj.export_templates();
143                                                         }
144                                                 ],
145                                                 'import' : [
146                                                         ['command'],
147                                                         function() {
148                                                                 obj.import_templates();
149                                                         }
150                                                 ],
151                                                 'default' : [
152                                                         ['command'],
153                                                         function() {
154                                                                 obj.data.print_list_defaults();
155                                                                 obj.post_init();
156                                                         }
157                                                 ],
158                                                 'macros' : [
159                                                         ['command'],
160                                                         function() {
161                                                                 try {
162                                                                         JSAN.use('util.functional');
163                                                                         var template_type = obj.controller.view.template_type_menu.value;
164                                                                         var macros;
165                                                                         switch(template_type) {
166                                                                                 case 'items':
167                                                                                         JSAN.use('circ.util');
168                                                                                         macros = util.functional.map_list(
169                                                                                                 circ.util.columns( {} ),
170                                                                                                 function(o) {
171                                                                                                         return '%' + o.id + '%';
172                                                                                                 }
173                                                                                         );
174                                                                                 break;
175                                                                                 case 'holds':
176                                                                                         JSAN.use('circ.util');
177                                                                                         macros = util.functional.map_list(
178                                                                                                 circ.util.hold_columns( {} ),
179                                                                                                 function(o) {
180                                                                                                         return '%' + o.id + '%';
181                                                                                                 }
182                                                                                         );
183                                                                                 break;
184                                                                                 case 'bills':
185                                                                                         JSAN.use('patron.util');
186                                                                                         macros = util.functional.map_list(
187                                                                                                 patron.util.mbts_columns( {} ),
188                                                                                                 function(o) {
189                                                                                                         return '%' + o.id + '%';
190                                                                                                 }
191                                                                                         );
192                                                                                 break;
193                                                                                 case 'patrons':
194                                                                                         JSAN.use('patron.util');
195                                                                                         macros = util.functional.map_list(
196                                                                                                 patron.util.columns( {} ),
197                                                                                                 function(o) {
198                                                                                                         return '%' + o.id + '%';
199                                                                                                 }
200                                                                                         );
201                                                                                 break;
202                                                                                 case 'payment' : 
203                                                                                         macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%voided_balance%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%', '%title%' ];
204                                                                                 break;
205                                                                         }
206                                                                         var macro_string = macros.join(', ');
207                                                                         JSAN.use('util.window');
208                                                                         var win = new util.window();
209                                                                         win.open('data:text/html,'
210                                                                                 + window.escape(
211                                                                                         '<html style="width: 600; height: 400;">'
212                                                                                         + '<head><title>' 
213                                                                                         + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.title')
214                                                                                         + '</title></head>'
215                                                                                         + '<body onload="document.getElementById(\'btn\').focus()">'
216                                                                                         + '<h1>' +
217                                                                                         + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.heading')
218                                                                                         + '</h1>'
219                                                                                         + '<p>%SHORTNAME%, %TODAY%, %STAFF_FIRSTNAME%, %STAFF_LASTNAME%, '
220                                                                                         + '%PATRON_FIRSTNAME%, %LIBRARY%</p>'
221                                                                                         + '<h1>'
222                                                                                         + document.getElementById('circStrings').getFormattedString('staff.circ.print_list_template.window.template_type', [template_type])
223                                                                                         + '</h1>'
224                                                                                         + '<p>' 
225                                                                                         + macro_string 
226                                                                                         + '</p>'
227                                                                                         + '<button id="btn" onclick="window.close()">'
228                                                                                         + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.close')
229                                                                                         + '</button>'
230                                                                                         + '</body></html>'
231                                                                                 ), 'title', 'chrome,resizable');
232                                                                 } catch(E) {
233                                                                         alert(E);
234                                                                 }
235                                                         }
236                                                 ],
237                                                 'template_name_menu_placeholder' : [
238                                                         ['render'],
239                                                         function(e) {
240                                                                 return function() {
241                                                                         JSAN.use('util.widgets'); JSAN.use('util.functional');
242                                                                         util.widgets.remove_children(e);
243                                                                         var ml = util.widgets.make_menulist(
244                                                                                 util.functional.map_object_to_list(
245                                                                                         obj.data.print_list_templates,
246                                                                                         function(o,i) { return [i,i]; }
247                                                                                 )
248                                                                         );
249                                                                         ml.setAttribute('id','template_name_menu');
250                                                                         //ml.setAttribute('editable','true');
251                                                                         ml.setAttribute('flex','1');
252                                                                         e.appendChild(ml);
253                                                                         obj.controller.view.template_name_menu = ml;
254                                                                         ml.addEventListener(
255                                                                                 'command',
256                                                                                 function(ev) {
257                                                                                         var tmp = obj.data.print_list_templates[ ev.target.value ];
258                                                                                         obj.controller.view.template_type_menu.value = tmp.type;
259                                                                                         obj.controller.view.header.value = tmp.header;
260                                                                                         obj.controller.view.line_item.value = tmp.line_item;
261                                                                                         obj.controller.view.footer.value = tmp.footer;
262                                                                                         obj.preview();
263                                                                                 },
264                                                                                 false
265                                                                         );
266                                                                 }
267                                                         }
268                                                 ],
269                                                 'template_type_menu_placeholder' : [
270                                                         ['render'],
271                                                         function(e) {
272                                                                 return function() {
273                                                                         JSAN.use('util.widgets'); JSAN.use('util.functional');
274                                                                         util.widgets.remove_children(e);
275                                                                         var ml = util.widgets.make_menulist(
276                                                                                 util.functional.map_list(
277                                                                                         obj.data.print_list_types,
278                                                                                         function(o) { return [o,o]; }
279                                                                                 )
280                                                                         );
281                                                                         ml.setAttribute('id','template_types_menu');
282                                                                         ml.setAttribute('disabled','true');
283                                                                         e.appendChild(ml);
284                                                                         obj.controller.view.template_type_menu = ml;
285                                                                 }
286                                                         }
287                                                 ],
288
289                                         }
290                                 }
291                         );
292                 } catch(E) {
293                         alert('controller_init: ' + E );
294                 }
295         },
296
297         'preview' : function () { 
298                 try {
299                         var list = this.test_list[ this.controller.view.template_type_menu.value ];
300                         if (typeof list == 'undefined') list = [];
301                         var data = this.test_data[ this.controller.view.template_type_menu.value ];
302                         if (typeof data == 'undefined') data = {};
303
304                         var params = { 
305                                 'patron' : this.test_patron, 
306                                 'lib' : this.data.hash.aou[ this.data.list.au[0].ws_ou() ],
307                                 'staff' : this.data.list.au[0],
308                                 'header' : this.controller.view.header.value,
309                                 'line_item' : this.controller.view.line_item.value,
310                                 'footer' : this.controller.view.footer.value,
311                                 'type' : this.controller.view.template_type_menu.value,
312                                 'list' : list,
313                                 'data' : data,
314                                 'sample_frame' : this.controller.view.sample,
315                         };
316                         JSAN.use('util.print'); var print = new util.print();
317                         print.tree_list( params );
318                 } catch(E) {
319                         this.error.sdump('D_ERROR', document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
320                         alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
321                 }
322         },
323
324         'save_template' : function(name) {
325                 var obj = this;
326                 obj.data.print_list_templates[name].header = obj.controller.view.header.value;
327                 obj.data.print_list_templates[name].line_item = obj.controller.view.line_item.value;
328                 obj.data.print_list_templates[name].footer = obj.controller.view.footer.value;
329                 obj.data.print_list_templates[name].type = obj.controller.view.template_type_menu.value;
330                 obj.data.stash( 'print_list_templates' );
331                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
332                 JSAN.use('util.file'); var file = new util.file('print_list_templates');
333                 file.set_object(obj.data.print_list_templates); file.close();
334                 alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.save') + '\n' + js2JSON(obj.data.print_list_templates[name]));
335         },
336
337         'export_templates' : function() {
338                 try {
339                         var obj = this;
340                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
341                         JSAN.use('util.file'); var f = new util.file('');
342             f.export_file( { 'title' : document.getElementById('circStrings').getString('staff.circ.print_list_template.save_as'), 'data' : obj.data.print_list_templates } );
343
344                 } catch(E) {
345                         this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.export.error'),E);
346                 }
347         },
348
349         'import_templates' : function() {
350                 try {
351                         var obj = this;
352                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
353                         JSAN.use('util.file'); var f = new util.file('');
354             var temp = f.import_file( { 'title' : document.getElementById('circStrings').getString('staff.circ.print_list_template.import') } );
355             if (!temp) { return; }
356             var s = '';
357             function set_t(k,v) {
358                 obj.data.print_list_templates[k] = v;
359                 if (s) s+= ', '; s += k;
360             }
361             for (var i in temp) { set_t(i,temp[i]); }
362             obj.data.stash('print_list_templates');
363             alert(document.getElementById('circStrings').getFormattedString('staff.circ.print_list_template.import_results', [s]));
364             if (xulG) { 
365                 xulG.set_tab(xulG.url_prefix(urls.XUL_PRINT_LIST_TEMPLATE_EDITOR), {}, {});
366             } else {
367                 alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.reload'));
368             }
369         
370                 } catch(E) {
371                         this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.import.error'),E);
372                 }
373         },
374
375 }
376
377 dump('exiting print_list_template_editor.js\n');