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