-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccprocess.php.live
206 lines (188 loc) · 10.5 KB
/
ccprocess.php.live
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
require_once("session.inc");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Credit Card Registration</title>
<?php
require_once("condb.inc");
if ($_POST['useoldaddr']) {
if (isset($postobjs['address'])) foreach ($postobjs['address'] as $addrid => $addr) if (isset($addr->fields['ca'])) if ($addr->fields['ca'] == $_POST['new_ca_id']) {
unset($postobjs['address'][$addr->obj_id]);
$ca =& $postobjs['ca'][$_POST['new_ca_id']];
unset($ca->fields['address'][$addr->obj_id]);
}
$curca =& $postobjs['ca'][$_POST['new_ca_id']];
$addrcopy = clone $postobjs['address'][$_POST['useoldaddr']];
$addrcopy->obj_id = "id" . substr(md5(microtime().posix_getpid()), 10, 6);
$addrcopy->fields['ca'] = $curca->obj_id;
$curca->addresses = array($addrcopy->obj_id => $addrcopy);
$postobjs['address'][$addrcopy->obj_id] = $addrcopy;
}
if ($_POST['del'] === "Delete Checked Memberships") foreach ($_POST as $postname => $postitem) if (substr($postname, 0, 10) == "delobj_ca_") unset($postobjs['ca'][array_pop($tmp = explode('_', $postname))]);
$add = (($_SERVER['REQUEST_METHOD'] != "POST") || ($_POST['add'] === "Add additional membership"));
if (isset($postobjs['ca'])) $add = $add || (count($postobjs['ca']) == 0);
if (isset($postobjs)) foreach ($postobjs as $grpname => $objgroup) foreach ($objgroup as $objid => $object) if (isset($object->fields['ca'])) if (!isset($postobjs['ca'][$object->fields['ca']])) unset($postobjs[$grpname][$objid]);
if (isset($postobjs['badge'])) foreach ($postobjs['badge'] as &$badge) {
$badge->fields['price'] = $_SESSION['db_enums']['badgetypes'][$badge->fields['type']][price];
}
?>
</style>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-90723-3";
urchinTracker();
</script>
</head>
<body>
<h2 style="text-align:center">Technicon Credit Card Registration</h2>
<form method="POST" action="ccprocess.php">
<?php
if (($_POST['finish'] == "Complete Order") && ($_POST['email'] != "")) {
$trans = new transaction;
$trans->fields['paidby'] = $_POST['email'];
$trans->fields['paidto'] = "ProPay";
$trans->fields['amount'] = $_POST['total'];
$trans->fields['paytype'] = "3";
$trans->fields['con'] = $_SESSION['conid'];
$trans->save();
$mailbody = "Please contact {$_POST['email']} and charge them \${$_POST['total']}. The transaction id is: {$trans->obj_id}\n\nRegistration data:\n\n";
if (isset($postobjs['ca'])) foreach ($postobjs['ca'] as &$ca) {
$ca->save();
$GLOBALS['db']->query("INSERT INTO many (fromtable, fromid, totable, toid) VALUES ('transactions', {$trans->obj_id}, 'CAs', {$ca->obj_id})");
$mailbody .= "CA Number {$ca->obj_id}\n";
foreach ($ca->fields as $fieldname => $field) if (strval($field) != "") $mailbody .= "$fieldname: $field\n";
foreach ($ca->addresses as &$address) {
$mailbody .= "Address {$address->obj_id}\n";
foreach($address->fields as $afname => $afield) if (strval($afield) != "") $mailbody .= "$afname: $afield\n";
}
foreach ($ca->stuff['badge'] as &$badge) {
$mailbody .= "Badge {$badge->obj_id}\n";
foreach($badge->fields as $bfname => $bfield) if (strval($bfield) != "") $mailbody .= "$bfname: $bfield\n";
}
$mailbody .= "\n\n";
}
mail('[email protected], [email protected]', 'Technicon Credit Card Registration', wordwrap($mailbody, 70), "From: [email protected]");
echo '<p style="text-align: center">Thank you for registering for Technicon online. If you do not receive an e-mail requesting payment in the next 5 days, please send an e-mail to <a href="mailto:[email protected]">[email protected]</a><br /><br /><a href="http://www.technicon.org/">Technicon Web Site</a></p>';
unset($postobjs);
}
elseif (($_POST['finish'] == "Complete Order") && ($_POST['email'] == "")) {
$_POST['checkout'] = "Check Out";
echo '<p style="text-align: center; color: red">Please enter a billing e-mail address to proceed.</p>';
}
if (isset($postobjs['ca']) && !$add) {
$subtotal = 0.00;
echo '<table border="0" align="center" cellpadding="2" cellspacing="2" style="width: 80%; text-align: left;">';
echo '<tr><th></th><th style="vertical-align: top; text-align: left">Name</th><th style="vertical-align: top; text-align: left">Address (First Line)</th><th style="vertical-align: top; text-align: left">Membership Type</th><th style="text-align: right">Price</th></tr>';
foreach ($postobjs['ca'] as &$ca) {
?>
<tr>
<td>
<?php
if ($_POST['checkout'] != "Check Out") {
?>
<input type="checkbox" name="delobj_ca_<?php echo $ca->obj_id ?>"></input>
<?php
}
unset($addr);
unset($badge);
?>
</td>
<td><?php echo $ca->fields['first'] . ' ' . $ca->fields['last'] ?></td>
<td><?php $addr =& current($ca->addresses); echo $addr->fields['addr1'] ?></td>
<?php $badge =& current($ca->stuff['badge']) ?>
<td><?php echo $_SESSION['db_enums']['badgetypes'][$badge->fields['type']]['name'] ?></td>
<td style="text-align: right"><?php echo "$" . $badge->fields['price']; $subtotal += $badge->fields['price'] ?></td>
</tr>
<?php
}
$subtotal = number_format($subtotal, 2);
echo '<tr><td colspan="4" style="text-align: right">Subtotal:</td>' . "<td style=\"text-align: right\">\${$subtotal}</td></tr>";
echo '<tr><td colspan="4" style="text-align: right">Ticketing Fee:</td>' . '<td style="text-align: right">$' . number_format($total = (($subtotal * 0.035) + 0.35), 2) . "</td></tr>";
$total = number_format($total + $subtotal, 2);
echo '<tr><td colspan="4" style="text-align: right">Total:</td>' . "<td style=\"text-align: right\">\${$total}</td></tr>";
if ($_POST['checkout'] == "Check Out") {
foreach ($postobjs['address'] as &$address) {
$address->fields['mailing'] = 'on';
$address->fields['valid'] = 'on';
}
echo '<tr><td colspan="2"></td><td colspan="3">';
echo '<br />You will be billed via e-mail for your registrations.<br />A bill will be sent by ProPay, our billing provider.<br />The bill will be from [email protected] - this is normal.<br />Please enter your e-mail address to complete your order.';
echo '</td>';
echo '<tr><td colspan="2"></td><td colspan="3">';
echo 'Billing e-mail address: <input type="text" name="email" size="30"></input>';
echo '</td>';
echo '</table><p style="text-align: center"><input type="submit" name="finish" value="Complete Order"></input></p>';
echo '<input type="hidden" name="total" ' . "value=\"$total\"></input>";
}
else echo '</table><p style="text-align: center"><input type="submit" name="add" value="Add additional membership"></input> <input type="submit" name="del" value="Delete Checked Memberships"></input> <input type="submit" name="checkout" value="Check Out"></input></p>';
}
elseif ($add) {
$newca = new ca;
$newaddr = new address;
$newbadge = new badge;
$newaddr->fields['ca'] = $newca->obj_id;
$newbadge->fields['ca'] = $newca->obj_id;
$newbadge->fields['status'] = '7';
?>
<p style="text-align: center">Please enter the information for this attendee and click the button below when you are finished.</p>
<table border="0" align="center" cellpadding="2" cellspacing="2" style="width: 80%; text-align: left;">
<tbody>
<tr>
<th style="vertical-align: top; text-align: left">Name (First, MI, Last)<br>
</th>
<th style="vertical-align: top; text-align: left">Membership Type<br>
</th>
<th style="vertical-align: top; text-align: left">Age (if under 18)<br>
</th>
</tr>
<tr>
<td style="vertical-align: top;"><input type="hidden" name="new_ca_id" value="<?php echo $newca->obj_id ?>"><input type="hidden" name="editobj_ca_<?php echo $newca->obj_id ?>" value="true"><?php echo $newca->textbox("first", 12); echo $newca->textbox("middle", 2); echo $newca->textbox("last", 16);?></td>
<td style="vertical-align: top;"><input type="hidden" name="editobj_badge_<?php echo $newbadge->obj_id ?>" value="true"><?php echo $newbadge->hidden("ca") . $newbadge->hidden("status") ?><select name="badge_<?php echo $newbadge->obj_id ?>_type" size="1">
<option value="150" selected>General Pre-Reg</option>
<option value="151">Supporting Member</option>
<option value="152">Student Pre-Reg</option>
<option value="153">Child Pre-Reg</option>
<option value="165">Staff Pre-Reg</option>
<option value="166">Student Staff Pre-Reg</option>
<option value="170">Volunteer Pre-Reg</option>
<option value="171">Student Volunteer Pre-Reg</option>
</select></td>
<td style="vertical-align: top;"><?php echo $newca->textbox("age", 4) ?></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: right;">Comments:</td>
<td style="vertical-align: top; text-align: left;" colspan="2"><?php echo str_replace("<textarea", '<textarea cols="50"', $newca->textarea("comments")) ?></td>
</tr>
<tr>
<td><input type="hidden" name="editobj_address_<?php echo $newaddr->obj_id ?>" value="true"><?php echo $newaddr->hidden('ca') ?>Mailing Address:<br>
<?php
if (isset($postobjs['address'])) {
$addrlines = array();
foreach ($postobjs['address'] as $addr) $addrlines[$addr->obj_id] = $addr->fields['addr1'];
$addrlines = array_unique(array_filter(($addrlines)));
if (count($addrlines) > 0) {
echo '<select name="useoldaddr" size="1"><option value="0">Select existing address:</option>';
foreach ($addrlines as $addrid => $addrline) echo "<option value=\"$addrid\">$addrline</option>";
echo '</select>';
}
}
?>
</td>
<td>Street Address:<br><?php echo $newaddr->textbox('addr1', 20) ?><br><?php echo $newaddr->textbox('addr2', 20) ?></td>
<td>City: <?php echo $newaddr->textbox('city', 20) ?><br>State: <?php echo $newaddr->textbox('state', 10) ?><br>Postal Code: <?php echo $newaddr->textbox('zip', 10) ?></td>
</tr>
</tbody>
</table>
<p style="text-align: center">
<input type="submit" value="Add membership to cart"></input>
</p>
<?php
}
if (isset($postobjs)) foreach($postobjs as $objarr) foreach($objarr as $object) echo $object->display_hidden();
?>
</form>
</body>
</html>