LP1849182 Angular catalog result/detail tab titles
[Evergreen.git] / Open-ILS / xul / staff_client / server / patron / bill_cc_info.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="/xul/server/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14     <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
21 <window id="patron_bill" title="&staff.patron.bill_cc_info.title;"
22     orient="vertical" style="overflow: auto" oils_persist="height width sizemode"
23     onload="try{info_init(); font_helper(); refresh_fields(); persist_helper(); }catch(E){alert(E);}"
24     onunload="try {  persist_helper_cleanup(); } catch(E) { alert(E) }"
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         function $(id) { return document.getElementById(id); }
37
38         XULElement.prototype.hide = function() {
39             this.style.display = "none";
40         }
41         XULElement.prototype.reveal = function() {
42             this.style.display = "";
43         }
44
45         var patron = {};
46         var show = {'int': 1, 'ext': 2}; // tied to Application::Circ::Money
47         var fields_of_interest = {
48             "cc_type":          show['ext'],
49             "cc_number":        show['int'],
50             "expire_month":     show['int'],
51             "expire_year":      show['int'],
52             "billing_first":    show['ext'] + show['int'],
53             "billing_last":     show['ext'] + show['int'],
54             "billing_address":  show['int'],
55             "billing_city":     show['int'],
56             "billing_state":    show['int'],
57             "billing_zip":      show['int'],
58             "approval_code":    show['ext'],
59             "note":             show['ext'] + show['int'],
60             "where_process":    show['ext'] + show['int']
61         };
62
63         function is_relevant_here(field) {
64             var flag = $('where_process').value;
65             var field_flag = fields_of_interest[field];
66             return ((field_flag & flag) == flag);
67         }
68
69         function refresh_fields() {
70             for (var field in fields_of_interest) {
71                 if (is_relevant_here(field)) {
72                     $('row_' + field).reveal();
73                 }
74                 else {
75                     $('row_' + field).hide();
76                 }
77             }
78         }
79
80         function populate_address_fields() {
81             $('billing_first').value = patron.first_given_name();
82             $('billing_last').value = patron.family_name();
83             if (patron.billing_address()) {
84                 $('billing_address').value = patron.billing_address().street1();
85                 var street2 = patron.billing_address().street2();
86                 if (street2) {
87                     $('billing_address').value += (' ' + street2);
88                 }
89                 $('billing_city').value = patron.billing_address().city();
90                 $('billing_state').value = patron.billing_address().state();
91                 $('billing_zip').value = patron.billing_address().post_code();
92             }
93         }
94
95         function info_init() {
96             if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
97             JSAN.errorLevel = "die"; // none, warn, or die
98             JSAN.addRepository('/xul/server/');
99             JSAN.use('util.error'); g.error = new util.error();
100             JSAN.use('util.network'); g.network = new util.network();
101             g.error.sdump('D_TRACE','my_init() for patron_display.xul');
102             g.OpenILS = {}; JSAN.use('OpenILS.data'); g.OpenILS.data = new OpenILS.data();
103             g.OpenILS.data.init({'via':'stash'});
104             /* 'true' as a string matches the expectations in bill2.js */
105             g.payment_blob = { 'cc_args' : {}, 'cancelled' : 'true' };
106             g.OpenILS.data.temp = js2JSON( g.payment_blob );
107             g.OpenILS.data.stash('temp');
108
109             try {
110                 patron = g.network.simple_request(
111                     'FM_AU_FLESHED_RETRIEVE_VIA_ID',
112                     [ses(), xul_param('patron_id')]
113                 );
114             } catch (e) {
115                 alert ("Patron retrieval failed");
116                 throw(e);
117             }
118
119             populate_address_fields();
120             document.getElementById('cc_number').focus();
121         }
122
123         function sanity_check() {
124             if ($('where_process').value == show['int']) { // internal process
125                 if ($('cc_number').value.match(/^\s*$/)) {
126                     alert($('patronStrings').getString('staff.patron.bill_cc_info.need_cc_number'));
127                     return false;
128                 }
129             }
130             else {  // external
131                 if ($('approval_code').value.match(/^\s*$/)) {
132                     alert($('patronStrings').getString('staff.patron.bill_cc_info.need_approval_code'));
133                     return false;
134                 }
135             }
136             return true;
137         }
138
139         function info_finish() {
140             /* FIXME -- need unique temp space name */
141
142             /* The following for loop gathers our payment_blob values from
143             the widgets in this window.  This is better than the method of
144             gathering data that was here before (using oncommand attributes
145             to set values in this JS object whenever a field value changed)
146             because (if for no other reason), a select menu, if left at the
147             default value, would never reach the payment_blob, because its
148             oncommand attribute would never fire. */
149             for (var field in fields_of_interest) {
150                 if (is_relevant_here(field)) {
151                     var matches = field.match(/^cc_(.+)$/);
152                     var target_key = matches ? matches[1] : field;
153                     g.payment_blob.cc_args[target_key] = $(field).value;
154                 }
155             }
156             delete( g.payment_blob.cancelled );
157             g.OpenILS.data.temp = js2JSON( g.payment_blob );
158             g.OpenILS.data.stash('temp');
159         }
160
161     ]]>
162     </script>
163
164     <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
165
166     <groupbox>
167         <caption label="&staff.patron.bill_cc_info.info.label;"/>
168         <grid>
169             <columns> <column flex="0" /> <column flex="0" /> </columns>
170             <rows>
171                 <row id="row_where_process">
172                     <label value="&staff.patron.bill_cc_info.where_process.label;"/>
173                     <menulist id="where_process" oncommand="refresh_fields();">
174                         <menupopup>
175                             <menuitem label="&staff.patron.bill_cc_info.process_int.label;" value="1"/>
176                             <menuitem label="&staff.patron.bill_cc_info.process_ext.label;" value="2"/>
177                         </menupopup>
178                     </menulist>
179                 </row>
180                 <row id="row_cc_type">
181                     <label value="&staff.patron.bill_cc_info.type.label;"/>
182                     <menulist id="cc_type">
183                         <menupopup>
184                             <menuitem label="&staff.patron.bill_cc_info.visa.label;" value="VISA"/><!-- capitalization to match CC processors' output -->
185                             <menuitem label="&staff.patron.bill_cc_info.mastercard.label;" value="MasterCard"/><!-- capitalization to match CC processors' output -->
186                             <menuitem label="&staff.patron.bill_cc_info.american_express.label;" value="American Express"/>
187                             <menuitem label="&staff.patron.bill_cc_info.discover.label;" value="Discover"/>
188                             <menuitem label="&staff.patron.bill_cc_info.other.label;" value="Other"/>
189                         </menupopup>
190                     </menulist>
191                 </row>
192                 <row id="row_approval_code">
193                     <label value="&staff.patron.bill_cc_info.approval_code.value;"/>
194                     <textbox id="approval_code" context="clipboard"/>
195                 </row>
196                 <row id="row_cc_number">
197                     <label value="&staff.patron.bill_cc_info.cc_number.value;"/>
198                     <textbox id="cc_number" context="clipboard"/>
199                 </row>
200                 <row id="row_expire_month">
201                     <label value="&staff.patron.bill_cc_info.month_expire.value;"/>
202                     <textbox id="expire_month" context="clipboard"/>
203                 </row>
204                 <row id="row_expire_year">
205                     <label value="&staff.patron.bill_cc_info.year_expire.value;"/>
206                     <textbox id="expire_year" context="clipboard"/>
207                 </row>
208             </rows>
209         </grid>
210     </groupbox>
211     <groupbox>
212         <caption label="Optional fields"/>
213         <grid>
214             <columns><column flex="0" /><column flex="1" /></columns>
215             <rows>
216                 <row id="row_billing_first">
217                     <label value="&staff.patron.bill_cc_info.billing_first.value;"/>
218                     <textbox id="billing_first" context="clipboard"/>
219                 </row>
220                 <row id="row_billing_last">
221                     <label value="&staff.patron.bill_cc_info.billing_last.value;"/>
222                     <textbox id="billing_last" context="clipboard"/>
223                 </row>
224                 <row id="row_billing_address">
225                     <label value="&staff.patron.bill_cc_info.billing_address.value;"/>
226                     <textbox id="billing_address" context="clipboard"/>
227                 </row>
228                 <row id="row_billing_city">
229                     <label value="&staff.patron.bill_cc_info.billing_city.value;"/>
230                     <textbox id="billing_city" context="clipboard"/>
231                 </row>
232                 <row id="row_billing_state">
233                     <label value="&staff.patron.bill_cc_info.billing_state.value;"/>
234                     <textbox id="billing_state" context="clipboard"/>
235                 </row>
236                 <row id="row_billing_zip">
237                     <label value="&staff.patron.bill_cc_info.billing_zip.value;"/>
238                     <textbox cols="12" maxlength="11" id="billing_zip" context="clipboard"/>
239                 </row>
240                 <row id="row_note">
241                     <label value="&staff.patron.bill_cc_info.note.value;"/>
242                     <textbox id="note" multiline="true" context="clipboard"/>
243                 </row>
244             </rows>
245         </grid>
246         <hbox>
247             <spacer flex="1"/>
248             <button label="&staff.patron.bill_cc_info.cancel.label;" oncommand="window.close()" accesskey="&staff.patron.bill_cc_info.cancel.accesskey;"/>
249             <button label="&staff.patron.bill_cc_info.submit.label;" oncommand="if (sanity_check()) { info_finish(); window.close(); }" accesskey="&staff.patron.bill_cc_info.submit.accesskey;"/>
250         </hbox>
251     </groupbox>
252
253 </window>
254