Copyright (C) 2005 James Grant Copyright (C) 2007 David Grant 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. */ ?> "{$type}_main.php") ); if($_POST['action']=="save") { $vals = ''; if(is_array($_POST['posn'])) { /* Load available IDs */ $posns = array(); $q = "SELECT * FROM volunteer_positions WHERE year='{$config['FAIRYEAR']}'"; $r = mysql_query($q); while($p = mysql_fetch_object($r)) { $posns[] = $p->id; } /* Match selections with avaiulable positions */ foreach($_POST['posn'] as $id=>$val) { if(!in_array($id, $posns)) continue; if($vals != '') $vals .=','; $vals .= "('{$_SESSION['users_id']}','$id','{$config['FAIRYEAR']}')"; } } /* Delete existing selections */ mysql_query("DELETE FROM volunteer_positions_signup WHERE users_id='{$_SESSION['users_id']}' AND year='{$config['FAIRYEAR']}' "); echo mysql_error(); /* Add new selections if there are any */ if($vals != '') { $q = "INSERT INTO volunteer_positions_signup (users_id, volunteer_positions_id,year) VALUES $vals"; $r=mysql_query($q); echo mysql_error(); } echo notice(i18n("Volunteer Positions successfully updated")); } //output the current status $newstatus=volunteer_status_position($u); if($newstatus!='complete') { echo error(i18n("Volunteer Position Selection Incomplete")); } else { echo happy(i18n("Volunteer Position Selection Complete")); } echo "
\n"; echo "\n"; echo "\n"; /* Read current selections */ $q = "SELECT * FROM volunteer_positions_signup WHERE users_id = '{$_SESSION['users_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 '' ; echo ""; echo ''; } echo "
'; $checked = false; if($_SESSION['lang'] == 'en') { $sday = strftime("%a. %B %e, %Y", $p->ustart); $stime = strftime("%H:%M", $p->ustart); $eday = strftime("%a. %B %e, %Y", $p->uend); $etime = strftime("%H:%M", $p->uend); if($sday == $eday) { $start = $stime; $end = "$etime, $sday"; } else { $start = "$sday, $stime"; $end = "$eday, $etime"; } } else { $start = $p->start; $end = $p->end; } $ch = in_array($p->id, $checked_positions) ? 'checked="checked"' : ''; echo "id]\" value=\"checked\" />"; echo ''; echo ''.i18n($p->name).'($start - $end)
'; echo i18n($p->desc); echo '

"; echo "\n"; echo "
"; echo "
"; send_footer(); ?>