forked from science-ation/science-ation
7368a22975
make committee management fully XHTML compliant
446 lines
14 KiB
PHP
446 lines
14 KiB
PHP
<?
|
|
/*
|
|
This file is part of the 'Science Fair In A Box' project
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
|
Copyright (C) 2005 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");
|
|
send_header("Administration - Committee Management");
|
|
?>
|
|
|
|
|
|
<script type="text/javascript">
|
|
<!--
|
|
|
|
function getElement(e,f)
|
|
{
|
|
if(document.layers)
|
|
{
|
|
f=(f)?f:self;
|
|
if(f.document.layers[e]) {
|
|
return f.document.layers[e];
|
|
}
|
|
for(W=0;i<f.document.layers.length;W++) {
|
|
return(getElement(e,fdocument.layers[W]));
|
|
}
|
|
}
|
|
if(document.all) {
|
|
return document.all[e];
|
|
}
|
|
return document.getElementById(e);
|
|
}
|
|
|
|
|
|
function actionChanged()
|
|
{
|
|
if(document.forms.memberaction.action.selectedIndex==1) //assign
|
|
{
|
|
getElement('assigndiv').style.display = 'block';
|
|
|
|
}
|
|
else // edit or delete
|
|
{
|
|
getElement('assigndiv').style.display = 'none';
|
|
}
|
|
|
|
}
|
|
|
|
function actionSubmit()
|
|
{
|
|
if(document.forms.memberaction.action.selectedIndex==0)
|
|
{
|
|
alert('You must choose an action');
|
|
return false;
|
|
}
|
|
if(document.forms.memberaction.committees_members_id.selectedIndex==0)
|
|
{
|
|
alert('You must choose a member');
|
|
return false;
|
|
}
|
|
|
|
if(document.forms.memberaction.action.selectedIndex==3) //remove
|
|
{
|
|
return confirmClick('Are you sure you want to completely remove this member?');
|
|
}
|
|
return true;
|
|
}
|
|
//-->
|
|
</script>
|
|
<?
|
|
|
|
if($_POST['addcommittee'])
|
|
{
|
|
//add a new committee
|
|
mysql_query("INSERT INTO committees (name) VALUES ('".mysql_escape_string($_POST['addcommittee'])."')");
|
|
echo happy(i18n("Committee successfully added"));
|
|
}
|
|
|
|
if($_POST['committees_id'] && $_POST['committees_ord'])
|
|
{
|
|
//re-order the committees
|
|
$x=0;
|
|
$ids=$_POST['committees_id'];
|
|
$ords=$_POST['committees_ord'];
|
|
|
|
while($ids[$x])
|
|
{
|
|
mysql_query("UPDATE committees SET ord='".$ords[$x]."' WHERE id='".$ids[$x]."'");
|
|
$x++;
|
|
}
|
|
echo happy(i18n("Committees successfully re-ordered"));
|
|
|
|
}
|
|
|
|
if($_POST['action']=="assign")
|
|
{
|
|
if($_POST['committees_id'] && $_POST['committees_members_id'])
|
|
{
|
|
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='".$_POST['committees_id']."' AND committees_members_id='".$_POST['committees_members_id']."'");
|
|
|
|
if(!mysql_num_rows($q))
|
|
{
|
|
mysql_query("INSERT INTO committees_link (committees_id,committees_members_id) VALUES ('".$_POST['committees_id']."','".$_POST['committees_members_id']."')");
|
|
echo happy(i18n("Successfully added member to committee"));
|
|
}
|
|
else
|
|
echo error(i18n("That member already exists in that committee"));
|
|
}
|
|
else
|
|
echo error(("You must choose both a member and a committee"));
|
|
|
|
|
|
}
|
|
|
|
if($_GET['deletecommittee'])
|
|
{
|
|
mysql_query("DELETE FROM committees WHERE id='".$_GET['deletecommittee']."'");
|
|
echo happy(i18n("Committee removed"));
|
|
|
|
}
|
|
|
|
if($_POST['action']=="remove")
|
|
{
|
|
mysql_query("DELETE FROM committees_members WHERE id='".$_POST['committees_members_id']."'");
|
|
mysql_query("DELETE FROM committees_link WHERE committees_members_id='".$_POST['committees_members_id']."'");
|
|
echo happy(i18n("Committee member removed"));
|
|
|
|
}
|
|
|
|
if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
|
|
{
|
|
//unlink the member from the committee
|
|
mysql_query("DELETE FROM committees_link WHERE committees_members_id='".$_GET['unlinkmember']."' AND committees_id='".$_GET['unlinkcommittee']."'");
|
|
echo happy(i18n("Committee member unlinked from committee"));
|
|
|
|
}
|
|
|
|
if($_POST['add_member_to_committees_id'])
|
|
{
|
|
mysql_query("INSERT INTO committees_link (committees_id,committees_members_id) VALUES ('".$_POST['add_member_to_committees_id']."')");
|
|
$edit=$_POST['committees_members_id'];
|
|
}
|
|
|
|
if($_POST['add_member'])
|
|
{
|
|
mysql_query("INSERT INTO committees_members (name) VALUES ('".mysql_escape_string(stripslashes($_POST['add_member']))."')");
|
|
$edit=mysql_insert_id();
|
|
}
|
|
|
|
if($_POST['save'])
|
|
{
|
|
mysql_query("UPDATE committees_members SET ".
|
|
"name='".$_POST['name']."', ".
|
|
"organization='".$_POST['organization']."', ".
|
|
"email='".$_POST['email']."', ".
|
|
"emailprivate='".$_POST['emailprivate']."', ".
|
|
"phonehome='".$_POST['phonehome']."', ".
|
|
"phonework='".$_POST['phonework']."', ".
|
|
"phonecell='".$_POST['phonecell']."', ".
|
|
"fax='".$_POST['fax']."', ".
|
|
"displayemail='".$_POST['displayemail']."' ".
|
|
" WHERE id='".$_POST['save']."'");
|
|
|
|
if($_POST['ord'])
|
|
{
|
|
$keys=@array_keys($_POST['ord']);
|
|
foreach ($keys AS $key)
|
|
{
|
|
mysql_query("UPDATE committees_link SET title='".mysql_escape_string(stripslashes($_POST['titles'][$key]))."', ord='".$_POST['ord'][$key]."' WHERE committees_id='$key' AND committees_members_id='".$_POST['save']."'");
|
|
echo mysql_error();
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
if($_FILES['picture']['error']==UPLOAD_ERR_OK)
|
|
{
|
|
system("convert -sample 100 ".$_FILES['picture']['tmp_name']." ".$_SERVER['DOCUMENT_ROOT']."/board/".$_POST['save']."-thumb.jpg");
|
|
move_uploaded_file($_FILES['picture']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/board/".$_POST['save'].".jpg");
|
|
echo notice("Picture updated");
|
|
echo "<br>\n";
|
|
}
|
|
*/
|
|
|
|
//print_r($config);
|
|
|
|
if($config['committees_executeonsave'])
|
|
{
|
|
echo happy(i18n("Executing:").$config['committees_executeonsave']);
|
|
system($config['committees_executeonsave']);
|
|
}
|
|
|
|
echo happy(i18n("Committee member saved"));
|
|
|
|
}
|
|
|
|
if($_POST['action']=="edit")
|
|
{
|
|
$edit=$_POST['committees_members_id'];
|
|
}
|
|
|
|
if($_GET['edit'] || $edit)
|
|
{
|
|
if($_GET['edit'])
|
|
$e=$_GET['edit'];
|
|
else
|
|
$e=$edit;
|
|
$q=mysql_query("SELECT * FROM committees_members WHERE id='$e'");
|
|
$r=mysql_fetch_object($q);
|
|
echo "<h4>Edit Committee Member</h4>";
|
|
echo "<a href=\"committees.php\"><font face=arial><< Back to Committees Editor</a>\n";
|
|
|
|
// echo "<form enctype=\"multipart/form-data\" action=\"admin_board.php\" method=\"post\" accept=\"image/jpeg\">\n";
|
|
echo "<form action=\"committees.php\" method=\"post\">\n";
|
|
echo "<input type=\"hidden\" name=\"save\" value=\"$e\">\n";
|
|
|
|
|
|
echo "<table>";
|
|
// echo "<tr><td>";
|
|
|
|
// echo "<table class=bodytext border=\"0\" cellspacing=0 cellpadding=1>";
|
|
|
|
echo "<tr><td>Name:</td><td><input size=25 type=text name=name value=\"$r->name\"></td></tr>";
|
|
|
|
$cq=mysql_query("SELECT committees.name, committees.id, committees_link.title, committees_link.ord FROM committees,committees_link WHERE committees_link.committees_id=committees.id AND committees_link.committees_members_id='$e' ORDER BY committees.name");
|
|
|
|
echo "<tr><td valign=\"top\">Committees:</td><td>";
|
|
if(mysql_num_rows($cq))
|
|
{
|
|
echo "<table>";
|
|
echo "<tr><th>Committee</th><th>Title in Committee</th><th>Order</th></tr>";
|
|
while($cr=mysql_fetch_object($cq))
|
|
{
|
|
echo "<tr><td>$cr->name</td><td><input type=\"text\" name=\"titles[$cr->id]\" value=\"$cr->title\" /></td><td><input type=text name=\"ord[$cr->id]\" value=\"$cr->ord\" size=3></td></tr>";
|
|
}
|
|
|
|
echo "</table>";
|
|
}
|
|
else
|
|
echo "None";
|
|
echo "</td></tr>\n";
|
|
echo "<tr><td>Organization:</td><td><input size=\"25\" type=\"text\" name=\"organization\" value=\"$r->organization\" /></td></tr>\n";
|
|
echo "<tr><td>Email (Public):</td><td><input size=\"25\" type=\"text\" name=\"email\" value=\"$r->email\" /></td></tr>\n";
|
|
echo "<tr><td>Email (Private):</td><td><input size=\"25\" type=\"text\" name=\"emailprivate\" value=\"$r->emailprivate\" /></td></tr>\n";
|
|
echo "<tr><td>Display Emails:</td><td>";
|
|
if($r->displayemail=="N") $checked="checked=\"checked\""; else $checked="";
|
|
echo "<input type=\"radio\" name=\"displayemail\" value=\"N\" $checked>No";
|
|
echo " ";
|
|
if($r->displayemail=="Y") $checked="checked=\"checked\""; else $checked="";
|
|
echo "<input type=\"radio\" name=\"displayemail\" value=\"Y\" $checked>Yes";
|
|
|
|
echo "</td></tr>\n";
|
|
echo "<tr><td>Phone (Home):</td><td><input size=\"15\" type=\"text\" name=\"phonehome\" value=\"$r->phonehome\" /></td></tr>\n";
|
|
echo "<tr><td>Phone (Work):</td><td><input size=\"15\" type=\"text\" name=\"phonework\" value=\"$r->phonework\" /></td></tr>\n";
|
|
echo "<tr><td>Phone (Cell):</td><td><input size=\"15\" type=\"text\" name=\"phonecell\" value=\"$r->phonecell\" /></td></tr>\n";
|
|
echo "<tr><td>Fax:</td><td><input size=\"15\" type=\"text\" name=\"fax\" value=\"$r->fax\"></td></tr>\n";
|
|
// echo "<tr><td>Picture:</td><td><input size=10 name=\"picture\" type=\"file\"></td></tr>\n";
|
|
// echo "</table>";
|
|
|
|
// echo "</td><td valign=middle>";
|
|
|
|
// if(file_exists($_SERVER['DOCUMENT_ROOT']."/board/".$r->id."-thumb.jpg"))
|
|
// echo "<img src=\"/board/".$r->id."-thumb.jpg\" border=\"0\">";
|
|
// else
|
|
// echo "No Picture";
|
|
|
|
// echo "</td></tr>\n";
|
|
echo "<tr><td align=center colspan=2>";
|
|
echo "<br><br>";
|
|
echo "<input type=submit value=\"Save Member\" />\n";
|
|
echo "</td></tr>\n";
|
|
echo "</table>\n";
|
|
|
|
echo "</form>\n";
|
|
}
|
|
else
|
|
{
|
|
|
|
echo "<table>";
|
|
echo "<tr><td>";
|
|
|
|
echo "<h4>Add Committee</h4>\n";
|
|
echo "<form method=\"post\"action=\"committees.php\">\n";
|
|
echo "<table>\n";
|
|
echo "<tr><td>Committee Name: </td><td><input type=\"text\" size=\"15\" name=\"addcommittee\" /></td>";
|
|
echo " <td><input type=\"submit\" value=\"Add\" /></td></tr>\n";
|
|
echo "</table>\n";
|
|
echo "</form>\n";
|
|
|
|
echo "</td><td width=\"40\"> </td><td>";
|
|
|
|
echo "<h4>Add Committee Member</h4>\n";
|
|
echo "<form method=\"post\" action=\"committees.php\">\n";
|
|
echo "<table>\n";
|
|
echo "<tr><td>Member Name: </td><td>";
|
|
echo "<input type=\"text\" size=\"15\" name=\"add_member\" />\n";
|
|
echo "</td>\n";
|
|
echo " <td><input type=\"submit\" value=\"Add\" /></td></tr>\n";
|
|
echo "</table>\n";
|
|
echo "</form>\n";
|
|
|
|
echo "</td></tr>";
|
|
echo "</table>";
|
|
|
|
|
|
echo "<hr />";
|
|
echo "<h4>Committee Member Management</h4>\n";
|
|
echo "<form name=\"memberaction\" method=\"post\" action=\"committees.php\" onsubmit=\"return actionSubmit()\">\n";
|
|
echo "<table>";
|
|
echo "<tr><td>";
|
|
echo "<select name=\"action\" onchange=\"javascript:actionChanged()\">";
|
|
echo "<option value=\"\">Choose</option>\n";
|
|
echo "<option value=\"assign\">Assign</option>\n";
|
|
echo "<option value=\"edit\">Edit</option>\n";
|
|
echo "<option value=\"remove\">Remove</option>\n";
|
|
echo "</select>";
|
|
|
|
echo "</td><td>";
|
|
$q=mysql_query("SELECT * FROM committees_members ORDER BY name");
|
|
echo "<select name=\"committees_members_id\">";
|
|
echo "<option value=\"\">Select a Member</option>\n";
|
|
while($r=mysql_fetch_object($q))
|
|
{
|
|
echo "<option value=\"$r->id\">$r->name</option>\n";
|
|
}
|
|
echo "</select>";
|
|
|
|
echo "</td><td>";
|
|
|
|
|
|
//The Assign Div
|
|
echo "<div id=\"assigndiv\">";
|
|
echo "To Committee: ";
|
|
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
|
echo "<select name=\"committees_id\">";
|
|
echo "<option value=\"\">Select a Committee</option>\n";
|
|
while($r=mysql_fetch_object($q))
|
|
{
|
|
echo "<option value=\"$r->id\">$r->name</option>\n";
|
|
}
|
|
echo "</select>";
|
|
echo "</div>";
|
|
|
|
|
|
//The Edit or Remove Div
|
|
|
|
echo "</td><td><input type=\"submit\" value=\"Go\" /></td></tr>";
|
|
|
|
echo "</table>";
|
|
echo "</form>";
|
|
|
|
echo "<script language=\"javascript\" type=\"text/javascript\">actionChanged()</script>";
|
|
echo "<hr />";
|
|
|
|
|
|
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
|
|
if(mysql_num_rows($q))
|
|
{
|
|
echo "<h4>Committees</h4>";
|
|
echo "<form method=\"post\" action=\"committees.php\">\n";
|
|
echo "<table>";
|
|
while($r=mysql_fetch_object($q))
|
|
{
|
|
echo "<tr>";
|
|
echo "<td colspan=\"3\">";
|
|
echo "<input type=\"hidden\" name=\"committees_id[]\" value=\"$r->id\" />";
|
|
echo "<input size=\"2\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
|
|
echo " <b>$r->name</b>";
|
|
|
|
$q2=mysql_query("SELECT ".
|
|
"committees_members.id,".
|
|
"committees_members.name,".
|
|
"committees_members.email,".
|
|
"committees_members.emailprivate,".
|
|
"committees_link.title, ".
|
|
"committees_link.ord ".
|
|
"FROM committees_members, committees_link ".
|
|
"WHERE committees_link.committees_members_id=committees_members.id ".
|
|
" AND committees_link.committees_id='$r->id'".
|
|
" ORDER BY ord,name");
|
|
if(mysql_num_rows($q2)==0)
|
|
{
|
|
echo " ";
|
|
echo "<a title=\"Remove Committee\" onclick=\"return confirmClick('Are you sure you want to remove this committee?');\" href=\"committees.php?deletecommittee=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Committee\" /></a>";
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
|
echo mysql_error();
|
|
while($r2=mysql_fetch_object($q2))
|
|
{
|
|
echo "<tr><td align=\"right\"> ";
|
|
echo "<a title=\"Edit Member\" href=\"committees.php?edit=$r2->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\" border=\"0\" alt=\"Edit\" /></a>";
|
|
echo " ";
|
|
echo "<a title=\"Unlink Member from Committee\" onclick=\"return confirmClick('Are you sure you want to unlink this member from this committee?');\" href=\"committees.php?unlinkmember=$r2->id&unlinkcommittee=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/undo.".$config['icon_extension']."\" border=\"0\" alt=\"Unlink\" /></a>";
|
|
echo "</td>";
|
|
echo "<td valign=\"top\">";
|
|
echo " <b>$r2->name</b>";
|
|
|
|
if($r2->title) echo " - $r2->title ";
|
|
|
|
echo "</td><td>";
|
|
|
|
if($r2->email)
|
|
{
|
|
list($b,$a)=split("@",$r2->email);
|
|
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
|
}
|
|
|
|
if($r2->emailprivate)
|
|
{
|
|
if($r2->email) echo " <b>/</b> ";
|
|
list($b,$a)=split("@",$r2->emailprivate);
|
|
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
|
}
|
|
echo "<tr><td colspan=\"2\"> </td></tr>\n";
|
|
}
|
|
echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"Re-Order Committees\" /></td></tr>\n";
|
|
echo "</table>";
|
|
echo "</form>\n";
|
|
}
|
|
}
|
|
|
|
send_footer();
|
|
?>
|
|
|