]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/bill_wizard.xul
ad-hoc line-item billing.. some display fixes
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / patron / bill_wizard.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron Display -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
10 <?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
11
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
13 <!-- LOCALIZATION -->
14 <!DOCTYPE window PUBLIC "" ""[
15         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
16 ]>
17
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
19 <!-- OVERLAYS -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
21
22 <window id="patron_bill" title="Bill Patron Wizard"
23         orient="vertical" style="overflow: auto"
24         onload="patron_bill_init()" width="700" height="550"
25         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
26
27         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28         <!-- BEHAVIOR -->
29         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
30         <scripts id="openils_util_scripts"/>
31
32         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
33
34         <script>
35         <![CDATA[
36
37                 function $(id) { return document.getElementById(id); }
38
39                 function retrieve_mbts() {
40                         g.network.simple_request('FM_MBTS_RETRIEVE',[g.session,g.mbts_id],
41                                 function(req) {
42                                         try {
43                                                 g.mbts = req.getResultObject();
44                                                 $('mbts_id').value = g.mbts.id();
45                                                 $('mbts_xact_type').value = g.mbts.xact_type();
46                                                 $('mbts_xact_start').value = g.mbts.xact_start().toString().substr(0,19);
47                                                 $('mbts_xact_finish').value = g.mbts.xact_finish() ? g.mbts.xact_finish().toString().substr(0,19) : '';
48                                                 $('mbts_total_owed').value = g.mbts.total_owed() ? util.money.sanitize( g.mbts.total_owed() ) : '';
49                                                 $('mbts_total_paid').value = g.mbts.total_paid() ? util.money.sanitize( g.mbts.total_paid() ) : '';
50                                                 $('mbts_balance_owed').value = g.mbts.balance_owed() ? util.money.sanitize( g.mbts.balance_owed() ) : '';
51                                                 $('xact_type').value = g.mbts.xact_type(); $('xact_type').disabled = true;
52                                         } catch(E) {
53                                                 g.error.sdump('D_ERROR',E);
54                                         }
55                                 }
56                         );
57                 }
58
59                 function retrieve_circ() {
60                         JSAN.use('util.widgets');
61                         g.network.simple_request('FM_CIRC_RETRIEVE_VIA_ID', [ g.session, g.mbts_id ],
62                                 function (req) {
63                                         var r_circ = req.getResultObject();
64                                         if (instanceOf(r_circ,circ)) {
65
66                                                 $('title_label').hidden = false;
67                                                 $('checked_out_label').hidden = false;
68                                                 $('due_label').hidden = false;
69                                                 $('checked_in_label').hidden = false;
70                                                 $('checked_out').value = r_circ.xact_start() ? r_circ.xact_start().toString().substr(0,10) : '';
71                                                 $('checked_in').value = r_circ.checkin_time() ? r_circ.checkin_time().toString().substr(0,10) : '';
72                                                 $('due').value = r_circ.due_date() ? r_circ.due_date().toString().substr(0,10) : '';
73
74                                                 g.network.simple_request(
75                                                         'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY',
76                                                         [ r_circ.target_copy() ],
77                                                         function (rreq) {
78                                                                 var r_mvr = rreq.getResultObject();
79                                                                 if (instanceOf(r_mvr,mvr)) {
80                                                                         util.widgets.remove_children('title');
81                                                                         $('title').appendChild( document.createTextNode( r_mvr.title() ) );
82                                                                 } else {
83                                                                         obj.network.simple_request(
84                                                                                 'FM_ACP_RETRIEVE',
85                                                                                 [ r_circ.target_copy() ],
86                                                                                 function (rrreq) {
87                                                                                         var r_acp = rrreq.getResultObject();
88                                                                                         if (instanceOf(r_acp,acp)) {
89                                                                                                 util.widgets.remove_children('title');
90                                                                                                 $('title').appendChild( document.createTextNode( r_acp.dummy_title() ) );
91                                                                                         }
92                                                                                 }
93                                                                         );
94                                                                 }
95                                                         }
96                                                 );
97
98                                         }
99                                 }
100                         );
101                 }
102
103
104                 function patron_bill_init() {
105                         try {
106                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
107                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
108                                 JSAN.errorLevel = "die"; // none, warn, or die
109                                 JSAN.addRepository('/xul/server/');
110                                 JSAN.use('util.error'); g.error = new util.error();
111                                 g.error.sdump('D_TRACE','my_init() for patron_display.xul');
112                                 g.OpenILS = {}; JSAN.use('OpenILS.data'); g.OpenILS.data = new OpenILS.data();
113                                 g.OpenILS.data.init({'via':'stash'});
114                                 JSAN.use('util.network'); g.network = new util.network();
115                                 JSAN.use('util.date');
116                                 JSAN.use('util.money');
117
118                                 g.cgi = new CGI();
119                                 g.session = g.cgi.param('session');
120                                 g.patron_id = g.cgi.param('patron_id');
121
122                                 JSAN.use('patron.util'); 
123                                 g.au_obj = patron.util.retrieve_fleshed_au_via_id( g.session, g.patron_id );
124                                 
125                                 $('patron_name').setAttribute('value', g.au_obj.family_name() + ', ' + g.au_obj.first_given_name() + ' : ' + g.au_obj.card().barcode() );
126                                 $('billing_location').setAttribute('value', g.OpenILS.data.hash.aou[ g.OpenILS.data.list.au[0].ws_ou() ].name() );
127
128                                 $('bill_amount').focus();
129
130                                 if (g.cgi.param('xact_id')) { 
131                                         g.mbts_id = g.cgi.param('xact_id');
132                                         $('summary').hidden = false; 
133                                         retrieve_mbts();
134                                         retrieve_circ();
135                                 }
136
137                         } catch(E) {
138                                 var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
139                                         "system administrator or software developer the following:\n" 
140                                         + 'patron/bill_wizard.xul\n' + E + '\n';
141                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
142                                 alert(err_msg);
143                         }
144
145                 }
146
147                 function patron_bill_finish() {
148                         try {
149                                 var xact_id = g.cgi.param('xact_id');
150                                 if (!xact_id) {
151                                                 var grocery = new mg();
152                                                         grocery.isnew('1');
153                                                         grocery.billing_location( g.OpenILS.data.list.au[0].ws_ou() );
154                                                         grocery.usr( g.au_obj.id() );
155                                                         grocery.note( $('bill_note').value );
156                                                 xact_id = g.network.request(
157                                                         api.FM_MG_CREATE.app,
158                                                         api.FM_MG_CREATE.method,
159                                                         [ g.session, grocery ]
160                                                 );
161                                 }
162                                 if (xact_id) {
163                                         var billing = new mb();
164                                                 billing.isnew('1');
165                                                 billing.note( $('bill_note').value );
166                                                 billing.xact( xact_id );
167                                                 billing.amount( $('bill_amount').value );
168                                                 billing.billing_type( $('billing_type').value );
169                                         var mb_id = g.network.request(
170                                                 api.FM_MB_CREATE.app,
171                                                 api.FM_MB_CREATE.method,
172                                                 [ g.session, billing ]
173                                         );
174                                         if (mb_id) {
175                                         } else {
176                                                 throw('mb_id = ' + mb_id);
177                                         }
178                                 } else {
179                                         throw('xact_id = ' + xact_id);
180                                 }
181                         } catch(E) {
182                                 g.error.sdump('D_ERROR',js2JSON(E));
183                                 alert(js2JSON(E));
184                         }
185                 }
186
187         ]]>
188         </script>
189
190         <vbox flex="1">
191                         <groupbox orient="vertical" flex="1" hidden="true" id="summary">
192                                 <caption label="Summary" />
193                                 <grid flex="1">
194                                         <columns>
195                                                 <column flex="1"/>
196                                                 <column flex="1"/>
197                                                 <column flex="1"/>
198                                                 <column flex="1"/>
199                                                 <column flex="1"/>
200                                                 <column flex="2"/>
201                                         </columns>
202                                         <rows>
203                                                 <row>
204                                                         <label class="header" value="Bill #"/>
205                                                         <label id="mbts_id" />
206                                                         <label class="header" value="Total Billed"/>
207                                                         <label id="mbts_total_owed" />
208                                                         <label class="header" id="title_label" value="Title" hidden="true"/>
209                                                         <description id="title"/>
210                                                 </row>
211                                                 <row>
212                                                         <label class="header" value="Type"/>
213                                                         <label id="mbts_xact_type"/>
214                                                         <label class="header" value="Total Paid"/>
215                                                         <label id="mbts_total_paid" />
216                                                         <label class="header" id="checked_out_label" value="Checked Out" hidden="true"/>
217                                                         <label id="checked_out"/>
218                                                 </row>
219                                                 <row>
220                                                         <label class="header" value="Start"/>
221                                                         <label id="mbts_xact_start"/>
222                                                         <label class="header" value="Balance Owed"/>
223                                                         <label id="mbts_balance_owed" />
224                                                         <label class="header" id="due_label" value="Due Date" hidden="true"/>
225                                                         <label id="due"/>
226                                                 </row>
227                                                 <row>
228                                                         <label class="header" value="Finish"/>
229                                                         <label id="mbts_xact_finish"/>
230                                                         <label/>
231                                                         <label/>
232                                                         <label class="header" id="checked_in_label" value="Checked In" hidden="true"/>
233                                                         <label id="checked_in"/>
234                                                 </row>
235                                         </rows>
236                                 </grid>
237                         </groupbox>
238
239                         <groupbox flex="1">
240                                 <caption label="Bill Patron"/>
241                                 <label id="patron_name" class="patronNameLarge"/>
242                                 <grid>
243                                         <columns> <column flex="0" /> <column flex="0" /> </columns>
244                                         <rows id="page1_rows">
245                                                 <row><label value="Location"/><textbox id="billing_location" disabled="true" /></row>
246                                                 <row><label value="Transaction Type"/>
247                                                         <menulist id="xact_type">
248                                                                 <menupopup>
249                                                                         <menuitem label="Grocery" value="grocery" selected="true"/>
250                                                                         <menuitem label="Circulation" value="circulation" disabled="true"/>
251                                                                 </menupopup>
252                                                         </menulist>
253                                                 </row>
254                                                 <row><label value="Billing Type"/>
255                                                         <menulist id="billing_type">
256                                                                 <menupopup>
257                                                                         <menuitem value="Miscellaneous" label="Miscellaneous" />
258                                                                         <menuitem value="Overdue materials" label="Overdue materials" />
259                                                                         <menuitem value="Fee for placing a hold" label="Fee for placing a hold" />
260                                                                         <menuitem value="Fee for checking out a book" label="Fee for checking out a book" />
261                                                                         <menuitem value="Fee for library card" label="Fee for library card" />
262                                                                         <menuitem value="Miscellaneous charges" label="Miscellaneous charges" />
263                                                                         <menuitem value="Lost materials" label="Lost materials" />
264                                                                         <menuitem value="Damaged material" label="Damaged material" />
265                                                                         <menuitem value="Overdue Reserves charge" label="Overdue Reserves charge" />
266                                                                         <menuitem value="Recall overdue" label="Recall overdue" />
267                                                                         <menuitem value="Fee for processing lost library materials" label="Fee for processing lost library materials" />
268                                                                         <menuitem value="Fee for sending patron bills to collection agency" label="Fee for sending patron bills to collection agency" />
269                                                                         <menuitem value="Fee for interlibrary loan" label="Fee for interlibrary loan" />
270                                                                         <menuitem value="Fee for copies" label="Fee for copies" />
271                                                                         <menuitem value="Money advanced to pay for telephone use" label="Money advanced to pay for telephone use" />
272                                                                         <menuitem value="Deposit fee" label="Deposit fee" />
273                                                                         <menuitem value="Fee for disk" label="Fee for disk" />
274                                                                         <menuitem value="Fee for faxing" label="Fee for faxing" />
275                                                                         <menuitem value="Fee for laminating" label="Fee for laminating" />
276                                                                         <menuitem value="Fee for room cleaning" label="Fee for room cleaning" />
277                                                                         <menuitem value="Deposit returned; fee refund" label="Deposit returned; fee refund" />
278                                                                         <menuitem value="Sale items" label="Sale items" />
279                                                                         <menuitem value="Fee for lost card" label="Fee for lost card" />
280                                                                         <menuitem value="Long overdue items" label="Long overdue items" />
281                                                                         <menuitem value="Lost/Replacement Cassette" label="Lost/Replacement Cassette" />
282                                                                         <menuitem value="Returned Check" label="Returned Check" />
283                                                                 </menupopup>
284                                                         </menulist>
285                                                 </row>
286                                                 <row><label value="Amount"/><textbox id="bill_amount" /></row>
287                                                 <row><label value="Note"/><textbox id="bill_note" multiline="true" rows="5" /></row>
288                                         </rows>
289                                 </grid>
290                                 <spacer flex="1"/>
291                                 <hbox>
292                                         <spacer flex="1"/>
293                                         <button label="Cancel" oncommand="window.close()" accesskey="C"/>
294                                         <button label="Submit this Bill" oncommand="patron_bill_finish(); window.close();" accesskey="S"/>
295                                 </hbox>
296                         </groupbox>
297         </vbox>
298 </window>
299
300