[LON-CAPA-cvs] cvs: modules /raeburn/register register.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Wed, 21 Mar 2007 22:17:33 -0000
This is a MIME encoded message
--raeburn1174515453
Content-Type: text/plain
raeburn Wed Mar 21 18:17:33 2007 EDT
Modified files:
/modules/raeburn/register register.pm
Log:
Use CSS.
Form items can now have a cost associated with them, and there can be a cost for registration itself.
Interface for use the AIS webCredit system.
--raeburn1174515453
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20070321181733.txt"
Index: modules/raeburn/register/register.pm
diff -u modules/raeburn/register/register.pm:1.8 modules/raeburn/register/register.pm:1.9
--- modules/raeburn/register/register.pm:1.8 Fri May 5 14:30:42 2006
+++ modules/raeburn/register/register.pm Wed Mar 21 18:17:29 2007
@@ -10,6 +10,7 @@
use HTTP::Cookies;
use CGI::Apache qw(:standard);
use Apache::LON::processform;
+use Time::Local;
use Date::Manip;
sub handler {
@@ -73,8 +74,9 @@
my @sponsors = ();
my %sponsorinfo = ();
my $domain = $params{'domain'};
+ my %feeinfo;
- my ($page,$year,$event,$portal,$returnpage,$event_id,$webpath,$year_quoted,$event_quoted);
+ my ($page,$year,$event,$portal,$returnpage,$event_id,$webpath,$year_quoted,$event_quoted,$fees);
if (exists $params{'return'}) {
$returnpage = $params{'return'};
}
@@ -105,12 +107,23 @@
$sponsorinfo{$name}{orientation} = $orientation;
}
$sth->finish;
- ($event_id,$webpath) = $dbh->selectrow_array("SELECT event_id,webpath FROM event_config WHERE year=$year_quoted AND event=$event_quoted");
+ ($event_id,$webpath,$fees) = $dbh->selectrow_array("SELECT event_id,webpath,fees FROM event_config WHERE year=$year_quoted AND event=$event_quoted");
$portal = $webpath.$returnpage;
if ($event_id eq '') {
&invalid_event($r,$dbh,$page,$year,$event,$portal,$returnpage,$exitpage,\@sponsors,\%sponsorinfo,$domain);
return OK;
} else {
+# check for fees
+ if ($fees) {
+ $sth = $dbh->prepare("SELECT iid,description,cost,required FROM products WHERE event_id = '$event_id'");
+ $sth->execute;
+ while ( my ($iid,$desc,$cost,$reqd) = $sth->fetchrow_array) {
+ $feeinfo{$iid}{desc} = $desc;
+ $feeinfo{$iid}{cost} = $cost;
+ $feeinfo{$iid}{reqd} = $reqd;
+ }
+ $sth->finish;
+ }
# get items that should appear in event_registration table
my $sth = $dbh->prepare("SELECT name FROM event_formfields WHERE event_id = '$event_id' AND tablename = 'event_registration'");
$sth->execute;
@@ -187,11 +200,15 @@
# figure out what page we're on and where we're heading.
$page = $params{'page'};
my $command = $params{'go'};
- my $current_page = &calculate_page($page,$command);
+ my $current_page = &calculate_page($page,$command);
+ if ($current_page == 3) {
+ my $status = $dbh->selectrow_array("SELECT status FROM event_registration WHERE user_id = $quoted_user AND event_id = '$event_id'");
+ &display_three($r,$event,$year,$event_id,$status,$domain,$portal,$returnpage,$exitpage,$dbh,$current_page,$contact_email,$contact_name,\@sponsors,\%sponsorinfo);
+ }
if ($current_page == 2) {
- &display_two($r,$event,$year,$event_id,\%params,$user,$domain,$portal,$returnpage,$exitpage,\%items,\@info,\@workshop,$dbh,$current_page,$contact_email,$contact_name,\%form_elements,\@rowitems,\@rowtitles,\@sponsors,\%sponsorinfo);
+ &display_two($r,$event,$year,$event_id,\%params,$user,$domain,$portal,$returnpage,$exitpage,\%items,\@info,\@workshop,$dbh,$current_page,$contact_email,$contact_name,\%form_elements,\@rowitems,\@rowtitles,\@sponsors,\%sponsorinfo,$fees,\%feeinfo);
} else {
- &display_one($r,$event_id,\%params,$user,\$domain,$portal,$returnpage,$exitpage,\%items,\@info,\@workshop,$dbh,$current_page,$contact_email,$contact_name,\%form_elements,\@rowitems,\@rowtitles,\@sponsors,\%sponsorinfo);
+ &display_one($r,$event_id,\%params,$user,\$domain,$portal,$returnpage,$exitpage,\%items,\@info,\@workshop,$dbh,$current_page,$contact_email,$contact_name,\%form_elements,\@rowitems,\@rowtitles,\@sponsors,\%sponsorinfo,$fees,\%feeinfo);
}
return OK;
}
@@ -214,27 +231,20 @@
}
$r->print(<<"END_OF_A");
-<html><head><title>LON-CAPA Event Registration</title>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head><title>LON-CAPA Event Registration</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<style type="text/css">
-<!--
-.buttonred
-{
- font-size: 13px; font-family: arial, Trebuchet MS, verdana, helvetica, san-serif; padding: 4px;
- line-height: 15px; color: #FFFFFF; text-align: center; background: #CC6633; font-weight: bold;
-}
--->
-</style>
+<link type="text/css" rel="stylesheet" href="/css/registration.css">
</head>
-<body bgcolor="#ffffff" link="#003333" alink="#003333" vlink="#003333">
+<body>
END_OF_A
&main_box($r,$year,$event);
$r->print(<<"END_OF_B");
- <table cellpadding="0" cellspacing="0" width="100%" border="0">
- <tr bgcolor="#ffffff">
- <td><font face="Arial,Helvetica,sans-serif">
- <a HREF="http://loncapa.org/">Home</a> --> <a href="$exitpage">Events</a> --> <a href="$portal">Information</a>--> <b>Choose a LON-CAPA event</b></font>
+ <table class="LC_breadcrumb">
+ <tr>
+ <td>
+ <a HREF="http://loncapa.org/">Home</a> --> <a href="$exitpage">Events</a> --> <a href="$portal">Information</a>--> <b>Choose a LON-CAPA event</b>
</td>
<td> </td>
<td align="right" valign="top">
@@ -249,9 +259,9 @@
<table border="0" width="100%">
<tr>
<td> </td>
- <td><font face='arial,helvetica,sans serif'>
+ <td>
<br /><br />Click on the link to the LON-CAPA event for you wish to register:<br /><br />
- <table>
+ <table class="LC_finder">
<tr>
<th>Event</th>
<th>Location</th>
@@ -277,7 +287,7 @@
}
sub display_one() {
- my ($r,$event_id,$params,$user,$domain,$portal,$returnpage,$exitpage,$items,$info,$workshop,$dbh,$page,$contact_email,$contact_name,$form_elements,$rowitems,$rowtitles,$sponsors,$sponsorinfo) = @_;
+ my ($r,$event_id,$params,$user,$domain,$portal,$returnpage,$exitpage,$items,$info,$workshop,$dbh,$page,$contact_email,$contact_name,$form_elements,$rowitems,$rowtitles,$sponsors,$sponsorinfo,$fees,$feeinfo) = @_;
my $year = $$params{'year'};
my $event = $$params{'event'};
my $quoted_user = $dbh->quote( $user );
@@ -293,6 +303,9 @@
my %userinfo = ();
my $username;
+ my $modifybutton = 'Modify Registration';
+ my $cancelbutton = 'Cancel Registration';
+
# Is there LON-CAPA user data or MSU user data?
if ($user =~ /[^\@]+:[^\@]+/) {
($username,$$domain) = split/:/,$user;
@@ -363,6 +376,79 @@
}
}
+# Is there payment data?
+ my $payinfo;
+ if ($fees) {
+ my (%total,%balance,%credit);
+ my $statement = "SELECT t.iid,t.quantity,t.status,t.amount FROM purchaser p, transactions t, webcredit w WHERE p.event_id = '$event_id' AND p.user_id = $quoted_user AND p.pid = t.pid AND w.wid = t.wid AND w.state IS NOT NULL ORDER BY t.tid";
+ my $sth = $dbh->prepare("$statement");
+ $sth->execute();
+ while (my ($iid,$quant,$status,$amount) = $sth->fetchrow_array) {
+ if ($iid) {
+ $total{$iid} += $quant;
+ $balance{$iid} += $amount;
+ }
+ }
+ $sth->finish;
+ my ($confcredit,$preconfcredit);
+
+ if ($status eq 'enroll' || $status eq 'cancel') {
+ foreach my $iid (sort(keys(%{$feeinfo}))) {
+ if ($$feeinfo{$iid}{reqd} eq 'Y') {
+ if (!defined($total{$iid})) {
+ $total{$iid} = 1;
+ }
+ if ($balance{$iid} eq '') {
+ $balance{$iid} = 0;
+ }
+ } elsif ($curr{$$feeinfo{$iid}{desc}} eq 'Y') {
+ if ($total{$iid} eq '') {
+ $total{$iid} = 1;
+ }
+ if ($balance{$iid} eq '') {
+ $balance{$iid} = 0;
+ }
+ }
+ }
+ }
+ foreach my $iid (keys(%balance)) {
+ $credit{$iid} = $balance{$iid} - ($total{$iid} * $$feeinfo{$iid}{'cost'});
+ $credit{$iid} = sprintf("%.2f",$credit{$iid});
+ }
+ if ($status eq 'enroll') {
+ foreach my $iid (sort(keys(%credit))) {
+ if (($$feeinfo{$iid}{'reqd'} eq 'Y') || ($curr{$$feeinfo{$iid}{'desc'}} eq 'Y')) {
+ if ($credit{$iid} == 0) {
+ $payinfo .= 'You have paid the '.$$feeinfo{$iid}{desc}.' fee in full.';
+ } elsif ($credit{$iid} > 0) {
+ $payinfo .= 'You have overpaid for the '.$$feeinfo{$iid}{desc}.' - a credit of $'.$credit{$iid}.' will be credited to your credit card.';
+ } elsif ($credit{$iid} < 0) {
+ my $debt = -1 * $credit{$iid};
+ $payinfo .= 'You owe $'.$debt.' for the '.$$feeinfo{$iid}{desc}.' fee.';
+ $modifybutton = 'Modify Registration/Pay Fee';
+ }
+ } else {
+ if ($credit{$iid} > 0) {
+ $payinfo .= 'A credit of $'.$credit{$iid}.' for the '.$$feeinfo{$iid}{desc}.' is due to you, as you are no longer registered for this program. Unless you choose to re-register, this amount will be credited to your credit card.';
+ }
+ }
+ $payinfo .= '<br />';
+ }
+ } elsif ($status eq 'cancel') {
+ foreach my $iid (sort(keys(%credit))) {
+ if ($credit{$iid} > 0) {
+ $payinfo .= 'A credit of $'.$credit{$iid}.' for the '.$$feeinfo{$iid}{'desc'}.' is due to you, as you are no longer registered for the '.$event.' '.$year.'.';
+ if ($$feeinfo{$iid}{'reqd'} eq 'Y') {
+ $payinfo .= ' Unless you choose to re-register, this amount will be credited to your credit card.';
+ } else {
+ $payinfo .= ' Unless you choose to re-register, and choose to participate in the '.$$feeinfo{$iid}{'desc'}.' this amount will be credited to your credit card.';
+ }
+ $payinfo .'<br />';
+ }
+ }
+ }
+ }
+
# Check if new registrations are allowed.
my ($registeropen,$registerclose) = $dbh->selectrow_array("SELECT registeropen,registerclose FROM event_config WHERE event_id = '$event_id'");
my ($regopen,$regclose,$opendate,$closedate);
@@ -559,9 +645,11 @@
END
}
$r->print(<<"END_OF_A");
-<html><head><title>LON-CAPA Event Registration: page 1</title>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head><title>LON-CAPA Event Registration: page 1</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link type="text/css" rel="stylesheet" href="/css/registration.css">
<script language=javascript type = "text/javascript">
<!--
@@ -571,17 +659,8 @@
// End hiding -->
</script>
-<style type="text/css">
-<!--
-.buttonred
-{
- font-size: 13px; font-family: arial, Trebuchet MS, verdana, helvetica, san-serif; padding: 4px;
- line-height: 15px; color: #FFFFFF; text-align: center; background: #CC6633; font-weight: bold;
-}
--->
-</style>
</head>
-<body bgcolor="#ffffff" link="#003333" alink="#003333" vlink="#003333" $load_func >
+<body $load_func >
<form method="post" name="regForm">
END_OF_A
@@ -592,10 +671,10 @@
}
$r->print(<<"END_OF_B");
- <table cellpadding="0" cellspacing="0" width="100%" border="0">
- <tr bgcolor="#ffffff">
- <td><font face="Arial,Helvetica,sans-serif">
- <a HREF="http://loncapa.org/">Home</a> --> <a href="$exitpage">Events</a> --> <a href="$portal">Information</a>--> <b>Add/Cancel/Modify Registration</b></font>
+ <table class="LC_breadcrumb">
+ <tr>
+ <td>
+ <a HREF="http://loncapa.org/">Home</a> --> <a href="$exitpage">Events</a> --> <a href="$portal">Information</a>--> <b>Add/Cancel/Modify Registration</b>
</td>
<td> </td>
<td align="right" valign="top">
@@ -610,12 +689,17 @@
<table border="0" width="100%">
<tr>
<td> </td>
- <td><font face='arial,helvetica,sans serif'>
+ <td>
<br /><br />
END_OF_B
if ($status eq 'enroll') {
- $r->print("<b>A registration currently exists for you for the $year LON-CAPA $event. Use this form to modify your registration, or to cancel it.</b><br /><br />");
+ $r->print("<b>A registration currently exists for you for the $year LON-CAPA $event.</b><br /><b>Use this form to modify your registration, or to cancel it.</b><br />");
+ if ($payinfo) {
+ $r->print($payinfo.'<br />');
+ } else {
+ $r->print('<br />');
+ }
} elsif ($status eq 'cancel') {
$r->print("<b>Your previous registration for the $year LON-CAPA $event was cancelled.</b> ");
if ($regaccess eq 'current') {
@@ -623,9 +707,26 @@
} elsif ($regaccess eq 'past') {
$r->print("<b>Reactivation of cancelled registrations is not currently available as new registrations will not be allowed until $opendate");
}
+ if ($payinfo) {
+ $r->print('<br />'.$payinfo.'<br />');
+ }
} else {
if ($regaccess eq 'current') {
$r->print("<b>Please submit your registration for the $year LON-CAPA $event.</b>");
+ if ($fees) {
+ $r->print("<br />After submitting this form you will be directed to MSU's secure payment site to provide your credit card details, so the registration fee(s) can be collected:<br />");
+ if (keys(%{$feeinfo}) > 0) {
+ $r->print('<ul>');
+ foreach my $item (sort(keys(%{$feeinfo}))) {
+ $r->print('<li>');
+ if ($$feeinfo{$item}{reqd} eq 'N') {
+ $r->print('optional ');
+ }
+ $r->print($$feeinfo{$item}{desc}.' - $'.$$feeinfo{$item}{cost}.'</li>');
+ }
+ $r->print('</ul>');
+ }
+ }
} elsif ($regaccess eq 'future') {
$r->print("<b>New registrations for the $year LON-CAPA $event will be accepted beginning $opendate. Please return at that time to make your reservation.</b>");
} elsif ($regaccess eq 'past') {
@@ -650,15 +751,15 @@
END_OF_C
if ($status eq "enroll") {
$r->print(qq|
- <input type="button" class="buttonred" name="modify" value="Modify" onClick="javascript:validForm('modify')"> <input type="button" class="buttonred" value="Cancel" name="cancel" onClick=javascript:validForm('cancel')
+ <input type="button" class="buttoncolored" name="modify" value="$modifybutton" onClick="javascript:validForm('modify')"> <input type="button" class="buttoncolored" value="$cancelbutton" name="cancel" onClick=javascript:validForm('cancel')
|);
} elsif ($status eq "cancel") {
$r->print(qq|
- <input type="button" class="buttonred" name="reactivate" value="Re-register" onClick=
+ <input type="button" class="buttoncolored" name="reactivate" value="Re-register" onClick=
"javascript:validForm('add')">|);
} else {
$r->print(qq|
- <input type="button" class="buttonred" name="register" value="Register" onClick="javascript:validForm('add')">|);
+ <input type="button" class="buttoncolored" name="register" value="Register" onClick="javascript:validForm('add')">|);
}
$r->print(<<"END_OF_BLOCK");
</td>
@@ -668,30 +769,22 @@
<tr>
<td> </td>
<td>
- <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
- <tr>
- <td>
- <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
- <tr>
- <td>
- <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
- <tr>
- <td>
- <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
+ <table class="LC_regform">
END_OF_BLOCK
for (my $i=0; $i<@{$rowitems}; $i++) {
+ my $leftcss = 'LC_leftinner';
+ my $rightcss = 'LC_rightinner';
+ if ($i == @{$rowitems} - 1) {
+ $leftcss = 'LC_leftcol';
+ $rightcss = 'LC_rightcol';
+ }
$r->print(<<"END_ITEM");
<tr>
- <td width="200" bgcolor="#FFEEBB">
- <table width="200" border="0" cellpadding="8" cellspacing="0">
- <tr>
- <td align="right"><font face="Arial, Helvetica, sans-serif"><b>$$rowtitles[$i]</b></font>
- </td>
- </tr>
- </table>
+ <td align="right" class="$leftcss"><b>$$rowtitles[$i]</b>
</td>
- <td valign="top" bgcolor="#FFFFBB">
- <table width="100%" border="0" cellpadding="8" cellspacing="0"> <tr align="left">
+ <td valign="top" class="$rightcss">
+ <table width="100%" border="0" cellpadding="8" cellspacing="0">
+ <tr align="left">
END_ITEM
for (my $j=0; $j<@{$$rowitems[$i]}; $j++) {
if ($$form_elements{$$rowitems[$i][$j]}{preamble}) {
@@ -731,10 +824,12 @@
$r->print('<input type="text" size="'.$$form_elements{$$rowitems[$i][$j]}{size}.'" name="'.$$rowitems[$i][$j].'" value="'.$userinfo{$$rowitems[$i][$j]}.'">');
} elsif ($$form_elements{$$rowitems[$i][$j]}{type} eq 'radio') {
my @items = split/\&/,$$form_elements{$$rowitems[$i][$j]}{contents};
+ $r->print('<nobr>');
foreach (@items) {
my ($value,$name) = split/=/,$_;
$r->print('<input type="radio" name="'.$$rowitems[$i][$j].'" value="'.$value.'">'.$name.' ');
}
+ $r->print('</nobr>');
} elsif ($$form_elements{$$rowitems[$i][$j]}{type} eq 'checkbox') {
my @items = split/\&/,$$form_elements{$$rowitems[$i][$j]}{contents};
for (my $k=0; $k<@items; $k++) {
@@ -781,26 +876,9 @@
</table>
</td>
</tr>');
- unless ($i == @{$rowitems}-1) {
- $r->print('
- <tr>
- <td colspan="2" bgcolor="#000000">
- <img src="/images/login/blackdot.jpg" /><br />
- </td>
- </tr>');
- }
}
$r->print(<<"ENDBLOCK");
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
+ </table>
</td>
</tr>
</table>
@@ -808,15 +886,15 @@
ENDBLOCK
if ($status eq "enroll") {
$r->print(qq|
- <input type="button" class="buttonred" name="modify" value="Modify" onClick="javascript:validForm('modify')"> <input type="button" class="buttonred" value="Cancel" name="cancel" onClick=javascript:validForm('cancel')
+ <input type="button" class="buttoncolored" name="modify" value="$modifybutton" onClick="javascript:validForm('modify')"> <input type="button" class="buttoncolored" value="$cancelbutton" name="cancel" onClick=javascript:validForm('cancel')
|);
} elsif ($status eq "cancel") {
$r->print(qq|
- <input type="button" class="buttonred" name="reactivate" value="Re-register" onClick=
+ <input type="button" class="buttoncolored" name="reactivate" value="Re-register" onClick=
"javascript:validForm('add')">|);
} else {
$r->print(qq|
- <input type="button" class="buttonred" name="register" value="Register" onClick="javascript:validForm('add')">|);
+ <input type="button" class="buttoncolored" name="register" value="Register" onClick="javascript:validForm('add')">|);
}
$r->print (qq|
<br />
@@ -829,7 +907,7 @@
sub display_two() {
- my ($r,$event,$year,$event_id,$params,$user,$domain,$portal,$returnpage,$exitpage,$items,$info,$workshop,$dbh,$page,$contact_email,$contact_name,$form_elements,$rowitems,$rowtitles,$sponsors,$sponsorinfo) = @_;
+ my ($r,$event,$year,$event_id,$params,$user,$domain,$portal,$returnpage,$exitpage,$items,$info,$workshop,$dbh,$page,$contact_email,$contact_name,$form_elements,$rowitems,$rowtitles,$sponsors,$sponsorinfo,$fees,$feeinfo) = @_;
my $enc_event = &HTML::Entities::encode($event);
$enc_event =~ tr/ /+/;
my $action = $$params{'nextaction'};
@@ -872,6 +950,20 @@
}
$sth->finish;
+# Get fee information
+ my %feehash;
+ if ($fees) {
+ $sth = $dbh->prepare("SELECT iid,description,cost,required,longdesc FROM products WHERE event_id = '$event_id'");
+ $sth->execute;
+ while (my ($iid,$desc,$cost,$required,$longdesc)=$sth->fetchrow_array) {
+ $feehash{$desc}{'iid'} = $iid;
+ $feehash{$desc}{'cost'} = $cost;
+ $feehash{$desc}{'reqd'} = $required;
+ $feehash{$desc}{'longdesc'} = $longdesc;
+ }
+ $sth->finish;
+ }
+
# Is there already conference data for this user?
my $status = $dbh->selectrow_array("SELECT status FROM event_registration WHERE user_id = $quoted_user AND event_id = '$event_id'");
if ($status eq 'enroll') {
@@ -982,7 +1074,7 @@
my $statement = "$insertpart $valuespart";
$dbh->do($statement);
}
-
+
if ($action eq 'add') {
my $newstatus = 'enroll';
if ($register == -1) {
@@ -1149,6 +1241,84 @@
}
}
}
+
+# Get payment data?
+ my (%total,%balance,%ccard,$payinfo,%costs,%quantities,%transactions,%credtrans);
+ my $order = 0;
+ my $paynum = 0;
+ my $creditnum = 0;
+ my $curr_pid = $dbh->selectrow_array("SELECT pid FROM purchaser WHERE event_id = '$event_id' AND user_id = $quoted_user");
+ my $currstatus = $dbh->selectrow_array("SELECT status FROM event_registration WHERE user_id = $quoted_user AND event_id = '$event_id'");
+ if ($fees) {
+ my $statement = "SELECT t.iid,t.quantity,t.status,t.amount FROM purchaser p, transactions t, webcredit w WHERE p.event_id = '$event_id' AND p.user_id = $quoted_user AND p.pid = t.pid AND w.wid = t.wid AND w.state IS NOT NULL ORDER BY t.tid";
+ my $sth = $dbh->prepare("$statement");
+ $sth->execute();
+ while (my ($iid,$quant,$status,$amount) = $sth->fetchrow_array) {
+ if ($iid) {
+ $total{$iid} += $quant;
+ $balance{$iid} += $amount;
+ }
+ }
+ $sth->finish;
+ foreach my $key (keys(%feehash)) {
+ if (ref($feehash{$key}) eq 'HASH') {
+ if (($feehash{$key}{reqd} eq 'Y') || ($finaldispdat{$key} eq 'Y')) {
+ if ($currstatus eq 'enroll') {
+ $costs{$key} = $feehash{$key}{'cost'};
+ $quantities{$key} ++;
+ } else {
+ $costs{$key} = 0;
+ }
+ }
+ }
+ }
+ foreach my $iid (keys(%balance)) {
+ my $desc = $$feeinfo{$iid}{'desc'};
+ if (!$costs{$desc}) {
+ $costs{$desc} = 0;
+ }
+ }
+ foreach my $key (keys(%costs)) {
+ $ccard{$key} = $balance{$feehash{$key}{'iid'}}-$costs{$key};
+ $ccard{$key} = sprintf("%.2f",$ccard{$key});
+ if ($ccard{$key} == 0) {
+ if ($currstatus eq 'enroll') {
+ $payinfo .= 'You have paid the '.$key.' fee in full.';
+ } elsif ($currstatus eq 'cancel') {
+ $payinfo .= 'There is no credit due for the '.$key.' as a result of cancellation.';
+ }
+ } elsif ($ccard{$key} > 0) {
+ $creditnum ++;
+ my $credit = -1 * $ccard{$key};
+ my $iid = $feehash{$key}{'iid'};
+ $credtrans{$iid}{quantity} += -1 * $total{$feehash{$key}{'iid'}};
+ $credtrans{$iid}{amount} = $credit;
+ $credtrans{$iid}{status} = 'credit';
+ $credtrans{$iid}{desc} = $key;
+ if ($currstatus eq 'enroll') {
+ if (($feehash{$key}{reqd} eq 'Y') || ($finaldispdat{$key} eq 'Y')) {
+ $payinfo .= 'You have overpaid for '.$key.' - a credit of $'.$ccard{$key}.' will be credited to your credit card.';
+ } else {
+ $payinfo .= 'As you will not be attending the '.$key.' a credit of $'.$ccard{$key}.' will be credited to your credit card.';
+ }
+ $payinfo .= ' This credit will be processed within 1 to 2 business days.';
+ } elsif ($currstatus eq 'cancel') {
+ $payinfo .= 'As you have cancelled, a credit of $'.$ccard{$key}.' for the '.$key.' will be credited to your credit card.';
+ }
+ } elsif ($ccard{$key} < 0) {
+ my $debt = -1 * $ccard{$key};
+ $payinfo .= 'You owe $'.$debt.' for the '.$key.' fee.';
+ $order += $debt;
+ $paynum ++;
+ my $iid = $feehash{$key}{'iid'};
+ $transactions{$iid}{quantity} += $quantities{$key};
+ $transactions{$iid}{amount} = $debt;
+ $transactions{$iid}{status} = 'payment';
+ }
+ $payinfo .= '<br />';
+ }
+ }
+
if ($mailflag) {
my $requestmail = "To: $$params{'email'}\n";
$requestmail .= "From: $contact_name <$contact_email>\n".
@@ -1165,8 +1335,8 @@
&error_exit($r,$page,$year,$event,"Can't fork for sendmail:$!\n",$contact_name,$contact_email,$sponsors,$sponsorinfo,$domain);
return;
}
- my $mailcopy = "To: felicia\@lon-capa.org\n".
- "From: $contact_email\n".
+ my $mailcopy = "To: $contact_email\n".
+ "From: loncapa@loncapa.org\n".
"Subject: LON-CAPA conference/workshop change\n".
"The following transaction occurred for $user in the LON-CAPA events registration system: \n".
"$msg\n"."$statusmsg{mail}\n";
@@ -1185,13 +1355,14 @@
add => 'modify or cancel'
);
$r->print(<<"END_OF_A");
-<html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>LON-CAPA Event Registration: page 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="pragma" content="no-cache">
+<link type="text/css" rel="stylesheet" href="/css/registration.css">
</head>
-<body bgcolor="#ffffff" link="#003333" alink="#003333" vlink="#003333">
+<body>
END_OF_A
&main_box($r,$year,$event);
@@ -1201,10 +1372,180 @@
}
$r->print(<<"END_OF_B");
- <table cellpadding="0" cellspacing="0" width="100%" border="0">
- <tr bgcolor="#ffffff">
- <td><font face="Arial,Helvetica,sans-serif">
- <a HREF="http://loncapa.org/">Home</a> --> <a href="$exitpage">Events</a> --> <a href="$portal">Information</a>--> <a href="/register?year=$year&event=$enc_event">Add/Cancel/Modify registration</a> --> <b>Confirmation</b></font>
+ <table class="LC_breadcrumb">
+ <tr>
+ <td>
+ <a HREF="http://loncapa.org/">Home</a> --> <a href="$exitpage">Events</a> --> <a href="$portal">Information</a>--> <a href="/register?year=$year&event=$enc_event">Add/Cancel/Modify registration</a> --> <b>Confirmation</b>
+ </td>
+ <td> </td>
+ <td align="right" valign="top">
+ <img border="0" src="/images/login/logout_red.gif" width="90" height="23" align="right" usemap="#event_header">
+ <map name = 'event_header'>
+ <area shape='rect' coords=10,2,80,18' href="/logout?portal=$logoutportal">
+ <area shape = 'default' nohref>
+ </map>
+ </td>
+ </tr>
+ </table>
+ <br />
+ <table border="0" width="100%">
+ <tr>
+ <td> </td>
+ <td><h3>Registration Changes</h3>
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td class="LC_receipt">$webmsg<br />$statusmsg{web}</td>
+ </tr>
+END_OF_B
+ if ($fees) {
+ $r->print(<<"END_OF_C");
+ <tr>
+ <td colspan="2"> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td class="LC_receipt">$payinfo
+END_OF_C
+ if ($paynum) {
+ my $pid;
+ if ($curr_pid eq '') {
+ my $lastpid = $dbh->selectrow_array("SELECT LAST_INSERT_ID() FROM purchaser");
+ $dbh->do("INSERT INTO purchaser (user_id,event_id) VALUES ($quoted_user,'$event_id')");
+ $pid = $dbh->selectrow_array("SELECT LAST_INSERT_ID() FROM purchaser");
+ if ($pid - $lastpid > 1) {
+ print STDERR "Warning - strange behavior in puchaser table, last id before insert was $lastpid, last id after insert was $pid. This is for $event_id and $user\n";
+ }
+ } else {
+ $pid = $curr_pid;
+ }
+ $dbh->do("INSERT INTO webcredit (pid,created) VALUES ($pid,NOW())");
+ my $wid = $dbh->selectrow_array("SELECT LAST_INSERT_ID() FROM webcredit");
+ foreach my $iid (sort(keys(%transactions))) {
+ if (ref($transactions{$iid}) eq 'HASH') {
+ $dbh->do("INSERT INTO transactions (wid,pid,iid,quantity,status,amount) VALUES ('$wid','$pid','$iid','$transactions{$iid}{quantity}','$transactions{$iid}{status}','$transactions{$iid}{amount}')");
+ }
+ }
+ my $redirect = '/register?year='.$year.'&event='.$enc_event.'&page=2&go=NextPage';
+ my $webcreditform = &webcredit($paynum,$order,$wid,\%ccard,
+ \%feehash,\%finaldispdat,\%costs,
+ \%quantities,$redirect);
+ $r->print('<br /><br />'.$webcreditform);
+ }
+ if ($creditnum) {
+ my (%drop,%refund);
+ if ($curr_pid) {
+ foreach my $iid (sort(keys(%credtrans))) {
+ if (ref($credtrans{$iid}) eq 'HASH') {
+ my $remaining = -1 *$credtrans{$iid}{'quantity'};
+ my $moneyback = -1 * $credtrans{$iid}{'amount'};
+ print STDERR "$iid -- remaining = $remaining, moneyback = $moneyback\n";
+ my $sth = $dbh->prepare("SELECT wid,quantity,amount FROM transactions WHERE (iid = '$iid' AND pid = '$curr_pid' AND status = 'payment') ORDER BY wid");
+ $sth->execute();
+ while ((my ($oldwid,$quantity,$amount) = $sth->fetchrow_array) && ($remaining > 0)) {
+ $drop{$oldwid}{$iid} = -1 * $remaining;
+ $refund{$oldwid}{$iid} = -1 * $moneyback;
+ $remaining -= $quantity;
+ $moneyback -= $amount;
+ if ($remaining > 0) {
+ $drop{$oldwid}{$iid} = -1 * $quantity;
+ }
+ if ($moneyback > 0) {
+ $refund{$oldwid}{$iid} = -1 * $amount;
+ }
+ }
+ $sth->finish;
+ }
+ }
+ foreach my $wid (sort(keys(%refund))) {
+ my $newbal = $dbh->selectrow_array("SELECT amount FROM webcredit WHERE wid = '$wid'");
+ print STDERR "refund for $wid, startbal = $newbal\n";
+ if (ref($refund{$wid}) eq 'HASH') {
+ foreach my $iid (keys(%{$refund{$wid}})) {
+ $newbal += $refund{$wid}{$iid};
+ print STDERR "Balance changed by $refund{$wid}{$iid}\n";
+ }
+ $dbh->do("UPDATE webcredit SET modified=NOW(),state='C',amount='$newbal' WHERE wid='$wid'");
+ }
+ }
+ foreach my $wid (sort(keys(%drop))) {
+ if (ref($drop{$wid}) eq 'HASH') {
+ foreach my $iid (keys(%{$drop{$wid}})) {
+ $dbh->do("INSERT INTO transactions (wid,pid,iid,quantity,status,amount) VALUES ('$wid','$curr_pid','$iid','drop{$wid}{$iid}','$credtrans{$iid}{status}','$refund{$wid}{$iid}')");
+ }
+ }
+ }
+ }
+ }
+ $r->print(<<"END_OF_D");
+ </td>
+ </tr>
+END_OF_D
+ }
+ if (!$paynum) {
+ $r->print(<<"END_OF_E");
+ <tr>
+ <td colspan="2"> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td class="LC_receipt">
+ If you need to make modifications to your registration in the future, please return to the <a href="/register?year=$year&event=$enc_event">$year $event page</a> to $lateraction{$action} your registration. Thank you for your interest in LON-CAPA events.
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td class="LC_receipt">
+ Please logout from LON-CAPA support/registration when you are finished.
+ </td>
+ </tr>
+END_OF_E
+ }
+ $r->print(<<"END_OF_F")
+ <tr>
+ <td colspan="2"> </td>
+ </tr>
+ </table>
+END_OF_F
+ &main_footer($r,$page,$year,$event,$returnpage,$sponsors,$sponsorinfo,$domain);
+}
+
+sub display_three {
+ my ($r,$event,$year,$event_id,$status,$domain,$portal,$returnpage,$exitpage,$dbh,$page,$contact_email,$contact_name,$sponsors,$sponsorinfo) = @_;
+ my $enc_event = &HTML::Entities::encode($event);
+ $enc_event =~ tr/ /+/;
+
+ my %lateraction = (
+ cancel => 'reactivate',
+ enroll => 'modify or cancel',
+ );
+
+ $r->print(<<"END_OF_A");
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<title>LON-CAPA Event Registration: page 3</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="pragma" content="no-cache">
+<link type="text/css" rel="stylesheet" href="/css/registration.css">
+</head>
+<body>
+END_OF_A
+
+ &main_box($r,$year,$event);
+ my $logoutportal = $portal;
+ if ($logoutportal =~ /^\/update/) {
+ $logoutportal = '/register';
+ }
+
+ $r->print(<<"END_OF_B");
+ <table class="LC_breadcrumb">
+ <tr>
+ <td>
+ <a HREF="http://loncapa.org/">Home</a> --> <a href="$exitpage">Events</a> --> <a href="$portal">Information</a>--> <a href="/register?year=$year&event=$enc_event">Add/Cancel/Modify registration</a> --> <b>Credit Card Coompletion</b>
</td>
<td> </td>
<td align="right" valign="top">
@@ -1222,46 +1563,102 @@
<table border="0" width="100%">
<tr>
<td> </td>
- <td><font face="Arial,Helvetica,sans-serif" size="3"><b>Registration Changes</b></font>
- </td>
+ <td><h3>WebCredit Transaction</h3>
+ </td>
</tr>
<tr>
- <td colspan='2'> </td>
+ <td colspan="2"> </td>
</tr>
<tr>
+ <tr>
<td> </td>
<td>
- <font face="Arial, Helvetica, sans-serif" size="2">$webmsg<br />$statusmsg{web}
- </font>
+ Thank you for providing credit card information through MSU's secure webCredit site.
</td>
</tr>
<tr>
- <td colspan='2'> </td>
+ <td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td>
- <font size='2' face='Arial,Helvetica,sans-serif'>If you need to make modifications to your registration in the future, please return to the <a href="/register?year=$year&event=$enc_event">$year $event page</a> to $lateraction{$action} your registration. Thank you for your interest in LON-CAPA events.</font>
+ If you need to make modifications to your registration in the future, please return to the <a href="/register?year=$year&event=$enc_event">$year $event page</a> to $lateraction{$status} your registration. Thank you for your interest in LON-CAPA events.
</td>
</tr>
<tr>
- <td colspan='2'> </td>
+ <td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td>
- <font size='2' face='Arial,Helvetica,sans-serif'>Please logout from LON-CAPA support/registration when you are finished.</font>
+ Please logout from LON-CAPA support/registration when you are finished.
</td>
</tr>
<tr>
- <td colspan='2'> </td>
+ <td colspan="2"> </td>
</tr>
</table>
END_OF_B
-
&main_footer($r,$page,$year,$event,$returnpage,$sponsors,$sponsorinfo,$domain);
}
+sub webcredit {
+ my ($paynum,$order,$wid,$ccard,$feehash,$finaldat,$costs,$quantities,
+ $redirect) = @_;
+ my %sort_by_id;
+ my $checksum1 = (($order*300)+1)%307;
+ my $checksum2 = (($order*4200)+8)%1039;
+ my $name = $finaldat->{'firstname'}.' '.$finaldat->{'lastname'}.' '.$finaldat->{'generation'};
+ $name =~ s/^\s+//;
+ $name =~ s/\s+$//;
+ my $address = $finaldat->{'streetaddress'};
+ my $citystate = $finaldat->{'citystate'};
+ $citystate =~ s/\s+$//;
+ my ($city,$state) = ($citystate =~ /^(.+)\s+([^\s]+)$/);
+ my $output .= <<END_A;
+<form name="webcredit" action="https://payments.qual.ais.msu.edu/process/" method="post">
+<input type="hidden" name="Identifier" Value="32546LON">
+<input type="hidden" name="Version" Value="3.2">
+<input type="hidden" name="Card_Email" Value="$finaldat->{'email'}">
+<input type="hidden" name="Card_Name" Value="$name">
+<input type="hidden" name="Ship_Name" Value="$name">
+<input type="hidden" name="Ship_Address1" Value="$address">
+<input type="hidden" name="Ship_City" Value="$city">
+<input type="hidden" name="Ship_State" Value="$state">
+<input type="hidden" name="Ship_Country" Value="">
+<input type="hidden" name="Ship_Zip" Value="$finaldat->{'zip'}">
+<input type="hidden" name="Ship_Phone1" Value="$finaldat->{'phone'}">
+<input type="hidden" name="Order_Fkey" Value="$wid">
+<input type="hidden" name="Order_Price" Value="$order">
+<input type="hidden" name="Order_Checksum1" Value="$checksum1">
+<input type="hidden" name="Order_Checksum2" Value="$checksum2">
+<input type="hidden" name="Order_Items" Value="$paynum">
+END_A
+ my $n = 0;
+ foreach my $item (keys(%{$ccard})) {
+ if ($ccard->{$item} < 0) {
+ $sort_by_id{$feehash->{$item}{'iid'}} = $item;
+ }
+ }
+ foreach my $iid (sort(keys(%sort_by_id))) {
+ my $item = $sort_by_id{$iid};
+ $n ++;
+ my $debt = -1 * $ccard->{$item};
+ $output .= <<END_B;
+<input type="hidden" NAME="Prod_SKU$n" Value="$iid">
+<input type="hidden" NAME="Prod_Qty$n" Value="$quantities->{$item}">
+<input type="hidden" NAME="Prod_Name$n" Value="$feehash->{$item}{'longdesc'}">
+<input type="hidden" NAME="Prod_Price$n" Value="$costs->{$item}">
+<input type="hidden" NAME="Prod_TotalPrice$n" Value="$debt">
+END_B
+ }
+ $output .= <<END_C;
+<input type="button" class="buttoncolored" value="Proceed to secure payment site" onClick="submit()" />
+</form>
+END_C
+ return $output;
+}
+
sub error_exit() {
my ($r,$page,$year,$event,$error_msg,$contact_name,$contact_email,$sponsors,$sponsorinfo,$domain) = @_;
$r->print(<<"END_OF_TOP");
@@ -1269,18 +1666,19 @@
<HEAD>
<meta http-equiv="pragma" content="no-cache">
<TITLE>Registration Error</TITLE>
+<link type="text/css" rel="stylesheet" href="/css/registration.css">
</head>
-<body bgcolor="#ffffff" link="#003333" alink="#003333" vlink="#003333">
+<body>
<form method="post" name="event_err">
END_OF_TOP
&main_box($r,$year,$event);
$r->print(<<"END_OF_CRUMBS");
- <table cellpadding="0" cellspacing="0" width="100%" border="0">
- <tr bgcolor="#ffffff">
- <td><font face="Arial,Helvetica,sans-serif">
- <a HREF="http://loncapa.org">Home</a> --> <a href="http://loncapa.org/conferences.html/">Events information</a> --> <b>Add/Cancel/Modify Registration</b></font>
+ <table class="LC_breadcrumb">
+ <tr>
+ <td>
+ <a HREF="http://loncapa.org">Home</a> --> <a href="http://loncapa.org/conferences.html/">Events information</a> --> <b>Add/Cancel/Modify Registration</b>
</td>
<td> </td>
</tr>
@@ -1291,27 +1689,27 @@
<table border="0" width="100%">
<tr>
<td> </td>
- <td><font face='arial,helvetica,sans serif' size='+1'>
+ <td><font size="+1">
<b> Processing Error</font></b>
</td>
</tr>
<tr>
- <td colspan='2'> </td>
+ <td colspan="2"> </td>
</tr>
<tr>
<td> </td>
- <td><font face='arial,helvetica,sans-serif' size='2'>A problem was encountered.</font></td>
+ <td><font size="2">A problem was encountered.</font></td>
</tr>
<tr>
- <td colspan='2'> </td>
+ <td colspan="2"> </td>
</tr>
<tr>
<td> </td>
- <td><font face='arial,helvetica,sans-serif' size='2'>
+ <td><font size="2">
Please send an e-mail to $contact_name at <a href="mailto:$contact_email">$contact_email</a> to report the error: <b>"$error_msg"</b>.</font></td>
</tr>
<tr>
- <td colspan='2'> </td>
+ <td colspan="2"> </td>
</tr>
</table>
END_OF_CRUMBS
@@ -1325,22 +1723,22 @@
<table border="0">
<tr>
<td align="middle">
-<table width="800" BORDER="0" CELLSPACING="0" CELLPADDING="4" WIDTH="100%">
+<table class="LC_mainbox">
<tr>
- <td colspan="4" valign="top" align="center" bgcolor="#CC6633">
+ <td colspan="4" valign="top" align="center" class="LC_darker">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left">
<img border='0' src="/images/login/tmcc.jpg" width="420" height="60">
</td>
- <td><font face="arial,helvetica,sans-serif" size="+2" color="#ffffff"><b>LON-CAPA <br />$event $year</b></font></td>
+ <td class="LC_boxtitle"><b>LON-CAPA <br />$event $year</b></td>
</tr>
</table>
</td>
</tr>
<tr>
- <td width="8" bgcolor="#CC6633"> </td>
- <td bgcolor="#FFFF99" width="100%" height="350" valign="top">
+ <td width="8" class="LC_darker"> </td>
+ <td class="LC_lighter" width="100%" height="350" valign="top">
END_OF_BOX
}
@@ -1348,11 +1746,11 @@
my ($r,$page,$year,$event,$returnpage,$sponsors,$sponsorinfo,$domain) = @_;
$r->print(<<"START_OF_FOOT");
</td>
- <td bgcolor="#FFFF99" width="8"> </td>
- <td width="8" bgcolor="#CC6633"> </td>
+ <td width="8" class="LC_lighter"> </td>
+ <td width="8" class="LC_darker"> </td>
</tr>
<tr>
- <td colspan="4" height="4" bgcolor="#CC6633"> </td>
+ <td colspan="4" height="4" class="LC_darker"> </td>
</tr>
</table>
</td>
@@ -1444,7 +1842,7 @@
my $URL="https://ntweb1.ais.msu.edu/fsra/AppLogin.Asp";
my $request = HTTP::Request->new(POST => $URL);
$request->content_type('application/x-www-form-urlencoded');
- $request->content('AuthenticationMethod=MSU Net&AlternateID=itds0000&EncryptedStamp='.$stamp.'&'.$pname.'=&App=');
+ $request->content('AuthenticationMethod=MSU Net&AlternateID=itds0000&EncryptedStamp='.$stamp.'&'.$pname.'=&App=');
$request->header('referer' => 'https://ntweb1.ais.msu.edu/fsra/AppLogin.Asp');
my $res = $ua->request($request);
--raeburn1174515453--