forked from science-ation/science-ation
- Add a registration fee item editor
- Allow students to choose items from the optional registration items
This commit is contained in:
parent
4357280ffb
commit
735e5e0999
@ -49,6 +49,9 @@ if($config['tours_enable'] == 'yes') {
|
||||
echo "<a href=\"tours.php\">".i18n("Tour Management")."</a> <br />";
|
||||
}
|
||||
echo "<a href=\"documents.php\">".i18n("Internal Document Management")."</a> <br />";
|
||||
if($config['participant_regfee_items_enable'] == 'yes') {
|
||||
echo "<a href=\"regfee_items_manager.php\">".i18n("Registration Fee Items Management")."</a> <br />";
|
||||
}
|
||||
echo "<hr />";
|
||||
echo "<a href=\"winners.php\">".i18n("Enter Winning Projects")."</a> <br />";
|
||||
echo "<a href=\"cwsfregister.php\">".i18n("One-Click CWSF Registration")."</a> <br />";
|
||||
|
54
admin/regfee_items_manager.php
Normal file
54
admin/regfee_items_manager.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2007 James Grant <james@lightbox.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation, version 2.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
require("../tableeditor.class.php");
|
||||
require_once("../user.inc.php");
|
||||
|
||||
user_auth_required('committee', 'admin');
|
||||
send_header("Registration Fee Items Manager",
|
||||
array('Committee Main' => 'committee_main.php',
|
||||
'Administration' => 'admin/index.php')
|
||||
);
|
||||
|
||||
$editor=new TableEditor("regfee_items",
|
||||
array( 'name' => 'Name (for regfee line)',
|
||||
'description' => 'Description',
|
||||
'cost' => 'Cost',
|
||||
'per' => 'Cost Per',
|
||||
), null,
|
||||
array('year' => $config['FAIRYEAR'])
|
||||
);
|
||||
|
||||
$editor->setPrimaryKey("id");
|
||||
$editor->setDefaultSortField("description");
|
||||
$editor->setRecordType("Registration Fee Item");
|
||||
$editor->setFieldOptions("per", array( array('key' => 'student', 'val' => "Student"),
|
||||
array('key' => 'project', 'val' => "Project")
|
||||
) );
|
||||
$editor->setFieldInputType("per", 'select');
|
||||
|
||||
$editor->execute();
|
||||
|
||||
send_footer();
|
||||
?>
|
@ -1 +1 @@
|
||||
97
|
||||
98
|
||||
|
19
db/db.update.98.sql
Normal file
19
db/db.update.98.sql
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE TABLE `regfee_items` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT ,
|
||||
`year` INT NOT NULL ,
|
||||
`name` VARCHAR( 64 ) NOT NULL ,
|
||||
`description` TEXT NOT NULL ,
|
||||
`cost` FLOAT NOT NULL ,
|
||||
`per` ENUM( 'student', 'project') NOT NULL ,
|
||||
PRIMARY KEY ( `id` )
|
||||
) ENGINE = MYISAM ;
|
||||
|
||||
CREATE TABLE `regfee_items_link` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT ,
|
||||
`students_id` INT NOT NULL ,
|
||||
`regfee_items_id` INT NOT NULL ,
|
||||
PRIMARY KEY ( `id` )
|
||||
) ENGINE = MYISAM ;
|
||||
|
||||
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year`) VALUES (
|
||||
'participant_regfee_items_enable', 'no', 'Participant Registration', 'yesno', '', '2750', 'Ask the participants for registration fee item options. Enabling this item also enables a Registration Fee Item Manager in the Administration section. Use this manager to add optional registration items (that have a fee) for a student to select.', '-1');
|
@ -427,13 +427,28 @@ function generateProjectNumber($registration_id)
|
||||
function computeRegistrationFee($regid)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$ret = array();
|
||||
|
||||
$regfee_items = array();
|
||||
$q = mysql_query("SELECT * FROM regfee_items
|
||||
WHERE year='{$config['FAIRYEAR']}'");
|
||||
while($i = mysql_fetch_assoc($q)) $regfee_items[] = $i;
|
||||
|
||||
$q=mysql_query("SELECT * FROM students WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
|
||||
$n_students = mysql_num_rows($q);
|
||||
$n_tshirts = 0;
|
||||
$sel = array();
|
||||
while($s = mysql_fetch_object($q)) {
|
||||
if($s->tshirt != 'none') $n_tshirts++;
|
||||
|
||||
/* Check their regfee items too */
|
||||
if($config['participant_regfee_items_enable'] != 'yes') continue;
|
||||
|
||||
$sel_q = mysql_query("SELECT * FROM regfee_items_link
|
||||
WHERE students_id={$s->id}");
|
||||
while($info_q = mysql_fetch_assoc($sel_q)) {
|
||||
$sel[] = $info_q['regfee_items_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if($config['regfee_per'] == 'student') {
|
||||
@ -467,6 +482,29 @@ function computeRegistrationFee($regid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* $sel will be empty if regfee_items is disabled */
|
||||
foreach($regfee_items as $rfi) {
|
||||
$cnt = 0;
|
||||
foreach($sel as $s) if($rfi['id'] == $s) $cnt++;
|
||||
|
||||
if($cnt == 0) continue;
|
||||
|
||||
$tsc = floatval($rfi['cost']);
|
||||
|
||||
/* If it's per project, force the count to 1 */
|
||||
if($rfi['per'] == 'project') {
|
||||
$cnt = 1;
|
||||
}
|
||||
|
||||
$f = $tsc * $cnt;
|
||||
$ret[] = array( 'id' => "regfee_item_{$rfi['id']}",
|
||||
'text' => "{$rfi['name']} (per {$rfi['per']})" ,
|
||||
'base' => $tsc,
|
||||
'num' => $cnt,
|
||||
'ext' => $f);
|
||||
$regfee += $f;
|
||||
}
|
||||
return array($regfee, $ret);
|
||||
}
|
||||
|
||||
|
@ -342,6 +342,7 @@ echo "<table><tr><td>";
|
||||
$extra_after = "";
|
||||
echo "<table>";
|
||||
foreach($rfeedata as $rf) {
|
||||
$ex = '';
|
||||
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";
|
||||
|
@ -58,9 +58,16 @@ echo mysql_error();
|
||||
echo "<a href=\"register_participants_main.php\"><< ".i18n("Back to Participant Registration Summary")."</a><br />";
|
||||
echo "<br />";
|
||||
|
||||
$regfee_items = array();
|
||||
$items_q = mysql_query("SELECT * FROM regfee_items
|
||||
WHERE year='{$config['FAIRYEAR']}'");
|
||||
while($items_i = mysql_fetch_assoc($items_q)) {
|
||||
$regfee_items[] = $items_i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//now do any data saves
|
||||
|
||||
if($_POST['action']=="save")
|
||||
{
|
||||
if(registrationFormsReceived())
|
||||
@ -76,7 +83,8 @@ if($_POST['action']=="save")
|
||||
$x=1;
|
||||
while($_POST["num"][$x])
|
||||
{
|
||||
if($_POST['id'][$x]==0)
|
||||
$students_id = intval($_POST['id'][$x]);
|
||||
if($students_id==0)
|
||||
{
|
||||
//if they use schoolpassword or singlepassword, then we need to set the school based on the school stored in the registration record. for anything else they can school the school on their own.
|
||||
if($config['participant_registration_type']=="schoolpassword" || $config['participant_registration_type']=="invite")
|
||||
@ -114,7 +122,8 @@ if($_POST['action']=="save")
|
||||
"'".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ".
|
||||
"'".mysql_escape_string(stripslashes($_POST['teacheremail'][$x]))."', ".
|
||||
"'".$config['FAIRYEAR']."')");
|
||||
|
||||
$students_id = mysql_insert_id();
|
||||
|
||||
echo notice(i18n("%1 %2 successfully added",array($_POST['firstname'][$x],$_POST['lastname'][$x])));
|
||||
|
||||
}
|
||||
@ -153,10 +162,21 @@ if($_POST['action']=="save")
|
||||
"teachername='".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ".
|
||||
"teacheremail='".mysql_escape_string(stripslashes($_POST['teacheremail'][$x]))."', ".
|
||||
"tshirt='".mysql_escape_string(stripslashes($_POST['tshirt'][$x]))."' ".
|
||||
"WHERE id='".$_POST['id'][$x]."'");
|
||||
"WHERE id='$students_id'");
|
||||
echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x])));
|
||||
|
||||
}
|
||||
/* Update the regfee items link */
|
||||
if($config['participant_regfee_items_enable'] == 'yes') {
|
||||
mysql_query("DELETE FROM regfee_items_link WHERE students_id='$students_id'");
|
||||
|
||||
if(is_array($_POST['regfee_item'][$x])) {
|
||||
foreach($_POST['regfee_item'][$x] as $id=>$enabled) {
|
||||
mysql_query("INSERT INTO regfee_items_link(`students_id`,`regfee_items_id`)
|
||||
VALUES ('$students_id','$id') ");
|
||||
}
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
@ -170,19 +190,22 @@ if($_GET['action']=="removestudent")
|
||||
}
|
||||
else
|
||||
{
|
||||
$students_id = intval($_GET['removestudent']);
|
||||
//first make sure this is one belonging to this registration id
|
||||
$q=mysql_query("SELECT id FROM students WHERE id='".$_GET['removestudent']."' AND registrations_id='".$_SESSION['registration_id']."'");
|
||||
$q=mysql_query("SELECT id FROM students WHERE id='$students_id' AND registrations_id='".$_SESSION['registration_id']."'");
|
||||
if(mysql_num_rows($q)==1)
|
||||
{
|
||||
mysql_query("DELETE FROM students WHERE id='".$_GET['removestudent']."' AND registrations_id='".$_SESSION['registration_id']."'");
|
||||
mysql_query("DELETE FROM students WHERE id='$students_id' AND registrations_id='".$_SESSION['registration_id']."'");
|
||||
|
||||
//now see if they have an emergency contact that also needs to be removed
|
||||
|
||||
$q=mysql_query("SELECT id FROM emergencycontact WHERE students_id='".$_GET['removestudent']."' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
$q=mysql_query("SELECT id FROM emergencycontact WHERE students_id='$students_id' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
//no need to error message if this doesnt exist
|
||||
if(mysql_num_rows($q)==1)
|
||||
mysql_query("DELETE FROM emergencycontact WHERE students_id='".$_GET['removestudent']."' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
mysql_query("DELETE FROM emergencycontact WHERE students_id='$students_id' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
|
||||
|
||||
mysql_query("DELETE FROM regfee_items_link WHERE students_id='$students_id'");
|
||||
|
||||
echo notice(i18n("Student successfully removed"));
|
||||
}
|
||||
else
|
||||
@ -426,11 +449,26 @@ if($config['participant_student_personal']=="yes")
|
||||
echo " <td>".i18n("Teacher Email")."</td><td><input type=\"text\" name=\"teacheremail[$x]\" value=\"$studentinfo->teacheremail\" /></td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
|
||||
|
||||
|
||||
if($config['participant_regfee_items_enable'] == 'yes' ) {
|
||||
$sel_q = mysql_query("SELECT * FROM regfee_items_link
|
||||
WHERE students_id=$id");
|
||||
$sel = array();
|
||||
while($info_q = mysql_fetch_assoc($sel_q)) {
|
||||
$sel[$info_q['regfee_items_id']] = $info_q['id'];
|
||||
}
|
||||
foreach($regfee_items as $rfi) {
|
||||
echo "<tr><td align=\"right\">\n";
|
||||
$checked = array_key_exists($rfi['id'], $sel) ? 'checked="checked"' : '';
|
||||
echo "<input type=\"checkbox\" name=\"regfee_item[$x][{$rfi['id']}]\" $checked />";
|
||||
echo '</td><td colspan=\"2\">';
|
||||
echo i18n($rfi['description']);
|
||||
echo '</td></tr>';
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
|
||||
|
||||
if($numfound>$config['minstudentsperproject'] && $studentinfo->id)
|
||||
{
|
||||
echo "<div align=\"right\"><a onclick=\"return confirmClick('".i18n("Are you sure you want to remove this student from the project?")."');\" class=\"caution\" href=\"register_participants_students.php?action=removestudent&removestudent=$studentinfo->id\">".i18n("Remove this student from project")."</a></div>";
|
||||
|
Loading…
Reference in New Issue
Block a user