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