From 57ff84c56344826b89605eba6c44ce429f3fc0bc Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 12 Mar 2007 02:05:40 +0000 Subject: [PATCH] - Move registration fee computation into the include file - Add the required registration fee to the received forms checkoff, so the amount of the cheque can ben checked too. --- admin/registration_receivedforms.php | 2 ++ register_participants.inc.php | 48 ++++++++++++++++++++++++++++ register_participants_main.php | 37 +++++---------------- 3 files changed, 58 insertions(+), 29 deletions(-) diff --git a/admin/registration_receivedforms.php b/admin/registration_receivedforms.php index 4e2ae45..bab52c6 100644 --- a/admin/registration_receivedforms.php +++ b/admin/registration_receivedforms.php @@ -117,6 +117,8 @@ echo mysql_Error(); $studnum++; } + list($regfee,$regfeedata) = computeRegistrationFee($reg_id); + echo "".i18n("Registration Fee")."".sprintf("$%.02f", $regfee).""; echo "\n"; echo "
"; diff --git a/register_participants.inc.php b/register_participants.inc.php index 227a104..317d6c1 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -327,4 +327,52 @@ function generateProjectNumber($registration_id) return $projectnumber; } +function computeRegistrationFee($regid) +{ + global $config; + + $ret = array(); + $q=mysql_query("SELECT * FROM students WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'"); + $n_students = mysql_num_rows($q); + $n_tshirts = 0; + while($s = mysql_fetch_object($q)) { + if($s->tshirt != 'none') $n_tshirts++; + } + + if($config['regfee_per'] == 'student') { + $f = $config['regfee'] * $n_students; + $ret[] = array( 'id' => 'regfee', + 'text' => "Fair Registration (per student)", + 'base' => $config['regfee'], + 'num' => $n_students, + 'ext' => $f ); + $regfee += $f; + } else { + $ret[] = array( 'id' => 'regfee', + 'text' => "Fair Registration (per project)", + 'base' => $config['regfee'], + 'num' => 1, + 'ext' => $config['regfee'] ); + $regfee += $config['regfee']; + } + + if($config['participant_student_tshirt'] == 'yes') { + $tsc = floatval($config['participant_student_tshirt_cost']); + if($tsc != 0.0) { + $f = $n_tshirts * $tsc; + $regfee += $f; + if($n_tshirts != 0) { + $ret[] = array( 'id' => 'tshirt', + 'text' => "T-Shirts", + 'base' => $tsc, + 'num' => $n_tshirts, + 'ext' => $f); + } + } + } + return array($regfee, $ret); +} + + + ?> diff --git a/register_participants_main.php b/register_participants_main.php index 6c66be1..087bdbe 100644 --- a/register_participants_main.php +++ b/register_participants_main.php @@ -320,42 +320,21 @@ echo ""; echo ""; } + if($config['regfee_show_info'] == 'yes') { echo "

".i18n("Registration Fee Information")."

"; - $regfee = 0; - - $q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); - $n_students = mysql_num_rows($q); - $n_tshirts = 0; - while($s = mysql_fetch_object($q)) { - if($s->tshirt != 'none') $n_tshirts++; - } - - echo "
"; echo "".i18n($extra)."
"; - if($config['regfee_per'] == 'student') { - $f = $config['regfee'] * $n_students; - regfee_line("Fair Registration (per student)", $config['regfee'], $n_students, $f, ''); - $regfee += $f; - } else { - regfee_line("Fair Registration (per project)", $config['regfee'], 1, $config['regfee'], ''); - $regfee += $config['regfee']; - } + list($regfee, $rfeedata) = computeRegistrationFee($_SESSION['registration_id']); $extra_after = ""; - if($config['participant_student_tshirt'] == 'yes') { - $tsc = floatval($config['participant_student_tshirt_cost']); - if($tsc != 0.0) { - $f = $n_tshirts * $tsc; - $regfee += $f; - - if($n_tshirts != 0) { - $ex = "*"; - $extra_after = "* If you do not wish to order a T-Shirt, please select your T-Shirt size as 'None' on the Student Information Page"; - regfee_line("T-Shirts", $tsc, $n_tshirts, $f, $ex); - } + echo "
"; + foreach($rfeedata as $rf) { + if($rf['id'] == "tshirt") { + $ex = "*"; + $extra_after = "* If you do not wish to order a T-Shirt, please select your T-Shirt size as 'None' on the Student Information Page"; } + regfee_line($rf['text'],$rf['base'],$rf['num'],$rf['ext'],$ex); } echo ""; echo "
".i18n("Total (including all taxes)")."$".sprintf("%.02f", $regfee)."

";