From 5ca11ae362388676f7fcb1880b0fde02ccaa755a Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 21 Jan 2007 01:40:46 +0000 Subject: [PATCH] - Properly copy the config type in the config editor when copying -1 config values into the current year - Add 2 new config options. - 'participant_student_tshirt_cost' allows the cost of each fair tshirt to be set (vancouver charges $10 for tshirts, because not all students want them), this also adds a 'none' option to the tshirt selection box, and a note indicating the tshirt cost if the costs is nonzero. - 'regfee_show_info' adds a "Registration Fee Information" to the main student registration page, showing a breakdown of the registration fee computation (including tshirts, per_student and per_project registration, and indicates the total. - Convert the tshirt field to VARCHAR(32) instead of enum so the "none" option described above works, also, some fairs may want to add more optoins, like female/male sizes.. so turn this into a text field for those fairs. The next step would be to make a config option for the tshirt options. :) --- config/variables.php | 4 ++- config_editor.inc.php | 13 ++++----- db/db.code.version.txt | 2 +- db/db.update.38.sql | 6 +++++ register_participants_main.php | 42 ++++++++++++++++++++++++++++++ register_participants_students.php | 11 +++++++- 6 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 db/db.update.38.sql diff --git a/config/variables.php b/config/variables.php index 5ad7d5d9..130d85b9 100644 --- a/config/variables.php +++ b/config/variables.php @@ -31,10 +31,12 @@ $q=mysql_query("SELECT * FROM config WHERE year='-1'"); while($r=mysql_fetch_object($q)) { - mysql_query("INSERT INTO config (var,val,category,ord,description,year) VALUES ( + mysql_query("INSERT INTO config (var,val,category,type,type_values,ord,description,year) VALUES ( '".mysql_escape_string($r->var)."', '".mysql_escape_string($r->val)."', '".mysql_escape_string($r->category)."', + '".mysql_escape_string($r->type)."', + '".mysql_escape_string($r->type_values)."', '".mysql_escape_string($r->ord)."', '".mysql_escape_string($r->description)."', '".$config['FAIRYEAR']."')"); diff --git a/config_editor.inc.php b/config_editor.inc.php index 3fe21c19..b665b3b5 100644 --- a/config_editor.inc.php +++ b/config_editor.inc.php @@ -65,15 +65,16 @@ function config_editor_require_vars($category, $year, $varlist) if(mysql_num_rows($q) != 1) { /* Insert a dummy */ mysql_query("INSERT INTO `config` (`var`, `val`, - `description`, `category`, `year`, `ord`) - VALUES ('$v', '', '', - '$category', $year, 99999)"); + `description`, `category`, `type`, `type_values`, + `year`, `ord`) VALUES ('$v', '', '', + '$category', 'text', '', $year, 99999)"); } else { $r = mysql_fetch_object($q); mysql_query("INSERT INTO `config` (`var`, `val`, - `description`, `category`, `year`, `ord`) - VALUES ('$v', '{$r->val}', '{$r->description}', - '$category', '$year', {$r->ord})"); + `description`, `category`, `type`, `type_values`, + `year`, `ord`) VALUES ('$v', '{$r->val}', + '{$r->description}', '{$r->category}', '{$r->type}', + '{$r->type_values}', '$year', {$r->ord})"); } } } diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 81b5c5d0..e522732c 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -37 +38 diff --git a/db/db.update.38.sql b/db/db.update.38.sql new file mode 100644 index 00000000..62b4ce7f --- /dev/null +++ b/db/db.update.38.sql @@ -0,0 +1,6 @@ + +INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) VALUES ( 'participant_student_tshirt_cost', '0.00', 'Participant Registration', 'number', '', '1310', 'The cost of each T-Shirt. If this is non-zero, a "None" option is added to the T-Shirt size selection box, and a note is added indicating the cost of each T-Shirt', '-1'); + +INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) VALUES ( 'regfee_show_info', 'no', 'Participant Registration', 'yesno', '', '410', 'Show a breakdown of the total Registration Fee calculation on the main student registration page', '-1'); + +ALTER TABLE `students` CHANGE `tshirt` `tshirt` VARCHAR( 32 ) NOT NULL DEFAULT 'medium'; diff --git a/register_participants_main.php b/register_participants_main.php index 581aec17..1d639e30 100644 --- a/register_participants_main.php +++ b/register_participants_main.php @@ -292,6 +292,48 @@ echo "
"; echo "
"; echo "

"; + function regfee_line($item, $unit, $qty, $tot) + { + echo "".i18n($item).""; + echo "($".sprintf("%.02f", $unit).""; + echo "* $qty)"; + echo "$".sprintf("%.02f", $tot).""; + echo ""; + } + if($config['regfee_show_info']) { + 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 ""; + 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']; + } + + if($config['participant_student_tshirt'] == 'yes') { + $tsc = floatval($config['participant_student_tshirt_cost']); + if($tsc != 0.0) { + $f = $n_tshirts * $tsc; + $regfee += $f; + regfee_line("T-Shirts", $tsc, $n_tshirts, $f); + } + } + echo ""; + echo "
".i18n("Total (inlcuding all taxes)")."$".sprintf("%.02f", $regfee)."

"; +} + echo "

".i18n("Registration Instructions")."

"; //now get the text of special instructions for the bottom of this page: diff --git a/register_participants_students.php b/register_participants_students.php index a8525e43..aaeb4a49 100644 --- a/register_participants_students.php +++ b/register_participants_students.php @@ -345,9 +345,15 @@ else if($config['participant_student_tshirt']=="yes") { + + $tshirt_cost = floatval($config['participant_student_tshirt_cost']); echo "\n"; - echo " ".i18n("T-Shirt Size").""; + echo " ".i18n("T-Shirt Size").""; echo " "; + if($tshirt_cost != 0.0) { + printf(" The cost of each T-Shirt is $%.2f", $tshirt_cost); + } echo "\n"; echo ""; }