Documentation is available at team-summary-lists.php
- #!/usr/local/bin/php
- <?php
- /**
- * Generate Team Summary Lists
- *
- * This is a command-line script for generating printed lists.
- * It expectes two commandline arguments
- * - a CompUnix name
- * - an email address to deliver the export to, NOT USED
- *
- * These lists show each team's entries in each events, with a rough
- * guess of the likely number of rounds, for tracking callbacks, or
- * videotaping, or placements, etc
- *
- * This file is part of CompInaBox.
- * @package CommandLine-Scripts
- * @author Eric D. Nielsen <nielsene@alum.mit.edu>
- * @copyright CompInaBox Copyright 2005, Eric D. Nielsen. All Rights Reserved.
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @todo remove email address requirement
- */
- /**
- * Include path information
- */
- function latexHeader($title)
- {
- $header=<<<END_HEADER
- \\documentclass{report}
- \\usepackage{fullpage,graphics,array,color,colortbl,nopageno,longtable,pdflscape}
- \\definecolor{light}{gray}{.8}
- \\begin{document}
- \\begin{landscape}
- END_HEADER; return $header;
- }
- function getEventData($eventid,$orgid)
- {
- GLOBAL $db;
- $eventData=array();
- $result = $db->query("SELECT level, style FROM events NATURAL JOIN events_categories WHERE eventid=$eventid;");
- list($eventData["Level"],$eventData["Style"])=$result->getRowAt(0);
- $result = $db->query("SELECT COUNT(*) FROM events_registration WHERE eventid=$eventid;");
- list($eventData["NumCouples"])=$result->getRowAt(0);
- $result = $db->query("
- SELECT COUNT(DISTINCT competitornumber)
- FROM events_registration NATURAL JOIN couples
- JOIN people AS l ON (leader=l.peopleid)
- JOIN people AS f ON (follower=f.peopleid)
- WHERE (l.organization=$orgid OR f.organization=$orgid)
- AND eventid=$eventid;");
- list( $eventData["NumOwnCouples"])=$result->getRowAt(0);
- $numCouples =$eventData["NumCouples"];
- if ($numCouples <9) $eventData["NumRounds"]=1;
- else if ($numCouples < 16 ) $eventData["NumRounds"]=2;
- else if ($numCouples < 27 ) $eventData["NumRounds"]=3;
- else if ($numCouples < 51 ) $eventData["NumRounds"]=4;
- else $eventData["NumRounds"]=5;
- switch ($eventData["Level"])
- {
- case "Newcomer" :
- switch ($eventData["Style"])
- {
- case "Standard" : $eventData["Dances"]=array("W"); break;
- case "Latin" : $eventData["Dances"]=array("R"); break;
- case "Smooth" : $eventData["Dances"]=array("F"); break;
- case "Rhythm" : $eventData["Dances"]=array("S"); break;
- default: break;
- }
- break;
- case "Championship" :
- switch ($eventData["Style"])
- {
- case "Standard" : $eventData["Dances"]=array("W/T/V/F/Q"); break;
- case "Latin" : $eventData["Dances"]=array("C/S/R/P/J"); break;
- case "Smooth" : $eventData["Dances"]=array("W/T/F/V"); break;
- case "Rhythm" : $eventData["Dances"]=array("C/R/S/B/M"); break;
- default: break;
- }
- break;
- default:
- switch ($eventData["Style"])
- {
- case "Standard" : $eventData["Dances"]=array("W","T","V","F","Q"); break;
- case "Latin" : $eventData["Dances"]=array("C","S","R","P","J"); break;
- case "Smooth" : $eventData["Dances"]=array("W","T","F","V"); break;
- case "Rhythm" : $eventData["Dances"]=array("C","R","S","B","M"); break;
- default: break;
- }
- break;
- }
- return $eventData;
- }
- function eventHeader($eventData)
- {
- $numRounds = $eventData["NumRounds"];
- $numDances = count($eventData["Dances"]);
- $numBlocks = $numRounds*$numDances;
- if ($numRounds==5)
- $numBlocks -= ($eventData["Style"]=="Smooth" ? 2 : 3);
- $header = "\\begin{tabular}{l|";
- for ($i=0;$i<$numRounds;$i++)
- {
- $header .= "|";
- if ($numRounds==5 && $i==0)
- {
- $header.="l|l|";
- }
- else
- {
- for ($j=0;$j<$numDances;$j++)
- $header.="l|";
- }
- if ($i%2==1) $header .= "|l|";
- }
- $header .="}\n";
- $header2 = " ";
- $header3 = "\\textbf{Couple} ";
- for ($i=0;$i<$numRounds;$i++)
- {
- if ($numRounds==5 && $i==0)
- {
- $header2 .= "& \\multicolumn{2}{c}{Pre-Lim} ";
- switch ($eventData["Style"])
- {
- case "Standard" : $header3.= "&W & Q "; break;
- case "Latin" : $header3.= "&R & C "; break;
- case "Smooth" : $header3.= "&W & F "; break;
- case "Rhythm" : $header3.= "&R & S "; break;
- default: break;
- }
- }
- else
- {
- switch ($numRounds-$i)
- {
- case 1: $name="Final"; break;
- case 2: $name="Semi-Final"; break;
- case 3: $name="Quarter-Final"; break;
- case 4: $name="1/8-Final"; break;
- default:break;
- }
- $header2.="&\\multicolumn{{$numDances}}{c}{{$name}} ";
- $header3 .= "&" . str_replace(",","&",
- arrayToCSL($eventData["Dances"]));
- }
- if ($i%2==1)
- {
- $header2 .= "&";
- $header3 .=" & Num ";
- }
- }
- $header2 .= "\\\\ \n";
- $header3 .= "\\\\ \n";
- $header .= $header2 . $header3 . "\\hline\n";
- return $header;
- }
- function eventRow($couple, $eventData)
- {
- $numRounds = $eventData["NumRounds"];
- $numDances = count($eventData["Dances"]);
- $numBlocks = $numRounds*$numDances;
- $number = substr($couple,0,3);
- if ($numRounds==5)
- $numBlocks -= ($eventData["Style"]=="Smooth" ? 2 : 3);
- $row = "$couple ";
- for ($i=0;$i<$numRounds;$i++)
- {
- if ($numRounds==5 && $i==0)
- {
- $row.="& & ";
- }
- else
- {
- for ($j=0;$j<$numDances;$j++)
- $row.=" & ";
- }
- if ($i%2==1) $row .= "& $number ";
- }
- $row .= "\\\\ \\hline\n";
- return $row;
- }
- function eventFinals($eventData)
- {
- $numDances = count($eventData["Dances"]);
- $box = "\begin{tabular}{l||p{.75in}|p{.75in}|p{.75in}|p{.75in}|p{.75in}|p{.75in}|p{.75in}|p{.75in}|p{.75in}|}\n";;
- $box .= "Event & 9th & 8th & 7th & 6th & 5th & 4th & 3rd & 2nd & 1st \\\\\hline\n";
- for ($i=0;$i<$numDances;$i++)
- {
- $box .= $eventData["Dances"][$i]."& & & & & & & & & \\\\ \\hline\n";
- }
- $box .= "\\end{tabular}\n";
- return $box;
- }
- include("paths.inc");
- if ($argv[1]=="") die("No Comp Name provided\n");
- if ($argv[2]=="") die("No email address provided for document delivery\n");
- $unixname=$argv[1];
- if (!ereg("^[-a-zA-Z0-9_]*$",$unixname)) die ("Badly formed compname\n");
- $mailto = $argv[2];
- $CIB_TOOL_ROLE="register";
- include "$CIB_CONFIG_PATH/comps/{$unixname}_config.inc";
- if (!isset($SD_compname)) die ("Invalid Comp Name.");
- include "$CIB_INCLUDE_PATH/tools/SlidingDoors_header.inc";
- ini_alter("include_path", "$CIB_WEB_PATH/$CIB_WEB_INSTALL/$CIB_TOOL_ROLE/$unixna
- me/PREPARSED");
- $query = "SELECT distinct orgid,name FROM organizations JOIN people on (orgid=organization) join couples on (leader=peopleid);";
- $result=$db->query($query);
- $numAffils = $result->numrows();
- for ($i=0;$i< $numAffils;$i++)
- {
- list($orgid,$orgname) = $result->getRowAt($i);
- $page=latexHeader("Team Record Sheets");
- $page .= "\\begin{center}\n";
- $page .="\\LARGE Team Record Sheets\\\\ \\normalsize for\\\\ \\Huge $orgname\\\\
- \\normalsize
- \\end{center}\n";
- $page .= "These ``Team Record'' sheets are provided as an experimental
- CompInaBox service. They were designed for use by team historians, coaches,
- or videographers to quickly track all of their members in a given event at
- once. Annotate your team's callbacks, record taping times, track
- results, take notes on your couple's dancing, dar cartoon charicatures of the judges in the margins,
- or what ever else you come up with.
- In the future these sheets may be availible ahead of time from the
- Studio/Team Options page of competitions using CompInaBox for their on-line registration needs. If you need more
- copies of these sheets at the competition, there is a photocopy shop in the
- student center -- ask the workers at the registration desk for directions.
- You can email nielsene@mit.edu with suggestions for improvements to these
- sheets, or ideas for other helpful competition aides.
- \\newpage\n";
- $query =<<<END_QUERY
- SELECT DISTINCT competitornumber, l.firstname,
- f.firstname, longname, eventid, programnumber
- FROM events_registration NATURAL JOIN couples
- JOIN people AS l ON (leader=l.peopleid)
- JOIN people AS f ON (follower=f.peopleid)
- NATURAL JOIN events_names
- NATURAL JOIN events
- WHERE l.organization=$orgid OR f.organization=$orgid
- ORDER BY programnumber, competitornumber;
- END_QUERY; $innerResult = $db->query($query);
- $curEvent=0;
- $couples =array();
- $numRows = $innerResult->numrows();
- for ($j=0;$j<$numRows;$j++)
- {
- list($compNum, $leader, $follower,
- $eventname, $eventid, $progNum) = $innerResult->getRowAt($j);
- if ($follower=="TBA")$follower="\\_\\_\\_\\_\\_\\_\\_\\_";
- if ($leader=="TBA")$leader="\\_\\_\\_\\_\\_\\_\\_\\_";
- if ($curEvent!=$eventid)
- {
- if ($curEvent!=0)
- {
- $page .= eventRow("",$eventData);
- $page .= eventRow("",$eventData);
- $page .= "\end{tabular}\n\\\\\n\\\\\n\\\\\n\\\\\n\\\\\n";
- $page .= eventFinals($eventData);
- $page .= "\\newpage\n";
- }
- $eventData = getEventData($eventid,$orgid);
- $numRounds = $eventData["NumRounds"];
- $numCouples = $eventData["NumCouples"];
- $numOwnCouples = $eventData["NumOwnCouples"];
- $page.="\\begin{center}\n\\large 2003 MIT Open Ballroom Dance Competition\n$orgname\\\\\nEvent Number $progNum -- $eventname ($numOwnCouples of $numCouples Couples)\n\end{center}\n\\normalsize\n";
- $page .= eventHeader($eventData);
- $curEvent=$eventid;
- $couples=array();
- }
- $couple = "$compNum $leader \\& $follower";
- $couples[]=$couple;
- $page .= ($j%2==0? "\\rowcolor{light}":"").eventRow($couple,$eventData);
- }
- $page .= "\\end{tabular}\n\\\\\n\\\\\n\\\\\n\\\\\n\\\\\n";
- $page .= eventFinals($eventData);
- $page .= "\\end{landscape}\n";
- $page .= "\\end{document}";
- $directory = "{$CIB_WEB_PATH}register/$unixname/group/Records/";
- chdir($directory);
- $filename=str_replace(" ","_",$orgname);
- $filename=ereg_replace("[^-A-Za-z0-9_]","",$filename);
- echo "$filename <br />\n";
- $fp = fopen("{$directory}{$filename}.tex","w");
- fwrite($fp,$page);
- fclose($fp);
- exec("pdflatex $filename.tex");
- unlink("$filename.tex");
- unlink("$filename.log");
- unlink("$filename.aux");
- }
- echo "done";
- ?>
Documentation generated on Tue, 25 Apr 2006 13:11:37 -0400 by phpDocumentor 1.3.0RC3