Added some styles to make role descriptions a bit smaller MDL-6923
[moodle.git] / enrol / authorize / enrol.html
blob54f7b2aca2b6f97187ae0f7443c558853157eb54
1 <?php // $Id$
3 /// Prevent double paid
4 prevent_double_paid($course);
6 /// Get payment methods enabled and use the first method as default payment method
7 $paymentmethodsenabled = get_list_of_payment_methods(); // methods enabled
8 $paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA); // user's payment preference
10 if (!in_array($paymentmethod, $paymentmethodsenabled)) {
11 error("Invalid payment method: $paymentmethod");
14 switch ($paymentmethod)
16 case AN_METHOD_CC:
18 print_cc_form($this);
19 break;
22 case AN_METHOD_ECHECK:
24 print_echeck_form($this);
25 break;
29 function print_cc_form($classreference)
31 global $form, $course;
32 global $CFG, $USER;
34 $formvars = array(
35 'ccaddress', 'cccity', 'ccstate', 'cccountry', 'cczip',
36 'ccfirstname', 'cclastname', 'cc', 'ccexpiremm', 'ccexpireyyyy', 'cctype', 'cvv'
38 foreach ($formvars as $var) {
39 if (!isset($form->$var)) {
40 $form->$var = '';
44 $curcost = get_course_cost($course);
45 $userfirstname = empty($form->ccfirstname) ? $USER->firstname : $form->ccfirstname;
46 $userlastname = empty($form->cclastname) ? $USER->lastname : $form->cclastname;
47 $useraddress = empty($form->ccaddress) ? $USER->address : $form->ccaddress;
48 $usercity = empty($form->cccity) ? $USER->city : $form->cccity;
49 $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
51 <!-- BEGIN CC -->
52 <p align="center"><?php if (!empty($classreference->authorizeerrors['header'])) { formerr($classreference->authorizeerrors['header']); } ?></p>
53 <div align="center">
55 <p align="right"><?php print_other_method(AN_METHOD_CC) ?></p>
56 <p><?php print_string("paymentrequired") ?></p>
57 <p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
58 <p><?php print_string("paymentinstant") ?></p>
60 <form name="form" method="post" action="enrol.php" autocomplete="off">
61 <input type="hidden" name="id" value="<?php p($course->id) ?>" />
62 <input type="hidden" name="paymentmethod" value="<?php p(AN_METHOD_CC) ?>" />
63 <table align="center" width="100%" border=0>
64 <tr>
65 <td align="right"><?php print_string("ccno", "enrol_authorize") ?>: </td>
66 <td align="left"><input type="text" name="cc" size="16" value="<?php p($form->cc) ?>" />
67 <?php if (!empty($classreference->authorizeerrors['cc'])) { formerr($classreference->authorizeerrors['cc']); } ?></td>
68 </tr>
69 <tr>
70 <td align="right"><?php print_string("nameoncard", "enrol_authorize") ?>: </td>
71 <td align="left"><input type="text" name="ccfirstname" size="8" value="<?php p($userfirstname) ?>" />
72 <input type="text" name="cclastname" size="8" value="<?php p($userlastname) ?>" />
73 <?php if (!empty($classreference->authorizeerrors['ccfirstlast'])) { formerr($classreference->authorizeerrors['ccfirstlast']); } ?></td>
74 </tr>
75 <tr>
76 <td align="right"><?php print_string("ccexpire", "enrol_authorize") ?>: </td>
77 <td align="left"><?php
78 for ($i=1; $i<=12; $i++) {
79 $months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B");
81 choose_from_menu($months, 'ccexpiremm', $form->ccexpiremm);
82 $nowdate = getdate();
83 $nowyear = $nowdate["year"]-1;
84 for ($i=$nowyear; $i<=$nowyear+11; $i++) {
85 $years[$i] = $i;
87 choose_from_menu($years, 'ccexpireyyyy', $form->ccexpireyyyy);
88 if (!empty($classreference->authorizeerrors['ccexpire'])) { formerr($classreference->authorizeerrors['ccexpire']); }
89 ?></td>
90 </tr>
91 <tr>
92 <td align="right"><?php print_string("cctype", "enrol_authorize") ?>: </td>
93 <td align="left"><?php
94 choose_from_menu(get_list_of_creditcards(), 'cctype', $form->cctype);
95 if (!empty($classreference->authorizeerrors['cctype'])) { formerr($classreference->authorizeerrors['cctype']); }
97 </td>
98 </tr>
99 <tr>
100 <td align="right"><?php print_string("ccvv", "enrol_authorize") ?>: </td>
101 <td align="left"><input type="text" name="cvv" size="4" maxlength="4" value="<?php p($form->cvv) ?>" />
102 <?php helpbutton('cvv', '', 'enrol/authorize'); ?>
103 <?php if (!empty($classreference->authorizeerrors['cvv'])) { formerr($classreference->authorizeerrors['cvv']); } ?></td>
104 </tr>
105 <?php if (!empty($CFG->an_avs)) { /* Address Verification System */ ?>
106 <tr>
107 <td align="right"><?php print_string("address") ?>: </td>
108 <td align="left"><input type="text" name="ccaddress" size="32" value="<?php p($useraddress) ?>" />
109 <?php if (!empty($classreference->authorizeerrors['ccaddress'])) { formerr($classreference->authorizeerrors['ccaddress']); } ?></td>
110 </tr>
111 <tr>
112 <td align="right"><?php print_string("city") ?> / <?php print_string("state") ?>: </td>
113 <td align="left"><input type="text" name="cccity" size="16" value="<?php p($usercity) ?>" /> /
114 <input type="text" name="ccstate" size="2" maxlength="2" value="<?php p($form->ccstate) ?>" />
115 <?php if (!empty($classreference->authorizeerrors['cccity'])) { formerr($classreference->authorizeerrors['cccity']); } ?></td>
116 </tr>
117 <tr>
118 <td align="right"><?php print_string("country") ?>: </td>
119 <td align="left"><?php choose_from_menu(get_list_of_countries(), "cccountry", $usercountry, get_string("selectacountry")."..."); ?>
120 <?php if (!empty($classreference->authorizeerrors['cccountry'])) { formerr($classreference->authorizeerrors['cccountry']); } ?></td>
121 </tr>
122 <?php } else { /* not AVS */ ?>
123 <tr>
124 <td colspan="2">
125 <input type="hidden" name="ccstate" value="" />
126 <input type="hidden" name="ccaddress" value="<?php p($useraddress) ?>" />
127 <input type="hidden" name="cccity" value="<?php p($usercity) ?>" />
128 <input type="hidden" name="cccountry" value="<?php p($usercountry) ?>" />
129 </td>
130 </tr>
131 <?php } ?>
132 <tr>
133 <td align="right"><?php print_string("zipcode", "enrol_authorize") ?>: </td>
134 <td align="left"><input type="text" name="cczip" size="5" value="<?php p($form->cczip) ?>" />
135 <?php if (!empty($classreference->authorizeerrors['cczip'])) { formerr($classreference->authorizeerrors['cczip']); } ?></td>
136 </tr>
137 </table>
138 <input type="submit" value="<?php print_string("sendpaymentbutton", "enrol_authorize") ?>">
139 </form>
140 </div>
141 <!-- END CC -->
142 <?php
145 function print_echeck_form($classreference)
147 global $form, $course;
148 global $CFG, $USER;
150 $formvars = array('abacode', 'accnum', 'acctype', 'bankname', 'firstname', 'lastname');
151 foreach ($formvars as $var) {
152 if (!isset($form->$var)) {
153 $form->$var = '';
157 $curcost = get_course_cost($course);
158 $userfirstname = empty($form->firstname) ? $USER->firstname : $form->firstname;
159 $userlastname = empty($form->lastname) ? $USER->lastname : $form->lastname;
161 <!-- BEGIN ECHECK -->
162 <p align="center"><?php if (!empty($classreference->authorizeerrors['header'])) { formerr($classreference->authorizeerrors['header']); } ?></p>
163 <div align="center">
165 <p align="right"><?php print_other_method(AN_METHOD_ECHECK) ?></p>
166 <p><?php print_string("paymentrequired") ?></p>
167 <p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
168 <p><?php print_string("paymentinstant") ?></p>
170 <form name="form" method="post" action="enrol.php" autocomplete="off">
171 <input type="hidden" name="id" value="<?php p($course->id) ?>" />
172 <input type="hidden" name="paymentmethod" value="<?php p(AN_METHOD_ECHECK) ?>" />
173 <table align="center" width="100%" border=0>
174 <tr>
175 <td align="right"><?php print_string("echeckabacode", "enrol_authorize") ?>: </td>
176 <td align="left"><input type="text" name="abacode" size="9" maxlength="9" value="<?php p($form->abacode) ?>" />
177 <?php helpbutton('aba', '', 'enrol/authorize'); ?>
178 <?php if (!empty($classreference->authorizeerrors['abacode'])) { formerr($classreference->authorizeerrors['abacode']); } ?></td>
179 </tr>
180 <tr>
181 <td align="right"><?php print_string("echeckaccnum", "enrol_authorize") ?>: </td>
182 <td align="left"><input type="text" name="accnum" size="20" maxlength="20" value="<?php p($form->accnum) ?>" />
183 <?php if (!empty($classreference->authorizeerrors['accnum'])) { formerr($classreference->authorizeerrors['accnum']); } ?></td>
184 </tr>
185 <tr>
186 <td align="right"><?php print_string("echeckacctype", "enrol_authorize") ?>: </td>
187 <td align="left"><?php
188 $acctypes = array();
189 $acctypesenabled = get_list_of_bank_account_types();
190 foreach ($acctypesenabled as $key) {
191 $acctypes[$key] = get_string("echeck".strtolower($key), "enrol_authorize");
193 choose_from_menu($acctypes, 'acctype', $form->acctype);
194 if (!empty($classreference->authorizeerrors['acctype'])) { formerr($classreference->authorizeerrors['acctype']); }
196 </td>
197 </tr>
198 <tr>
199 <td align="right"><?php print_string("echeckbankname", "enrol_authorize") ?>: </td>
200 <td align="left"><input type="text" name="bankname" size="20" maxlength="50" value="<?php p($form->bankname) ?>" />
201 <?php if (!empty($classreference->authorizeerrors['bankname'])) { formerr($classreference->authorizeerrors['bankname']); } ?></td>
202 </tr>
203 <tr>
204 <td align="right"><?php print_string("echeckfirslasttname", "enrol_authorize") ?>: </td>
205 <td align="left"><input type="text" name="firstname" size="8" value="<?php p($userfirstname) ?>" />
206 <input type="text" name="lastname" size="8" value="<?php p($userlastname) ?>" />
207 <?php if (!empty($classreference->authorizeerrors['firstlast'])) { formerr($classreference->authorizeerrors['firstlast']); } ?></td>
208 </tr>
209 </table>
210 <input type="submit" value="<?php print_string("sendpaymentbutton", "enrol_authorize") ?>">
211 </form>
212 </div>
213 <!-- END ECHECK -->
214 <?php
217 function print_other_method($currentmethod)
219 global $course;
221 if ($currentmethod == AN_METHOD_CC) {
222 $otheravailable = in_array(AN_METHOD_ECHECK, get_list_of_payment_methods());
223 $url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_ECHECK;
224 $stringtofetch = 'usingecheckmethod';
226 else {
227 $otheravailable = in_array(AN_METHOD_CC, get_list_of_payment_methods());
228 $url = 'enrol.php?id='.$course->id.'&amp;paymentmethod='.AN_METHOD_CC;
229 $stringtofetch = 'usingccmethod';
231 if ($otheravailable) {
232 $a = new stdClass;
233 $a->url = $url;
234 print_string($stringtofetch, "enrol_authorize", $a);