forked from science-ation/science-ation
LPDF: fix bug when one line of text is added with addtext
LCSV: add addtext, newpage functions Create new report containing judging team project assignments, one team per page.
This commit is contained in:
parent
3120d31841
commit
db6b2dad28
@ -56,29 +56,28 @@ if($_GET['judges_projects_list_show'])
|
||||
$_SESSION['viewstate']['judges_projects_list_show']=$_GET['judges_projects_list_show'];
|
||||
|
||||
|
||||
if($_GET['action']=="delete" && $_GET['delete'] && $_GET['edit'])
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE id='".$_GET['delete']."'");
|
||||
if($_GET['action']=="delete" && $_GET['delete'] && $_GET['edit'])
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE id='".$_GET['delete']."'");
|
||||
echo happy(i18n("Judging team project successfully removed"));
|
||||
$action="edit";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if($_GET['action']=="empty" && $_GET['empty'])
|
||||
{
|
||||
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['empty']."'");
|
||||
echo happy(i18n("Judging team timeslots successfully removed"));
|
||||
}
|
||||
*/
|
||||
|
||||
if($_POST['action']=="assign" && $_POST['edit'] && $_POST['timeslot'] && $_POST['project_id'])
|
||||
{
|
||||
if($_POST['action']=="assign" && $_POST['edit'] && $_POST['timeslot'] && $_POST['project_id'])
|
||||
{
|
||||
mysql_query("INSERT INTO judges_teams_timeslots_projects_link (judges_teams_id,judges_timeslots_id,projects_id,year) VALUES ('".$_POST['edit']."','".$_POST['timeslot']."','".$_POST['project_id']."','".$config['FAIRYEAR']."')");
|
||||
echo happy(i18n("Project assigned to team timeslot"));
|
||||
}
|
||||
}
|
||||
|
||||
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q)>1)
|
||||
$show_date=true;
|
||||
else
|
||||
$show_date=false;
|
||||
|
||||
|
||||
if( ($action=="edit" || $action=="assign" ) && $edit)
|
||||
if( ($action=="edit" || $action=="assign" ) && $edit)
|
||||
{
|
||||
echo "<a href=\"judges_teams_projects.php\">Back to Judging Teams Projects List</a>";
|
||||
echo "<form name=\"teamsprojects\" method=\"post\" action=\"judges_teams_projects.php\">";
|
||||
@ -102,47 +101,6 @@ if($_GET['judges_projects_list_show'])
|
||||
echo $memberlist;
|
||||
echo "<br />";
|
||||
|
||||
/*
|
||||
if($_SESSION['viewstate']['judges_teams_list_show']=='all')
|
||||
{
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname
|
||||
FROM
|
||||
judges,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges.complete='yes'
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
}
|
||||
else
|
||||
{
|
||||
$querystr="SELECT
|
||||
judges.id,
|
||||
judges.firstname,
|
||||
judges.lastname,
|
||||
judges_teams_link.judges_id
|
||||
FROM
|
||||
judges
|
||||
LEFT JOIN judges_teams_link ON judges.id = judges_teams_link.judges_id,
|
||||
judges_years
|
||||
WHERE
|
||||
judges_years.year='".$config['FAIRYEAR']."' AND
|
||||
judges.id=judges_years.judges_id AND
|
||||
judges_teams_link.judges_id IS NULL AND
|
||||
judges.complete='yes'
|
||||
ORDER BY
|
||||
lastname,
|
||||
firstname";
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
if($_SESSION['viewstate']['judges_projects_list_show']=='all')
|
||||
{
|
||||
$querystr="SELECT
|
||||
@ -343,7 +301,7 @@ if($_GET['judges_projects_list_show'])
|
||||
|
||||
echo "<a href=\"judges_teams_projects.php?action=edit&edit=".$team['id']."\">Edit team project assignments</a>";
|
||||
|
||||
echo "<table class=summarytable style=\"margin-left: 0px\">";
|
||||
echo "<table class=summarytable style=\"margin-left: 0px; width: 100%;\">";
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
|
@ -53,5 +53,10 @@ echo "</table>";
|
||||
echo "<a href=\"reports_judges_teams_view.php?type=csv\">Team View (CSV)</a> ";
|
||||
echo "<a href=\"reports_judges_teams_view.php?type=pdf\">Team View (PDF)</a> ";
|
||||
|
||||
echo "<br />";
|
||||
echo i18n("Judging Project Assignments").": ";
|
||||
echo "<a href=\"reports_judges_teams_projects.php?type=csv\">CSV</a> ";
|
||||
echo "<a href=\"reports_judges_teams_projects.php?type=pdf\">PDF</a> ";
|
||||
|
||||
send_footer();
|
||||
?>
|
||||
|
139
admin/reports_judges_teams_projects.php
Normal file
139
admin/reports_judges_teams_projects.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?
|
||||
/*
|
||||
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");
|
||||
auth_required('admin');
|
||||
require("../lpdf.php");
|
||||
require("../lcsv.php");
|
||||
require("judges.inc.php");
|
||||
|
||||
$type=$_GET['type'];
|
||||
|
||||
if($type=="pdf")
|
||||
{
|
||||
|
||||
$rep=new lpdf( i18n($config['fairname']),
|
||||
i18n("Judging Team Project Assignments"),
|
||||
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
|
||||
);
|
||||
|
||||
$rep->newPage();
|
||||
$rep->setFontSize(11);
|
||||
}
|
||||
else if($type=="csv")
|
||||
{
|
||||
$rep=new lcsv(i18n("Judging Team Projecet Assignments"));
|
||||
}
|
||||
|
||||
$teams=getJudgingTeams();
|
||||
|
||||
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q)>1)
|
||||
$show_date=true;
|
||||
else
|
||||
$show_date=false;
|
||||
|
||||
foreach($teams AS $team)
|
||||
{
|
||||
$table=array();
|
||||
$table['header']=array(i18n("Timeslot"),i18n("Proj #"),i18n("Project Title"));
|
||||
if($show_date)
|
||||
$table['widths']=array( 2.0, 0.75, 4.25);
|
||||
else
|
||||
$table['widths']=array( 1.5, 0.75, 4.75);
|
||||
|
||||
$table['dataalign']=array("center","center","left");
|
||||
|
||||
$rep->heading($team['name']." (".$team['num'].")");
|
||||
|
||||
$memberlist="";
|
||||
foreach($team['members'] AS $member)
|
||||
{
|
||||
$memberlist.=$member['firstname']." ".$member['lastname'];
|
||||
if($member['captain']=="yes")
|
||||
$memberlist.="*";
|
||||
$memberlist.=", ";
|
||||
}
|
||||
$memberlist=substr($memberlist,0,-2);
|
||||
$rep->addText($memberlist);
|
||||
|
||||
$rep->nextLine();
|
||||
|
||||
//get the timeslots that this team has.
|
||||
$q=mysql_query("SELECT
|
||||
judges_timeslots.id,
|
||||
judges_timeslots.date,
|
||||
judges_timeslots.starttime,
|
||||
judges_timeslots.endtime
|
||||
FROM
|
||||
judges_timeslots,
|
||||
judges_teams,
|
||||
judges_teams_timeslots_link
|
||||
WHERE
|
||||
judges_teams.id='".$team['id']."' AND
|
||||
judges_teams.id=judges_teams_timeslots_link.judges_teams_id AND
|
||||
judges_timeslots.id=judges_teams_timeslots_link.judges_timeslots_id
|
||||
ORDER BY
|
||||
date,starttime
|
||||
");
|
||||
$numslots=mysql_num_rows($q);
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
if($show_date)
|
||||
$timeslot=$r->date." ";
|
||||
else
|
||||
$timeslot="";
|
||||
$timeslot.=substr($r->starttime,0,-3)." - ".substr($r->endtime,0,-3);
|
||||
|
||||
$projq=mysql_query("SELECT
|
||||
projects.projectnumber,
|
||||
projects.id,
|
||||
projects.title
|
||||
FROM
|
||||
projects,
|
||||
judges_teams_timeslots_projects_link
|
||||
WHERE
|
||||
judges_teams_timeslots_projects_link.judges_timeslots_id='$r->id' AND
|
||||
judges_teams_timeslots_projects_link.judges_teams_id='".$team['id']."' AND
|
||||
judges_teams_timeslots_projects_link.projects_id=projects.id AND
|
||||
judges_teams_timeslots_projects_link.year='".$config['FAIRYEAR']."'
|
||||
ORDER BY
|
||||
projectnumber
|
||||
");
|
||||
|
||||
while($proj=mysql_fetch_object($projq))
|
||||
{
|
||||
$table['data'][]=array($timeslot, $proj->projectnumber,$proj->title);
|
||||
//make the timeslot empty so we dont list it each time if there's more than one project in the timeslot
|
||||
$timeslot="";
|
||||
}
|
||||
}
|
||||
$rep->addTable($table);
|
||||
$rep->newPage();
|
||||
unset($table);
|
||||
}
|
||||
|
||||
$rep->output();
|
||||
?>
|
18
lcsv.php
18
lcsv.php
@ -90,7 +90,15 @@ class lcsv
|
||||
|
||||
function heading($str)
|
||||
{
|
||||
$this->csvdata.=$str;
|
||||
//we need to put it in quotes incase it contains a comma we dont want it going to the next 'cell'
|
||||
$this->csvdata.="\"".$str."\"";
|
||||
$this->csvdata.=$this->newline();
|
||||
}
|
||||
|
||||
function addText($str,$align="")
|
||||
{
|
||||
//we need to put it in quotes incase it contains a comma we dont want it going to the next 'cell'
|
||||
$this->csvdata.="\"".$str."\"";
|
||||
$this->csvdata.=$this->newline();
|
||||
}
|
||||
|
||||
@ -100,6 +108,14 @@ class lcsv
|
||||
|
||||
}
|
||||
|
||||
function newPage()
|
||||
{
|
||||
//well we cant really go to a new page, so in teh absense of a new page, lets put a few blank lines in?
|
||||
$this->csvdata.=$this->newline();
|
||||
$this->csvdata.=$this->newline();
|
||||
$this->csvdata.=$this->newline();
|
||||
}
|
||||
|
||||
|
||||
function output()
|
||||
{
|
||||
|
4
lpdf.php
4
lpdf.php
@ -113,7 +113,7 @@ class lpdf
|
||||
$textstr=$text;
|
||||
|
||||
$nr=0;
|
||||
$prevnr=0;
|
||||
$prevnr=-1;
|
||||
do
|
||||
{
|
||||
//echo "textstr=$textstr";
|
||||
@ -135,7 +135,7 @@ class lpdf
|
||||
|
||||
if($nr==$prevnr)
|
||||
{
|
||||
echo "breaking becausae nr==prevnr ($nr==$prevnr) trying to output [$textstr]";
|
||||
echo "breaking because nr==prevnr ($nr==$prevnr) trying to output [$textstr] (debug: fontsize=$fontsize, lineheight=$lineheight, stringwidth=$stringwidth, left=".$this->loc(0.75).", top=".$this->loc($this->yloc).", width=".$this->loc(7).", height=$lineheight)\n";
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user