e04e664c194cd8e12523e168fb3052b48af2ffeb
[working/Evergreen.git] / Open-ILS / src / templates / opac / myopac / main_payment_form.tt2
1 [%  PROCESS "opac/parts/header.tt2";
2     PROCESS "opac/parts/misc_util.tt2";
3     WRAPPER "opac/parts/myopac/main_base.tt2";
4     myopac_page = "main";
5     myopac_main_page = "payment_form";
6
7     last_chance = CGI.param("last_chance");
8     use_stripe = ctx.get_org_setting(ctx.user.home_ou.id, 'opac.processor.stripe.enabled');
9 %]
10 <h3 class="sr-only">[% l('Pay Fines') %]</h3>
11 [% IF ctx.fines.balance_owed <= 0 %]
12 <div>
13     [% l("You either have no fines to pay or you have selected fines whose " _
14         "total is non-positive.  We cannot process non-positive amounts.") %]
15 </div>
16 [% ELSE %]
17 <div id="pay_fines_now">
18     [% IF last_chance %]
19     <p><big>[% l("Are you sure you are ready to charge [_1] to your credit card?", money(ctx.fines.balance_owed)) %]</big></p>
20     <form action="[% ctx.opac_root %]/myopac/main_pay_init" method="post">
21         [% FOR k IN CGI.Vars;
22             NEXT UNLESS k;
23             FOR val IN CGI.param(k) %]
24         <input type="hidden" name="[% k | html %]" value="[% val | html %]" />
25         [% END; END %]
26         <input type="submit" value="[% l('Submit Payment') %]" />
27         <a href="[% mkurl(ctx.opac_root _ '/myopac/main', {}, 1) %]">[% l('Cancel') %]</a>
28     [% ELSE %]
29     <form method="post" id="payment_form"
30     [% IF use_stripe %]
31     onsubmit="return stripe_onsubmit();"
32     [% ENDIF %]
33     >
34         <input type="hidden" name="last_chance" value="1" />
35         [% FOR xact IN CGI.param('xact') %]
36         <input type="hidden" name="xact" value="[% xact | html %]" />
37         [% END %]
38         [% FOR xact IN CGI.param('xact_misc') %]
39         <input type="hidden" name="xact_misc" value="[% xact | html %]" />
40         [% END %]
41         [% IF use_stripe %]
42         <input type="hidden" name="stripe_token" id="stripe_token" />
43         [% ENDIF %]
44
45         <table title="[% l('Billing Information') %]">
46             <tbody>
47                 <tr>
48                     <td colspan='2'><strong>[% l('Billing Information') %]</strong></td>
49                     <td rowspan='13' valign='top'>
50                         <p>[% l('Selected fines you are paying for:') %]</p>
51                         <table title="[% l('List of Transactions') %]"
52                             class="table_no_border_space table_no_cell_pad myopac_payments_table">
53                             <thead>
54                                 <tr>
55                                     <th>[% l('Name') %]</th>
56                                     <th>[% l('Amount') %]</th>
57                                 </tr>
58                             </thead>
59                             <tbody>
60                             [%
61                             FOR f IN ctx.fines.circulation;
62                                 NEXT IF CGI.param('xact').size &&
63                                     !CGI.param('xact').grep(f.xact.id).size;
64                                 attrs = {marc_xml => f.marc_xml};
65                                 IF f.marc_xml;
66                                     PROCESS get_marc_attrs args=attrs;
67                                 ELSIF f.xact.reservation;
68                                     attrs.title = f.xact.reservation.target_resource_type.name;
69                                 END %]
70                                 <tr>
71                                     <td>[% attrs.title | html %]</td>
72                                     <td class="text-right">[% money(f.xact.balance_owed) %]</td>
73                                 </tr>
74                             [%
75                             END;
76                             FOR f IN ctx.fines.grocery;
77                                 NEXT IF CGI.param('xact_misc').size &&
78                                     !CGI.param('xact_misc').grep(f.xact.id).size %]
79                                 <tr>
80                                     <td>[% f.xact.last_billing_type | html %]</td>
81                                     <td class="text-right">[% money(f.xact.balance_owed) %]</td>
82                                 </tr>
83                             [% END %]
84                             </tbody>
85                         </table>
86                         <br />
87                         <div>
88                             [% l('Total amount to pay:') %]
89                             <strong>[% money(ctx.fines.balance_owed) %]</strong>
90                         </div>
91                         <br />
92                         [% | l('<strong>', '</strong>') %]Click [_1]Cancel[_2] to go back and (un)select other fines.[% END %]
93                     </td>
94                 </tr>
95                 <tr>
96                     <td><label for="payment-first-name">[% l('First Name') %]</label></td>
97                     <td><input type="text"  name="billing_first" id="payment-first-name" 
98                         value="[% ctx.user.first_given_name | html %]" /></td>
99                 </tr>
100                 <tr>
101                     <td><label for="payment-last-name">[% l('Last Name') %]</label></td>
102                     <td><input type="text" name="billing_last" id="payment-last-name" 
103                         value="[% ctx.user.family_name | html %]" /></td>
104                 </tr>
105                 <tr>
106                     <td><label for="payment-email-addr">[% l('Email Address') %]</label></td>
107                     <td>
108                         <input id="payment-email-addr" type="text" disabled="disabled" 
109                             readonly="readonly" value="[% ctx.user.email | html %]" />
110                         <a title="[% l('Update Email Address') %]"
111                             href="[% ctx.opac_root %]/myopac/update_email?return_to_referer=1">[% l("Update") %]</a>
112                     </td>
113                 </tr>
114                 <tr>
115                     <td><label for="payment-billing-address">[% l('Street Address') %]</label></td>
116                     <td><input type="text" name="billing_address" id="payment-billing-address" 
117                         value="[% ctx.user.billing_address.street1 _ ctx.user.billing_address.street2 | html %]" /></td>
118                 </tr>
119                 <tr>
120                     <td><label for="payment-billing-city">[% l('City' )%]</label></td>
121                     <td><input type="text" name="billing_city" id="payment-billing-city" 
122                         value="[% ctx.user.billing_address.city | html %]" /></td>
123                 </tr>
124                 <tr>
125                     <td><label for="payment-billing-state">[% l('State or Province') %]</label></td>
126                     <td><input type="text" name="billing_state" id="payment-billing-state"
127                         value="[% ctx.user.billing_address.state | html %]" /></td>
128                 </tr>
129                 <tr>
130                     <td><label for="paymenet-billing-zip">[% l('ZIP or Postal Code') %]</label></td>
131                     <td><input type="text" name="billing_zip" id="paymenet-billing-zip"
132                         value="[% ctx.user.billing_address.post_code | html %]" /></td>
133                 </tr>
134                 <tr>
135                   <td colspan='2'><strong>[% l('Credit Card Information') %]</strong></td>
136                 </tr>
137                 <tr>
138                     <td><label for="payment-credit-card">[% l('Credit Card #') %]</label></td>
139                     <td><input type="number" maxlength="16" id="payment-credit-card"
140                     [% IF use_stripe %]
141                     data-stripe="number"
142                     [% ELSE %]
143                     name="number"
144                     [% ENDIF %]
145                     /></td>
146                 </tr>
147                 <tr>
148                     <td><label for="payment-security-code">[% l('Security Code') %]</label></td>
149                     <td>
150                         <input type="number" size="4" maxlength="5" id="payment-security-code"
151                         [% IF use_stripe %]
152                         data-stripe="cvc"
153                         [% ELSE %]
154                         name="cvv2"
155                         [% ENDIF %]
156                         /></td>
157                 </tr>
158                 <tr>
159                     <td><label for="payment-expire-month">[% l('Expiration Month') %]</label></td>
160                     <td>
161                         <select id="payment-expire-month"
162                         [% IF use_stripe %]
163                         data-stripe="exp_month"
164                         [% ELSE %]
165                         name="expire_month"
166                         [% END IF %]
167                         >
168                             <option value="01">[% l("January") %]</option>
169                             <option value="02">[% l("February") %]</option>
170                             <option value="03">[% l("March") %]</option>
171                             <option value="04">[% l("April") %]</option>
172                             <option value="05">[% l("May") %]</option>
173                             <option value="06">[% l("June") %]</option>
174                             <option value="07">[% l("July") %]</option>
175                             <option value="08">[% l("August") %]</option>
176                             <option value="09">[% l("September") %]</option>
177                             <option value="10">[% l("October") %]</option>
178                             <option value="11">[% l("November") %]</option>
179                             <option value="12">[% l("December") %]</option>
180                         </select>
181                     </td>
182                 </tr>
183                 <tr>
184                     <td><label for="payment-expire-year">[% l('Expiration Year') %]</label></td>
185                     <td>
186                         <select id="payment-expire-year"
187                         [% IF use_stripe %]
188                         data-stripe="exp_year"
189                         [% ELSE %]
190                         name="expire_year"
191                         [% ENDIF %]
192                         >
193                         [% year = date.format(date.now, '%Y');
194                         y = year;
195                         WHILE y < year + 10; # show ten years starting now %]
196                             <option value="[% y %]">[% y %]</option>
197                         [% y = y + 1; END %]
198                         </select>
199                     </td>
200                 </tr>
201                 <tr>
202                     <td colspan='2' align="center">
203                         <input type="submit" id="payment_submit" value="[% l('Next') %]" />
204                         <a href="[% mkurl(ctx.opac_root _ '/myopac/main', {}, 1) %]">[% l('Cancel') %]</a>
205                     </td>
206                 </tr>
207                 [% INCLUDE "opac/parts/myopac/main_refund_policy.tt2" %]
208             </tbody>
209         </table>
210     [% END %]
211     </form>
212 </div>
213 [% END %]
214 [% END %]