]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/checkout.js
205fed3d72b768f2b2a427abaa9f14ac38f7531c
[Evergreen.git] / Open-ILS / xul / staff_client / server / circ / checkout.js
1 dump('entering circ.checkout.js\n');
2
3 if (typeof patron == 'undefined') patron = {};
4 circ.checkout = function (params) {
5
6         JSAN.use('util.error'); this.error = new util.error();
7         JSAN.use('main.network'); this.network = new main.network();
8 }
9
10 circ.checkout.prototype = {
11
12         'init' : function( params ) {
13
14                 var obj = this;
15
16                 obj.session = params['session'];
17                 obj.patron_id = params['patron_id'];
18
19                 JSAN.use('OpenILS.data'); obj.OpenILS = {}; 
20                 obj.OpenILS.data = new OpenILS.data( { 'session' : params.session } ); obj.OpenILS.data.init(true);
21
22
23                 JSAN.use('main.list'); obj.list = new main.list('checkout_list');
24                 //FIXME//getString used to wrap StringBundles, but we need to do the entity/div thing
25                 function getString(s) { return s; }
26                 obj.list.init(
27                         {
28                                 'columns' : [
29                                         {
30                                                 'id' : 'acp_id', 'label' : getString('acp_label_id'), 'flex' : 1,
31                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.id()'
32                                         },
33                                         {
34                                                 'id' : 'circ_id', 'label' : getString('circ_label_id'), 'flex' : 1,
35                                                 'primary' : false, 'hidden' : true, 'render' : 'my.circ.id()'
36                                         },
37                                         {
38                                                 'id' : 'mvr_doc_id', 'label' : getString('mvr_label_doc_id'), 'flex' : 1,
39                                                 'primary' : false, 'hidden' : true, 'render' : 'my.mvr.doc_id()'
40                                         },
41                                         {
42                                                 'id' : 'barcode', 'label' : getString('acp_label_barcode'), 'flex' : 1,
43                                                 'primary' : false, 'hidden' : false, 'render' : 'my.acp.barcode()'
44                                         },
45                                         {
46                                                 'id' : 'call_number', 'label' : getString('acp_label_call_number'), 'flex' : 1,
47                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.call_number()'
48                                         },
49                                         {
50                                                 'id' : 'copy_number', 'label' : getString('acp_label_copy_number'), 'flex' : 1,
51                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.copy_number()'
52                                         },
53                                         {
54                                                 'id' : 'location', 'label' : getString('acp_label_location'), 'flex' : 1,
55                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.location()'
56                                         },
57                                         {
58                                                 'id' : 'loan_duration', 'label' : getString('acp_label_loan_duration'), 'flex' : 1,
59                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.loan_duration()'
60                                         },
61                                         {
62                                                 'id' : 'circ_lib', 'label' : getString('acp_label_circ_lib'), 'flex' : 1,
63                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_lib()'
64                                         },
65                                         {
66                                                 'id' : 'fine_level', 'label' : getString('acp_label_fine_level'), 'flex' : 1,
67                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.fine_level()'
68                                         },
69                                         {
70                                                 'id' : 'deposit', 'label' : getString('acp_label_deposit'), 'flex' : 1,
71                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.deposit()'
72                                         },
73                                         {
74                                                 'id' : 'deposit_amount', 'label' : getString('acp_label_deposit_amount'), 'flex' : 1,
75                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.deposit_amount()'
76                                         },
77                                         {
78                                                 'id' : 'price', 'label' : getString('acp_label_price'), 'flex' : 1,
79                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.price()'
80                                         },
81                                         {
82                                                 'id' : 'circ_as_type', 'label' : getString('acp_label_circ_as_type'), 'flex' : 1,
83                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_as_type()'
84                                         },
85                                         {
86                                                 'id' : 'circ_modifier', 'label' : getString('acp_label_circ_modifier'), 'flex' : 1,
87                                                 'primary' : false, 'hidden' : true, 'render' : 'my.acp.circ_modifier()'
88                                         },
89                                         {
90                                                 'id' : 'xact_start', 'label' : getString('circ_label_xact_start'), 'flex' : 1,
91                                                 'primary' : false, 'hidden' : true, 'render' : 'my.circ.xact_start()'
92                                         },
93                                         {
94                                                 'id' : 'xact_finish', 'label' : getString('circ_label_xact_finish'), 'flex' : 1,
95                                                 'primary' : false, 'hidden' : true, 'render' : 'my.circ.xact_finish()'
96                                         },
97                                         {
98                                                 'id' : 'due_date', 'label' : getString('circ_label_due_date'), 'flex' : 1,
99                                                 'primary' : false, 'hidden' : false, 'render' : 'my.circ.due_date().substr(0,10)'
100                                         },
101                                         {
102                                                 'id' : 'title', 'label' : getString('mvr_label_title'), 'flex' : 2,
103                                                 'primary' : false, 'hidden' : false, 'render' : 'my.mvr.title()'
104                                         },
105                                         {
106                                                 'id' : 'author', 'label' : getString('mvr_label_author'), 'flex' : 1,
107                                                 'primary' : false, 'hidden' : false, 'render' : 'my.mvr.author()'
108                                         },
109                                         {
110                                                 'id' : 'renewal_remaining', 'label' : getString('circ_label_renewal_remaining'), 'flex' : 0,
111                                                 'primary' : false, 'hidden' : false, 'render' : 'my.circ.renewal_remaining()'
112                                         },
113                                         {
114                                                 'id' : 'status', 'label' : getString('acp_label_status'), 'flex' : 1,
115                                                 'primary' : false, 'hidden' : false, 'render' : 'my.acp.status().name()'
116                                         }
117                                 ],
118                                 'map_row_to_column' : function(row,col) {
119                                         // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
120                                         // col contains one of the objects listed above in columns
121                                         var my = row.my;
122                                         return eval( col.render );
123                                 },
124                         }
125                 );
126                 
127                 JSAN.use('main.controller'); obj.controller = new main.controller();
128                 obj.controller.init(
129                         {
130                                 'control_map' : {
131                                         'checkout_barcode_entry_textbox' : [
132                                                 ['keypress'],
133                                                 function(ev) {
134                                                 }
135                                         ],
136                                         'cmd_broken' : [
137                                                 ['command'],
138                                                 function() { alert('Not Yet Implemented'); }
139                                         ],
140                                         'cmd_checkout_submit_barcode' : [
141                                                 ['command'],
142                                                 function() {
143                                                         try {
144                                                                 var barcode = obj.controller.view.checkout_barcode_entry_textbox.value;
145                                                                 var permit = obj.network.request(
146                                                                         'open-ils.circ',
147                                                                         'open-ils.circ.permit_checkout',
148                                                                         [ obj.session, barcode, obj.patron_id, 0 ]
149                                                                 );
150
151                                                                 if (permit.status == 0) {
152                                                                         var checkout = obj.network.request(
153                                                                                 'open-ils.circ',
154                                                                                 'open-ils.circ.checkout.barcode',
155                                                                                 [ obj.session, barcode, obj.patron_id ]
156                                                                         );
157                                                                         obj.list.append(
158                                                                                 {
159                                                                                         'row' : {
160                                                                                                 'my' : {
161                                                                                                 'circ' : checkout.circ,
162                                                                                                 'mvr' : checkout.record,
163                                                                                                 'acp' : checkout.copy
164                                                                                                 }
165                                                                                         }
166                                                                                 //I could override map_row_to_column here
167                                                                                 }
168                                                                         );
169
170                                                                 } else {
171                                                                         throw(permit.text);
172                                                                 }
173                                                         } catch(E) {
174                                                                 alert('FIXME: need special alert and error handling\n'
175                                                                         + js2JSON(E));
176                                                         }
177                                                 }
178                                         ],
179                                         'cmd_checkout_print' : [
180                                                 ['command'],
181                                                 function() {
182                                                 }
183                                         ],
184                                         'cmd_checkout_reprint' : [
185                                                 ['command'],
186                                                 function() {
187                                                 }
188                                         ],
189                                         'cmd_checkout_done' : [
190                                                 ['command'],
191                                                 function() {
192                                                 }
193                                         ],
194                                 }
195                         }
196                 );
197
198         }
199 }
200
201 dump('exiting circ.checkout.js\n');