science-ation/admin/registration_webconsent.php
2025-02-10 19:54:20 +00:00

128 lines
4.0 KiB
PHP

<?
/*
* This file is part of the 'Science Fair In A Box' project
* Science-ation Website: https://science-ation.ca/
*
* Copyright (C) 2005-2006 Sci-Tech Ontario Inc <info@scitechontario.org>
* Copyright (C) 2005-2006 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_once('../user.inc.php');
user_auth_required('committee', 'admin');
send_header(
'Web Consent',
array(
'Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Participant Registration' => 'admin/registration.php'
)
);
echo '<br />';
if (get_value_from_array($_POST, 'changed')) {
$numchanged = 0;
foreach ($_POST['changed'] as $id => $val) {
if ($val == 1) {
$numchanged++;
$webfirst = get_value_from_2d_array($_POST, 'webfirst', $id) == 'yes' ? 'yes' : 'no';
$weblast = get_value_from_2d_array($_POST, 'weblast', $id) == 'yes' ? 'yes' : 'no';
$webphoto = get_value_from_2d_array($_POST, 'webphoto', $id) == 'yes' ? 'yes' : 'no';
$stmt = $pdo->prepare("UPDATE students SET
webfirst='$webfirst',
weblast='$weblast',
webphoto='$webphoto'
WHERE
id='$id'");
$stmt->execute();
}
}
if ($numchanged == 1) {
echo happy(i18n('1 student record updated'));
} else if ($numchanged > 1) {
echo happy(i18n('%1 student records updated', array($numchanged)));
} else {
echo error(i18n('No student records where changed'));
}
}
?>
<script type="text/javascript">
function changed(id) {
var o = document.getElementById('changed_' + id);
o.value = 1;
}
</script>
<?
$sq = $pdo->prepare("SELECT students.firstname,
students.lastname,
students.id,
projects.projectnumber,
students.webfirst,
students.weblast,
students.webphoto
FROM
students,
registrations,
projects
WHERE
students.registrations_id=registrations.id
AND\t( registrations.status = 'complete' OR registrations.status='paymentpending' )
AND\tprojects.registrations_id=registrations.id
AND \tregistrations.year='" . $config['FAIRYEAR'] . "'
AND \tprojects.year='" . $config['FAIRYEAR'] . "'
AND \tstudents.year='" . $config['FAIRYEAR'] . "'
ORDER BY projectnumber
");
$sq->execute();
show_pdo_errors_if_any($pdo);
echo '<form method="post" action="registration_webconsent.php">';
echo '<table class="tableview">';
echo '<thead><tr>';
echo ' <th>' . i18n('Proj #') . '</th>';
echo ' <th>' . i18n('Student Name') . '</th>';
echo ' <th>' . i18n('First') . '</th>';
echo ' <th>' . i18n('Last') . '</th>';
echo ' <th>' . i18n('Photo') . '</th>';
echo '</tr></thead>';
while ($r = $sq->fetch(PDO::FETCH_OBJ)) {
echo '<tr>';
echo "<td>$r->projectnumber<input id=\"changed_$r->id\" type=\"hidden\" name=\"changed[$r->id]\" value=\"0\"></td>";
echo "<td>$r->firstname $r->lastname</td>";
$ch = $r->webfirst == 'yes' ? 'checked="checked"' : '';
echo "<td><input $ch type=\"checkbox\" name=\"webfirst[$r->id]\" value=\"yes\" onchange=\"changed($r->id)\"></td>";
$ch = $r->weblast == 'yes' ? 'checked="checked"' : '';
echo "<td><input $ch type=\"checkbox\" name=\"weblast[$r->id]\" value=\"yes\" onchange=\"changed($r->id)\"></td>";
$ch = $r->webphoto == 'yes' ? 'checked="checked"' : '';
echo "<td><input $ch type=\"checkbox\" name=\"webphoto[$r->id]\" value=\"yes\" onchange=\"changed($r->id)\"></td>";
echo '</tr>';
}
echo '</table>';
echo '<input type="submit" value="' . i18n('Save Changes') . '">';
echo '</form>';
send_footer();
?>