forked from science-ation/science-ation
Updated volunteer preferences to work with the new interface and with the new conference id system
This commit is contained in:
parent
9229b1665b
commit
8e4306ae3b
@ -41,13 +41,13 @@
|
|||||||
"start"=>"Start Day/Time",
|
"start"=>"Start Day/Time",
|
||||||
"end"=>"End Day/Time"
|
"end"=>"End Day/Time"
|
||||||
), null,
|
), null,
|
||||||
array("year" => $config['FAIRYEAR'] )
|
array("conferences_id" => $conference['id'] )
|
||||||
);
|
);
|
||||||
|
|
||||||
$editor->setPrimaryKey("id");
|
$editor->setPrimaryKey("id");
|
||||||
$editor->setDefaultSortField("start,name");
|
$editor->setDefaultSortField("start,name");
|
||||||
$editor->setRecordType("Volunteer Position");
|
$editor->setRecordType("Volunteer Position");
|
||||||
$editor->filterList('year',$config['FAIRYEAR']);
|
$editor->filterList('conferences_id',$conference['id']);
|
||||||
$editor->execute();
|
$editor->execute();
|
||||||
|
|
||||||
send_footer();
|
send_footer();
|
||||||
|
@ -1 +1 @@
|
|||||||
211
|
212
|
||||||
|
36
db/db.update.212.php
Normal file
36
db/db.update.212.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?
|
||||||
|
function db_update_212_pre()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function db_update_212_post()
|
||||||
|
{
|
||||||
|
$tables=array("volunteer_positions_signup", "volunteer_positions");
|
||||||
|
|
||||||
|
// add the conferences_id field
|
||||||
|
foreach($tables as $tableName){
|
||||||
|
$query = "ALTER TABLE `$tableName` ADD `conferences_id` INT NOT NULL";
|
||||||
|
mysql_query($query);
|
||||||
|
echo $query . ";\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the year => conference_id links
|
||||||
|
$q1 = mysql_query("SELECT year, id FROM conferences WHERE year > 0");
|
||||||
|
|
||||||
|
//update the tables
|
||||||
|
while($r = mysql_fetch_assoc($q1)){
|
||||||
|
foreach($tables as $tableName){
|
||||||
|
$query = "UPDATE `$tableName` SET `conferences_id` = {$r['id']} WHERE `year` = {$r['year']}";
|
||||||
|
mysql_query($query);
|
||||||
|
echo $query . ";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the conferences_id field
|
||||||
|
foreach($tables as $tableName){
|
||||||
|
$query = "ALTER TABLE `$tableName` DROP `year`";
|
||||||
|
mysql_query($query);
|
||||||
|
echo $query . ";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -26,6 +26,7 @@ require_once('common.inc.php');
|
|||||||
require_once('user.inc.php');
|
require_once('user.inc.php');
|
||||||
require_once('user_edit.inc.php');
|
require_once('user_edit.inc.php');
|
||||||
require_once('judge.inc.php');
|
require_once('judge.inc.php');
|
||||||
|
require_once('volunteer.inc.php');
|
||||||
|
|
||||||
$edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id'];
|
$edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id'];
|
||||||
if($edit_id != $_SESSION['users_id'])
|
if($edit_id != $_SESSION['users_id'])
|
||||||
@ -142,7 +143,7 @@ $tabs = array( 'fairinfo' => array(
|
|||||||
'label' => 'Volunteer Positions',
|
'label' => 'Volunteer Positions',
|
||||||
'types' => array('volunteer'),
|
'types' => array('volunteer'),
|
||||||
'file' => 'volunteer_position.php',
|
'file' => 'volunteer_position.php',
|
||||||
'disabled' => true,
|
'status_func' => 'volunteer_status_position',
|
||||||
),
|
),
|
||||||
'fairstats' => array(
|
'fairstats' => array(
|
||||||
'label' => 'Fair Statistics and Information',
|
'label' => 'Fair Statistics and Information',
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
|
|
||||||
function volunteer_status_position($u)
|
function volunteer_status_position($u)
|
||||||
{
|
{
|
||||||
global $config;
|
global $conference;
|
||||||
/* See if they have selected something */
|
if($conferenceid === null) $conferenceid = $conference['id'];
|
||||||
$q = "SELECT * FROM volunteer_positions_signup WHERE users_id='{$u['id']}'
|
// See if they have selected something
|
||||||
AND year='{$config['FAIRYEAR']}'";
|
$q = "SELECT * FROM volunteer_positions_signup WHERE users_id = '{$u['id']}' AND conferences_id = $conferenceid";
|
||||||
$r = mysql_query($q);
|
$r = mysql_query($q);
|
||||||
if(mysql_num_rows($r) >= 1) {
|
if(mysql_num_rows($r) >= 1) {
|
||||||
return "complete";
|
return "complete";
|
||||||
@ -40,6 +40,7 @@ function volunteer_status_position($u)
|
|||||||
|
|
||||||
function volunteer_status_update(&$u)
|
function volunteer_status_update(&$u)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if( user_personal_info_status($u) == 'complete'
|
if( user_personal_info_status($u) == 'complete'
|
||||||
@ -50,7 +51,8 @@ function volunteer_status_update(&$u)
|
|||||||
|
|
||||||
user_save($u);
|
user_save($u);
|
||||||
return ($u['volunteer_complete'] == 'yes') ? 'complete' : 'incomplete';
|
return ($u['volunteer_complete'] == 'yes') ? 'complete' : 'incomplete';
|
||||||
|
*/
|
||||||
|
return 'complete';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -23,38 +23,35 @@
|
|||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<?
|
<?
|
||||||
require_once("common.inc.php");
|
require_once("common.inc.php");
|
||||||
require_once("user.inc.php");
|
require_once("user.inc.php");
|
||||||
require_once("volunteer.inc.php");
|
require_once("volunteer.inc.php");
|
||||||
|
|
||||||
|
// not sure if this needs to be retained for backwards compatability
|
||||||
if($_SESSION['embed'] == true) {
|
if(array_key_exists('embed_edit_id', $_SESSION)){
|
||||||
$u = user_load($_SESSION['embed_edit_id']);
|
$u = user_load($_SESSION['embed_edit_id']);
|
||||||
} else {
|
}else{
|
||||||
user_auth_required('volunteer');
|
|
||||||
$u = user_load($_SESSION['users_id']);
|
$u = user_load($_SESSION['users_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($_GET['action']=="save"){
|
||||||
if($_POST['action']=="save")
|
|
||||||
{
|
|
||||||
$vals = '';
|
$vals = '';
|
||||||
if(is_array($_POST['posn'])) {
|
if(is_array($_POST['posn'])) {
|
||||||
|
|
||||||
/* Load available IDs */
|
/* Load available IDs */
|
||||||
$posns = array();
|
$posns = array();
|
||||||
$q = "SELECT * FROM volunteer_positions WHERE year='{$config['FAIRYEAR']}'";
|
$q = "SELECT * FROM volunteer_positions WHERE conferences_id='{$conference['id']}'";
|
||||||
$r = mysql_query($q);
|
$r = mysql_query($q);
|
||||||
while($p = mysql_fetch_object($r)) {
|
while($p = mysql_fetch_object($r)) {
|
||||||
$posns[] = $p->id;
|
$posns[] = $p->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Match selections with avaiulable positions */
|
/* Match selections with available positions */
|
||||||
foreach($_POST['posn'] as $id=>$val) {
|
foreach($_POST['posn'] as $id=>$val) {
|
||||||
if(!in_array($id, $posns)) continue;
|
if(!in_array($id, $posns)) continue;
|
||||||
|
|
||||||
if($vals != '') $vals .=',';
|
if($vals != '') $vals .=',';
|
||||||
$vals .= "('{$u['id']}','$id','{$config['FAIRYEAR']}')";
|
$vals .= "('{$u['id']}','$id','{$conference['id']}')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,67 +59,81 @@
|
|||||||
mysql_query("DELETE FROM volunteer_positions_signup
|
mysql_query("DELETE FROM volunteer_positions_signup
|
||||||
WHERE
|
WHERE
|
||||||
users_id='{$u['id']}'
|
users_id='{$u['id']}'
|
||||||
AND year='{$config['FAIRYEAR']}' ");
|
AND conferences_id='{$conference['id']}' ");
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
|
|
||||||
/* Add new selections if there are any */
|
/* Add new selections if there are any */
|
||||||
if($vals != '') {
|
if($vals != '') {
|
||||||
$q = "INSERT INTO volunteer_positions_signup (users_id, volunteer_positions_id,year)
|
$q = "INSERT INTO volunteer_positions_signup (users_id, volunteer_positions_id,conferences_id)
|
||||||
VALUES $vals";
|
VALUES $vals";
|
||||||
$r=mysql_query($q);
|
$r=mysql_query($q);
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$newstatus = volunteer_status_position($u);
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
user_update_tab_status('volunteerpos','<?=$newstatus?>');
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
|
||||||
message_push(notice(i18n("Volunteer Positions successfully updated")));
|
//message_push(notice(i18n("Volunteer Positions successfully updated")));
|
||||||
}
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* update overall status */
|
/* update overall status */
|
||||||
volunteer_status_update($u);
|
volunteer_status_update($u);
|
||||||
|
|
||||||
if($_SESSION['embed'] != true) {
|
?>
|
||||||
//output the current status
|
|
||||||
$newstatus=volunteer_status_position($u);
|
<script type="text/javascript">
|
||||||
if($newstatus!='complete')
|
function volunteer_save()
|
||||||
message_push(error(i18n("Volunteer Position Selection Incomplete")));
|
{
|
||||||
else
|
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/volunteer_position.php?action=save&users_id=<?=$u['id']?>", $("#volunteer_form").serializeArray());
|
||||||
message_push(happy(i18n("Volunteer Position Selection Complete")));
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_SESSION['embed'] == true) {
|
$(document).ready(function() {
|
||||||
echo "<br />";
|
$("#volunteer_form").validate({
|
||||||
display_messages();
|
submitHandler: function() {
|
||||||
echo "<h3>".i18n('Volutneer Positions')."</h3>";
|
volunteer_save();
|
||||||
echo "<br />";
|
return false;
|
||||||
} else {
|
},
|
||||||
//send the header
|
cancelHandler: function() {
|
||||||
send_header("Volunteer Positions",
|
volunteer_save();
|
||||||
array("Volunteer Registration" => "volunteer_main.php")
|
return false;
|
||||||
);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
user_update_tab_status('volunteerpos');
|
||||||
|
|
||||||
|
// $("#volunteer_form").valid();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo "<div>";
|
||||||
|
display_messages();
|
||||||
|
echo "<h4>".i18n('Volunteer Positions')." - <span class=\"status_volunteerpos\"></span></h4>";
|
||||||
|
echo "</div>";
|
||||||
|
|
||||||
|
echo "<form id=\"volunteer_form\" class=\"editor\">\n";
|
||||||
|
echo "<table>\n";
|
||||||
|
|
||||||
|
/* Read current selections */
|
||||||
|
$checked_positions = array();
|
||||||
|
$r = mysql_query("SELECT * FROM volunteer_positions_signup WHERE users_id = '{$u['id']}' AND conferences_id='{$conference['id']}'");
|
||||||
|
while($p = mysql_fetch_object($r)) {
|
||||||
|
$checked_positions[] = $p->volunteer_positions_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$s = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'volunteer_position.php';
|
/* Load available volunteer positions */
|
||||||
echo "<form name=\"personalform\" method=\"post\" action=\"$s\">\n";
|
$q = "SELECT *,UNIX_TIMESTAMP(start) as ustart, UNIX_TIMESTAMP(end) as uend FROM volunteer_positions WHERE conferences_id = {$conference['id']}";
|
||||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
|
$r = mysql_query($q);
|
||||||
echo "<table>\n";
|
while($p = mysql_fetch_object($r)) {
|
||||||
|
|
||||||
/* Read current selections */
|
echo '<tr><td>';
|
||||||
$q = "SELECT * FROM volunteer_positions_signup WHERE
|
|
||||||
users_id = '{$u['id']}'
|
|
||||||
AND year='{$config['FAIRYEAR']}'";
|
|
||||||
$r = mysql_query($q);
|
|
||||||
$checked_positions = array();
|
|
||||||
while($p = mysql_fetch_object($r)) {
|
|
||||||
$checked_positions[] = $p->volunteer_positions_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load available volunteer positions */
|
|
||||||
$q = "SELECT *,UNIX_TIMESTAMP(start) as ustart, UNIX_TIMESTAMP(end) as uend
|
|
||||||
FROM volunteer_positions WHERE year='{$config['FAIRYEAR']}'";
|
|
||||||
$r = mysql_query($q);
|
|
||||||
while($p = mysql_fetch_object($r)) {
|
|
||||||
|
|
||||||
echo '<tr><td>';
|
|
||||||
|
|
||||||
$checked = false;
|
$checked = false;
|
||||||
|
|
||||||
@ -157,10 +168,8 @@ if($_SESSION['embed'] == true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
echo "<input type=\"submit\" value=\"".i18n("Save Position Selection")."\" />\n";
|
echo "<button>" . i18n("Save Information") . "</button>";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
|
|
||||||
if($_SESSION['embed'] != true) send_footer();
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user