forked from science-ation/science-ation
factor out functions to get projects that are eligible for an award
This commit is contained in:
parent
1476031aea
commit
e91dbdf4c9
@ -25,6 +25,7 @@
|
|||||||
require("../common.inc.php");
|
require("../common.inc.php");
|
||||||
auth_required('admin');
|
auth_required('admin');
|
||||||
require("judges.inc.php");
|
require("judges.inc.php");
|
||||||
|
require("projects.inc.php");
|
||||||
|
|
||||||
send_header("Judging Teams Projects");
|
send_header("Judging Teams Projects");
|
||||||
?>
|
?>
|
||||||
@ -127,6 +128,8 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
|
|||||||
echo "<br />";
|
echo "<br />";
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
|
|
||||||
|
//we need award_ids for use below to get the eligible projects, so lets build the array here while we're displaying the awards
|
||||||
|
$award_ids=array();
|
||||||
if(count($team['awards']))
|
if(count($team['awards']))
|
||||||
{
|
{
|
||||||
$awardlist=" ";
|
$awardlist=" ";
|
||||||
@ -134,6 +137,7 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
|
|||||||
{
|
{
|
||||||
$awardlist.=$award['name'];
|
$awardlist.=$award['name'];
|
||||||
$awardlist.=", ";
|
$awardlist.=", ";
|
||||||
|
$award_ids[]=$award['id'];
|
||||||
}
|
}
|
||||||
echo "<b>".i18n("Judging Team Awards").": </b>";
|
echo "<b>".i18n("Judging Team Awards").": </b>";
|
||||||
$awardlist=substr($awardlist,0,-2);
|
$awardlist=substr($awardlist,0,-2);
|
||||||
@ -173,7 +177,7 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
|
|||||||
else
|
else
|
||||||
$ch="";
|
$ch="";
|
||||||
|
|
||||||
echo "<input $ch onclick=\"eligibleclick()\" type=\"checkbox\" name=\"showeligible\"> Show only projects eligible for awards assigned to this team";
|
echo "<input $ch onclick=\"eligibleclick()\" type=\"checkbox\" name=\"showeligible\"> ".i18n("Only show projects eligible for awards assigned to this team");
|
||||||
echo "<table>";
|
echo "<table>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
@ -232,6 +236,10 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
|
|||||||
}
|
}
|
||||||
$pq=mysql_query($querystr);
|
$pq=mysql_query($querystr);
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
|
|
||||||
|
$eligibleprojects=getProjectsEligibleForAwards($award_ids);
|
||||||
|
echo nl2br(print_r($eligibleprojects,true));
|
||||||
|
|
||||||
$numprojects=mysql_num_rows($pq);
|
$numprojects=mysql_num_rows($pq);
|
||||||
|
|
||||||
echo "<select name=\"project_id\">";
|
echo "<select name=\"project_id\">";
|
||||||
|
77
admin/projects.inc.php
Normal file
77
admin/projects.inc.php
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<?
|
||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<?
|
||||||
|
function getProjectsEligibleForAward($award_id)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$prjq=mysql_query("SELECT
|
||||||
|
award_awards.id,
|
||||||
|
award_awards_projectcategories.projectcategories_id,
|
||||||
|
award_awards_projectdivisions.projectdivisions_id,
|
||||||
|
projects.projectnumber,
|
||||||
|
projects.title,
|
||||||
|
projects.id AS projects_id
|
||||||
|
FROM
|
||||||
|
award_awards,
|
||||||
|
award_awards_projectcategories,
|
||||||
|
award_awards_projectdivisions,
|
||||||
|
projects
|
||||||
|
WHERE
|
||||||
|
award_awards.id='$award_id'
|
||||||
|
AND award_awards.id=award_awards_projectcategories.award_awards_id
|
||||||
|
AND award_awards.id=award_awards_projectdivisions.award_awards_id
|
||||||
|
AND projects.projectcategories_id=award_awards_projectcategories.projectcategories_id
|
||||||
|
AND projects.projectdivisions_id=award_awards_projectdivisions.projectdivisions_id
|
||||||
|
AND projects.projectnumber is not null
|
||||||
|
AND projects.year='".$config['FAIRYEAR']."'
|
||||||
|
ORDER BY
|
||||||
|
projectnumber
|
||||||
|
");
|
||||||
|
$projects=array();
|
||||||
|
while($prjr=mysql_fetch_object($prjq))
|
||||||
|
{
|
||||||
|
$projects[$prjr->projectnumber]=array(
|
||||||
|
"id"=>$prjr->projects_id,
|
||||||
|
"projectnumber"=>$prjr->projectnumber,
|
||||||
|
"title"=>$prjr->title
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProjectsEligibleForAwards($awards_ids_array)
|
||||||
|
{
|
||||||
|
$projects=array();
|
||||||
|
foreach($awards_ids_array AS $award_id)
|
||||||
|
{
|
||||||
|
$awardprojects=array();
|
||||||
|
$awardprojects=getProjectsEligibleForAward($award_id);
|
||||||
|
//this will just overwrite ones that already exist, but still keep things in order because the main key is the projectnumber (i hope)
|
||||||
|
foreach($awardprojects AS $proj)
|
||||||
|
$projects[$proj['projectnumber']]=$proj;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $projects;
|
||||||
|
}
|
@ -23,6 +23,7 @@
|
|||||||
?>
|
?>
|
||||||
<?
|
<?
|
||||||
require("../common.inc.php");
|
require("../common.inc.php");
|
||||||
|
require("projects.inc.php");
|
||||||
auth_required('admin');
|
auth_required('admin');
|
||||||
|
|
||||||
send_header("Administration - Award Winners");
|
send_header("Administration - Award Winners");
|
||||||
@ -104,39 +105,8 @@ if($action=="edit" && $edit)
|
|||||||
{
|
{
|
||||||
|
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
$prjq=mysql_query("SELECT
|
//get the projets that are eligible for the award, given the award ID ($r->id)
|
||||||
award_awards.id,
|
$projects=getProjectsEligibleForAward($r->id);
|
||||||
award_awards_projectcategories.projectcategories_id,
|
|
||||||
award_awards_projectdivisions.projectdivisions_id,
|
|
||||||
projects.projectnumber,
|
|
||||||
projects.title,
|
|
||||||
projects.id AS projects_id
|
|
||||||
FROM
|
|
||||||
award_awards,
|
|
||||||
award_awards_projectcategories,
|
|
||||||
award_awards_projectdivisions,
|
|
||||||
projects
|
|
||||||
WHERE
|
|
||||||
award_awards.id='$r->id'
|
|
||||||
AND award_awards.id=award_awards_projectcategories.award_awards_id
|
|
||||||
AND award_awards.id=award_awards_projectdivisions.award_awards_id
|
|
||||||
AND projects.projectcategories_id=award_awards_projectcategories.projectcategories_id
|
|
||||||
AND projects.projectdivisions_id=award_awards_projectdivisions.projectdivisions_id
|
|
||||||
AND projects.projectnumber is not null
|
|
||||||
AND projects.year='".$config['FAIRYEAR']."'
|
|
||||||
ORDER BY
|
|
||||||
projectnumber
|
|
||||||
");
|
|
||||||
echo mysql_error();
|
|
||||||
$projects=array();
|
|
||||||
while($prjr=mysql_fetch_object($prjq))
|
|
||||||
{
|
|
||||||
$projects[$prjr->projects_id]=array(
|
|
||||||
"id"=>$prjr->projects_id,
|
|
||||||
"projectnumber"=>$prjr->projectnumber,
|
|
||||||
"title"=>$prjr->title
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$winq=mysql_query("SELECT
|
$winq=mysql_query("SELECT
|
||||||
winners.projects_id
|
winners.projects_id
|
||||||
|
Loading…
Reference in New Issue
Block a user