Some updates on the interface for creating conferences

Modified the user object, correcting some issues with judging availability and volunteer availability.
This commit is contained in:
jacob 2010-11-16 19:53:26 +00:00
parent 7113a3df95
commit 1e2340beb1
5 changed files with 187 additions and 62 deletions

View File

@ -779,8 +779,8 @@ function projectcategories_load($conferences_id = false) {
return $cats;
}
// a convenience function for getting the available event timeslots in the given conference
function get_timeslots($conferenceId){
// a convenience function for getting the available judging timeslots in the given conference
function get_judging_timeslots($conferenceId){
$times = array();
$q = mysql_query("SELECT id,date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND conferences_id='$conferenceId' ORDER BY starttime,type");
$x = 0;

View File

@ -40,7 +40,7 @@ else
$u = user_load($edit_id);
// Load the judging rounds
$times = get_timeslots($conference['id']);
$times = get_judging_timeslots($conference['id']);
switch($_GET['action']) {
case 'save':

View File

@ -44,8 +44,8 @@ $wizard_steps = array(
'method'
),
'actions' => array(
'cancel' => i18n('Cancel'),
'next' => i18n('Next'),
'cancel' => i18n('Cancel')
)
),
'selectNameType' => array(
@ -57,9 +57,9 @@ $wizard_steps = array(
'type'
),
'actions' => array(
'back' => i18n('Back'),
'cancel' => i18n('Cancel'),
'next' => i18n('Next'),
'cancel' => i18n('Cancel')
'back' => i18n('Back'),
)
),
'selectConference' => array(
@ -72,9 +72,9 @@ $wizard_steps = array(
'rollDates'
),
'actions' => array(
'back' => i18n('Back'),
'cancel' => i18n('Cancel'),
'next' => i18n('Next'),
'cancel' => i18n('Cancel')
'back' => i18n('Back'),
)
),
'enterName' => array(
@ -85,9 +85,9 @@ $wizard_steps = array(
'name'
),
'actions' => array(
'back' => i18n('Back'),
'cancel' => i18n('Cancel'),
'next' => i18n('Next'),
'cancel' => i18n('Cancel')
'back' => i18n('Back'),
)
),
@ -97,9 +97,9 @@ $wizard_steps = array(
'handler' => 'handle_complete_step',
'fields' => array(),
'actions' => array(
'back' => i18n('Back'),
'cancel' => i18n('Cancel'),
'ok' => i18n('OK'),
'cancel' => i18n('Cancel')
'back' => i18n('Back'),
)
),
'error' => array(
@ -138,23 +138,35 @@ send_header("Conferences Setup",
);
?>
<script type="text/javascript">
var wizard;
$(document).ready(function() {
// nothin' yet
$('#wizardBackdrop').fadeTo(0, 0);
// $('#wizardBackdrop').fadeTo(0, 0);
});
function editConference(cid){
alert('edit ' + cid);
}
function dropConference(cid){
alert('drop ' + cid);
}
function openWizard(){
$('#addAnchor').hide();
/*
$('#wizardWrapper').css({'display':'block'});
$('#wizardBackdrop').css({'display':'block'});
$('#wizardBackdrop').fadeTo('slow', 0.8);
$('#wizard').load('conferences.php?action=new');
$('#wizard').show();
*/
wizard = $('<div></div>');
$('#conferences').append(wizard);
wizard.dialog();
wizard.load('conferences.php?action=new');
}
function handleSubmit(action){
var params = {'formAction' : action};
var foo = false;
for(n in fields){
// is it a checked check box?
val = $('input:checkbox[name=' + fields[n] + ']:checked').val();
@ -177,16 +189,34 @@ function handleSubmit(action){
}
// the relevant parameters have been pulled out of the form, now submit them
$.post('conferences.php', params, function(result){
$('#wizard').html(result);
wizard.html(result);
});
}
</script>
<div id="conferences">
<?php draw_conferences_list(); ?>
<br/>
<hr/>
<a id="addAnchor" href='' onclick="openWizard(); return false;">Add a conference</a>
</div>
<?
send_footer();
function draw_conferences_list(){
echo "<table>";
$query = mysql_query("SELECT * FROM `conferences`");
while($row = mysql_fetch_assoc($query)){
echo "<tr>";
echo "<td>{$row['name']}</td><td>{$row['type']}</td><td>{$row['status']}</td>";
echo "<td><button onclick=\"editConference({$row['id']});return false;\">" . i18n("Edit") . "&nbsp;<img src=\"/icons/16/edit.png\"/></button></td>";
echo "<td><button onclick=\"dropConference({$row['id']});return false;\">" . i18n("Delete") . "&nbsp;<img src=\"/icons/16/button_cancel.png\"/></button></td>";
echo "</tr>";
}
echo "</table>";
}
/*
require("../tableeditor.class.php");
$editor=new TableEditor("conferences",
@ -201,18 +231,7 @@ $editor->setPrimaryKey("id");
$editor->setDefaultSortField("id");
$editor->setRecordType("Conference");
$editor->execute();
?>
<br/>
<hr/>
<a id="addAnchor" href='' onclick="openWizard(); return false;">Add a conference</a>
</div>
<div id="wizardBackdrop"></div>
<div id="wizardWrapper">
<div id="wizard" style="position:relative"></div>
</div>
<?
send_footer();
*/
/************** Wizard handling functions *************/
// draw an individual step in the wizard
function wizard_draw_step($step, $message = null){
@ -225,10 +244,20 @@ function wizard_draw_step($step, $message = null){
}else{
echo "var fields=['formStep'];";
}
echo "</script>";
// add the appropriate buttons
echo 'wizard.dialog("option","buttons", {';
$doneone = false;
foreach($wizard_steps[$step]['actions'] as $tag => $label){
if($doneone) echo ",";
else $doneone = true;
echo '"' . $label . '":function(){handleSubmit("' . $tag . '");}';
}
echo '});';
// draw the title header
echo '<h2>' . $wizard_steps[$step]['title'] . '</h2>';
echo 'wizard.dialog("option", "title", "' . $wizard_steps[$step]['title'] . '");';
echo "</script>";
if($message != null){
// used for error messages (eg. empty field)
@ -242,13 +271,6 @@ function wizard_draw_step($step, $message = null){
}
echo "</div>";
// add the appropriate buttons at the bottom
echo "<div class=\"wizard_buttons\">"; // draw the buttons at the bottom of this step
foreach($wizard_steps[$step]['actions'] as $tag => $label){
echo "<button name=\"$tag\" onclick=\"handleSubmit('$tag');return false;\">$label</button> ";
}
echo "</div>";
echo "<input type=\"hidden\" id=\"formStep\" value=\"$step\"></input>";
}
}
@ -258,9 +280,7 @@ function wizard_close(){
unset($_SESSION['conference_wizard']);
echo "
<script type=\"text/javascript\">
$('#wizardBackdrop').css({'display':'none'}).fadeTo(0, 0);
$('#wizardWrapper').css({'display':'none'});
$('#wizard').hide().html('');
wizard.dialog('close');
$('#addAnchor').show();
</script>
";
@ -518,10 +538,18 @@ function create_conference($params){
return $conferences_id;
}
// copy users of the specified roles (passed in an array)
// copy users of the specified roles from conference oldConfId to conference newConfId
// roles can be passed as a single comma delimited string, or as an array of strings
// return 'ok' on success, error message otherwise
function conferences_copy_users($oldConfId, $newConfId, $roles){
if(!is_array($roles)) $roles = array($roles);
if(!is_array($roles)){
// they must have been passed as a string
$roles = explode(',', $roles);
foreach($roles as $idx => $val){
$roles[$idx] = trim($val);
}
}
$query = mysql_query("
SELECT * FROM users WHERE users.id IN(
SELECT DISTINCT(users.id) FROM users
@ -543,7 +571,6 @@ function conferences_copy_users($oldConfId, $newConfId, $roles){
}
$row['conferences_id'] = $newConfId;
$values = "'" . implode("','", $row) . "'";
// echo("INSERT INTO users ($keys) VALUES ($values)");
mysql_query("INSERT INTO users ($keys) VALUES ($values)");
$uid = mysql_insert_id();
$aid = $row['accounts_id'];
@ -552,6 +579,7 @@ function conferences_copy_users($oldConfId, $newConfId, $roles){
SELECT roles_id, active, complete FROM user_roles
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.`type` IN('" . implode("','", $roles) . "')
AND user_roles.users_id = $oldId
");
while(mysql_error() == '' && $row2 = mysql_fetch_assoc($q2)){
mysql_query("
@ -719,7 +747,7 @@ function copy_conference($params){
// questions
$q = mysql_query("SELECT * FROM questions WHERE conferences_id = $oldConfId");
while($r=mysql_fetch_object($q) && mysql_error() == '')
while(mysql_error() == '' && $r=mysql_fetch_object($q))
mysql_query("INSERT INTO questions (id,conferences_id,section,db_heading,question,type,required,ord) VALUES (
'',
'$newConfId',
@ -781,8 +809,7 @@ function copy_conference($params){
}
// return empty string on success, error message otherwise
function roll($oldConfId, $newConfId, $table, $where='', $replace=array())
{
function roll($oldConfId, $newConfId, $table, $where='', $replace=array()){
/* Field Type Null Key Default Extra
* id int(10) unsigned NO PRI NULL auto_increment
* sponsors_id int(10) unsigned NO MUL 0
@ -830,7 +857,7 @@ function roll($oldConfId, $newConfId, $table, $where='', $replace=array())
else
$vals .= ",'".mysql_real_escape_string($r[$f])."'";
}
mysql_query("INSERT INTO `$table`(`conferences_id`,$names) VALUES ('$newConfId'$vals)");
mysql_query("INSERT INTO `$table` (`conferences_id`, $names) VALUES ('$newConfId'$vals)");
if(mysql_error() != '') $errMessage .= mysql_error() . "<br/>";
echo mysql_error();
}

View File

@ -756,7 +756,7 @@ ul.conferencenav li a:hover {
.scheduleevent_tour {
background: #CCFFD5;
}
/*
#wizardWrapper{
display: none;
position: absolute;
@ -808,3 +808,4 @@ ul.conferencenav li a:hover {
background-color: #1B86B7;
padding: 0.25em;
}
*/

View File

@ -204,7 +204,7 @@ function user_load($users_id, $accounts_id = false)
case 'available_times':
// a rather complicated match-up, as they're linked by time values, not by record id's
$times = get_timeslots($u['conferences_id']);
$times = get_judging_timeslots($u['conferences_id']);
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id=\"{$u['id']}\"");
$sel = array();
@ -227,6 +227,42 @@ function user_load($users_id, $accounts_id = false)
}
$u['available_times'] = $items;
break;
case 'available_events':
$q1 = mysql_query("SELECT schedule_id FROM `schedule_users_availability_link` sual JOIN schedule ON schedule.id = sual.schedule_id WHERE users_id = {$u['id']} AND schedule.conferences_id = '{$u['conferences_id']}'");
$ids = array();
while($row = mysql_fetch_assoc($q1)){
$ids[] = $row['schedule_id'];
}
$q2 = mysql_query("SELECT id FROM schedule WHERE schedule.conferences_id='{$u['conferences_id']}'");
$items = array();
while($row = mysql_fetch_assoc($q2)){
if(in_array($row['id'], $ids)){
$items[$row['id']] = 'yes';
}else{
$items[$row['id']] = 'no';
}
}
$u['available_events'] = $items;
break;
case 'volunteer_positions':
$q1 = mysql_query("SELECT volunteer_positions_id AS vpid FROM volunteer_positions_signup WHERE users_id = {$u['id']} AND conferences_id = {$u['conferences_id']}");
$ids = array();
while($row = mysql_fetch_assoc($q1)){
$ids[] = $row['vpid'];
}
$q2 = mysql_query("SELECT id FROM volunteer_positions WHERE conferences_id = {$u['conferences_id']}");
$items = array();
while($row = mysql_fetch_assoc($q2)){
if(in_array($row['id'], $ids)){
$items[$row['id']] = 'yes';
}else{
$items[$row['id']] = 'no';
}
}
$u['volunteer_positions'] = $items;
break;
}
}
@ -294,7 +330,8 @@ function user_get_role_fields($role){
}
function user_get_field_info(){
return array(
global $conference;
$returnval = array(
'salutation' => array('label' => 'Salutation', 'group' => 'Personal Information'),
'firstname' => array('label' => 'First Name', 'group' => 'Personal Information'),
'lastname' => array('label' => 'Last Name', 'group' => 'Personal Information'),
@ -329,11 +366,22 @@ function user_get_field_info(){
'primary' => array('label' => 'Primary Contact', 'group' => 'Sponsors'),
'position' => array('label' => 'Position', 'group' => 'Sponsors'),
'notes' => array('label' => 'Notes', 'group' => 'Sponsors'),
'schools_id' => array('label' => 'School', 'group' => 'Personal'),
'schools_id' => array('label' => 'School', 'group' => 'Personal Information'),
'grade' => array('label' => 'Grade', 'group' => 'Personal Information'),
'special_awards' => array('label' => 'Special Awards', 'group' => 'Judges'),
'available_times' => array('label' => 'Times Available', 'group' => 'Judges,Volunteers')
'volunteer_positions' => array('label' => 'Volunteer Positions', 'group' => 'Volunteers')
);
switch($conference['type']){
case 'sciencefair':
$returnval['available_times'] = array('label' => 'Times Available', 'group' => 'Judges');
$returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Volunteers');
break;
case 'scienceolympics':
$returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Judges,Volunteers');
break;
}
return $returnval;
}
function user_role_field_required($role, $fieldname){
@ -505,16 +553,33 @@ function user_get_fields($userRoles = null){
}
/******* Now we add fields that are not stored directly in the users table ********/
switch($conference['type']){
case 'sciencefair':
$specialFieldRoles = array(
'special_awards' => array('judge', 'student'),
'available_times' => array('judge', 'volunteer')
'available_times' => array('judge'),
'available_events' => array('volunteer'),
'volunteer_positions' => array('volunteer')
);
break;
case 'scienceolympics':
$specialFieldRoles = array(
'special_awards' => array(),
'available_times' => array(),
'available_events' => array('judge', 'volunteer'),
'volunteer_positions' => array('volunteer')
);
break;
default:
$specialFieldRoles = array();
}
// get the special_awards info if necessary
if(count(array_intersect($specialFieldRoles['special_awards'], $userRoles)) > 0){
$fields['special_awards'] = array();
$fields['special_awards']['field'] = 'special_awards';
$fields['special_awards']['display'] = $fieldInfo['special_awards']['label'];
$fields['special_awards']['display'] = i18n($fieldInfo['special_awards']['label']);
$fields['special_awards']['group'] = i18n($fieldInfo['special_awards']['group']);
$fields['special_awards']['type'] = 'multiselectlist';
$fields['special_awards']['options'] = array('yes' => 'Yes', 'no' => 'No');
$fields['special_awards']['entries'] = get_special_awards($conference['id']);
@ -524,15 +589,47 @@ function user_get_fields($userRoles = null){
if(count(array_intersect($specialFieldRoles['available_times'], $userRoles)) > 0){
$fields['available_times'] = array();
$fields['available_times']['field'] = 'available_times';
$fields['available_times']['display'] = $fieldInfo['available_times'];
$fields['available_times']['display'] = i18n($fieldInfo['available_times']['label']);
$fields['available_times']['group'] = i18n($fieldInfo['available_times']['group']);
$fields['available_times']['type'] = 'multiselectlist';
$fields['available_times']['options'] = array('yes' => 'Yes', 'no' => 'No');
$fields['available_times']['entries'] = array();
$timeslots = get_timeslots($conference['id']);
$timeslots = get_judging_timeslots($conference['id']);
foreach($timeslots as $slot){
$fields['available_times']['entries'][$slot['id']] = trim($slot['name'] . ' (' . $slot['date'] . ' ' . $slot['starttime'] . ' - ' . $slot['endtime'] . ')');
}
}
// get the available_events if available
if(count(array_intersect($specialFieldRoles['available_events'], $userRoles)) > 0){
$fields['available_events'] = array();
$fields['available_events']['field'] = 'available_events';
$fields['available_events']['display'] = i18n($fieldInfo['available_events']['label']);
$fields['available_events']['group'] = i18n($fieldInfo['available_events']['group']);
$fields['available_events']['type'] = 'multiselectlist';
$fields['available_events']['options'] = array('yes' => 'Yes', 'no' => 'No');
$fields['available_events']['entries'] = array();
$q=mysql_query("SELECT schedule.id, schedule.date, schedule.hour, schedule.minute, schedule.duration, events.name FROM schedule JOIN events ON schedule.events_id=events.id WHERE schedule.conferences_id='{$conference['id']}'");
while($row = mysql_fetch_assoc($q)){
$fields['available_events']['entries'][$row['id']] = $row['name'] . ' ' . $row['date'] . ', ' . $row['hour'] . ':' . $row['minute'] . ':00 (' . $row['duration'] . ' ' . i18n('minutes') . ')';
}
}
// get the available volunteer positions as well
if(count(array_intersect($specialFieldRoles['volunteer_positions'], $userRoles)) > 0){
$fields['volunteer_positions'] = array();
$fields['volunteer_positions']['field'] = 'volunteer_positions';
$fields['volunteer_positions']['display'] = i18n($fieldInfo['volunteer_positions']['label']);
$fields['volunteer_positions']['group'] = i18n($fieldInfo['volunteer_positions']['group']);
$fields['volunteer_positions']['type'] = 'multiselectlist';
$fields['volunteer_positions']['options'] = array('yes' => 'Yes', 'no' => 'No');
$fields['volunteer_positions']['entries'] = array();
$q = mysql_query("SELECT id, name FROM volunteer_positions WHERE conferences_id = {$conference['id']}");
while($row = mysql_fetch_assoc($q)){
$fields['volunteer_positions']['entries'][$row['id']] = $row['name'];
}
}
return $fields;
}