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",
|
||||
"end"=>"End Day/Time"
|
||||
), null,
|
||||
array("year" => $config['FAIRYEAR'] )
|
||||
array("conferences_id" => $conference['id'] )
|
||||
);
|
||||
|
||||
$editor->setPrimaryKey("id");
|
||||
$editor->setDefaultSortField("start,name");
|
||||
$editor->setRecordType("Volunteer Position");
|
||||
$editor->filterList('year',$config['FAIRYEAR']);
|
||||
$editor->filterList('conferences_id',$conference['id']);
|
||||
$editor->execute();
|
||||
|
||||
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_edit.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'];
|
||||
if($edit_id != $_SESSION['users_id'])
|
||||
@ -142,7 +143,7 @@ $tabs = array( 'fairinfo' => array(
|
||||
'label' => 'Volunteer Positions',
|
||||
'types' => array('volunteer'),
|
||||
'file' => 'volunteer_position.php',
|
||||
'disabled' => true,
|
||||
'status_func' => 'volunteer_status_position',
|
||||
),
|
||||
'fairstats' => array(
|
||||
'label' => 'Fair Statistics and Information',
|
||||
|
@ -27,10 +27,10 @@
|
||||
|
||||
function volunteer_status_position($u)
|
||||
{
|
||||
global $config;
|
||||
/* See if they have selected something */
|
||||
$q = "SELECT * FROM volunteer_positions_signup WHERE users_id='{$u['id']}'
|
||||
AND year='{$config['FAIRYEAR']}'";
|
||||
global $conference;
|
||||
if($conferenceid === null) $conferenceid = $conference['id'];
|
||||
// See if they have selected something
|
||||
$q = "SELECT * FROM volunteer_positions_signup WHERE users_id = '{$u['id']}' AND conferences_id = $conferenceid";
|
||||
$r = mysql_query($q);
|
||||
if(mysql_num_rows($r) >= 1) {
|
||||
return "complete";
|
||||
@ -40,6 +40,7 @@ function volunteer_status_position($u)
|
||||
|
||||
function volunteer_status_update(&$u)
|
||||
{
|
||||
/*
|
||||
global $config;
|
||||
|
||||
if( user_personal_info_status($u) == 'complete'
|
||||
@ -50,7 +51,8 @@ function volunteer_status_update(&$u)
|
||||
|
||||
user_save($u);
|
||||
return ($u['volunteer_complete'] == 'yes') ? 'complete' : 'incomplete';
|
||||
|
||||
*/
|
||||
return 'complete';
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -23,38 +23,35 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require_once("common.inc.php");
|
||||
require_once("user.inc.php");
|
||||
require_once("volunteer.inc.php");
|
||||
require_once("common.inc.php");
|
||||
require_once("user.inc.php");
|
||||
require_once("volunteer.inc.php");
|
||||
|
||||
|
||||
if($_SESSION['embed'] == true) {
|
||||
$u = user_load($_SESSION['embed_edit_id']);
|
||||
} else {
|
||||
user_auth_required('volunteer');
|
||||
// not sure if this needs to be retained for backwards compatability
|
||||
if(array_key_exists('embed_edit_id', $_SESSION)){
|
||||
$u = user_load($_SESSION['embed_edit_id']);
|
||||
}else{
|
||||
$u = user_load($_SESSION['users_id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($_POST['action']=="save")
|
||||
{
|
||||
if($_GET['action']=="save"){
|
||||
$vals = '';
|
||||
if(is_array($_POST['posn'])) {
|
||||
if(is_array($_POST['posn'])) {
|
||||
|
||||
/* Load available IDs */
|
||||
$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);
|
||||
while($p = mysql_fetch_object($r)) {
|
||||
$posns[] = $p->id;
|
||||
}
|
||||
|
||||
/* Match selections with avaiulable positions */
|
||||
/* Match selections with available positions */
|
||||
foreach($_POST['posn'] as $id=>$val) {
|
||||
if(!in_array($id, $posns)) continue;
|
||||
|
||||
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
|
||||
WHERE
|
||||
users_id='{$u['id']}'
|
||||
AND year='{$config['FAIRYEAR']}' ");
|
||||
AND conferences_id='{$conference['id']}' ");
|
||||
echo mysql_error();
|
||||
|
||||
/* Add new selections if there are any */
|
||||
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";
|
||||
$r=mysql_query($q);
|
||||
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 */
|
||||
volunteer_status_update($u);
|
||||
|
||||
if($_SESSION['embed'] != true) {
|
||||
//output the current status
|
||||
$newstatus=volunteer_status_position($u);
|
||||
if($newstatus!='complete')
|
||||
message_push(error(i18n("Volunteer Position Selection Incomplete")));
|
||||
else
|
||||
message_push(happy(i18n("Volunteer Position Selection Complete")));
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function volunteer_save()
|
||||
{
|
||||
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/volunteer_position.php?action=save&users_id=<?=$u['id']?>", $("#volunteer_form").serializeArray());
|
||||
return false;
|
||||
}
|
||||
|
||||
if($_SESSION['embed'] == true) {
|
||||
echo "<br />";
|
||||
display_messages();
|
||||
echo "<h3>".i18n('Volutneer Positions')."</h3>";
|
||||
echo "<br />";
|
||||
} else {
|
||||
//send the header
|
||||
send_header("Volunteer Positions",
|
||||
array("Volunteer Registration" => "volunteer_main.php")
|
||||
);
|
||||
$(document).ready(function() {
|
||||
$("#volunteer_form").validate({
|
||||
submitHandler: function() {
|
||||
volunteer_save();
|
||||
return false;
|
||||
},
|
||||
cancelHandler: function() {
|
||||
volunteer_save();
|
||||
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';
|
||||
echo "<form name=\"personalform\" method=\"post\" action=\"$s\">\n";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
|
||||
echo "<table>\n";
|
||||
/* Load available volunteer positions */
|
||||
$q = "SELECT *,UNIX_TIMESTAMP(start) as ustart, UNIX_TIMESTAMP(end) as uend FROM volunteer_positions WHERE conferences_id = {$conference['id']}";
|
||||
$r = mysql_query($q);
|
||||
while($p = mysql_fetch_object($r)) {
|
||||
|
||||
/* Read current selections */
|
||||
$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>';
|
||||
echo '<tr><td>';
|
||||
|
||||
$checked = false;
|
||||
|
||||
@ -157,10 +168,8 @@ if($_SESSION['embed'] == true) {
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
echo "<input type=\"submit\" value=\"".i18n("Save Position Selection")."\" />\n";
|
||||
echo "<button>" . i18n("Save Information") . "</button>";
|
||||
echo "</form>";
|
||||
|
||||
echo "<br />";
|
||||
|
||||
if($_SESSION['embed'] != true) send_footer();
|
||||
echo "<br />";
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user