Copyright (C) 2011 Dennis Spanogle 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. */ ?> 0) { echo "File Selection / upload Error: Return Code: " . $_FILES["file"]["error"] . "
"; echo "

Return
"; exit; } else { echo "Uploading: " . $_FILES["file"]["name"] . "
"; //echo "Type: " . $_FILES["file"]["type"] . "
"; //echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
"; if (file_exists("uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists - OLD COPY WAS DELETED
"; unlink("uploads/" . $_FILES["file"]["name"]); } //else { move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); $filename = "uploads/". $_FILES["file"]["name"]; //echo "
Stored in: ".$filename."
"; //open the file $fh = fopen($filename, 'r'); //$theData = fread($fh, filesize($filename)); while (($data = fgetcsv($fh, 60, ",")) !== FALSE) { $num = count($data); //echo "

$num fields in line $row:

\n"; if ($num != 9){ echo "Number of fields in file not equal to 9. Incorrect File - Try Again!"; fclose($fh); // delete the file unlink($filename); echo "

Return
"; exit; } $row++; // get each item in the csv record there are 9 items $Apperson_num = $data[0]; $team_num = $data[1]; // IMPORTANT This only works if the setup is done following the rules for using the Apperson Scanner. // The project numbers are all unique after removing the first digit (the Category ID) $qstr = "SELECT judges_teams.num, projects.projectnumber, projects.projectcategories_id, ". "eval_projects_entries.criteria_id, eval_projects_entries.level_id, ". "eval_projects_entries.id, SUBSTR(projects.projectnumber, 2) AS apppProj ". "FROM eval_projects_entries, projects, judges_teams ". "WHERE eval_projects_entries.project_id = projects.id AND ". "eval_projects_entries.judges_teams_id = judges_teams.id AND ". "(judges_teams.num = '".$team_num."') AND ". "(SUBSTR(projects.projectnumber, 2) = '".$Apperson_num."') ORDER BY eval_projects_entries.criteria_id"; $q = mysql_query($qstr) ; if (!$q OR mysql_num_rows($q) == 0){ if(!$q){ echo "q = FALSE!
"; } echo "No Matching record for team number ".$team_num." and Apperson Project number ".$Apperson_num."
"; fclose($fh); // delete the file unlink($filename); echo "
Need to keep trying Ask Dennis to fix
Return
"; exit; } if (mysql_num_rows($q) == 6){ // 6 criteria for each judgeteam-project is required to upload Apperson data while($r=mysql_fetch_object($q)) { $project_num = $r->projectnumber; $record_id = $r->id; switch ($r->criteria_id) { case 1: //Creative Ability //echo " update CAS 1= ".$data[2 ]; mysql_query("UPDATE eval_projects_entries SET level_id = '".$data[2]."' WHERE id = '".$record_id."'"); break; case 2: // Scientific Thought //echo " update STS 2= ".$data[3 ]; mysql_query("UPDATE eval_projects_entries SET level_id = '".$data[3]."' WHERE id = '".$record_id."'"); break; case 3: // Thouroughness //echo " update THS 3= ".$data[4 ]; mysql_query("UPDATE eval_projects_entries SET level_id = '".$data[4]."' WHERE id = '".$record_id."'"); break; case 4 : // Skill //echo " update SKS 4= ".$data[5 ]; mysql_query("UPDATE eval_projects_entries SET level_id = '".$data[5]."' WHERE id = '".$record_id."'"); break; case 5: //Clairity //echo " update CLS 5= ".$data[6 ]; mysql_query("UPDATE eval_projects_entries SET level_id = '".$data[6]."' WHERE id = '".$record_id."'"); break; case 6: //Teamwork //echo " update TWS 6= ".$data[7 ]; mysql_query("UPDATE eval_projects_entries SET level_id = '".$data[7]."' WHERE id = '".$record_id."'"); break; } } // while } else { echo "Evaluations table eval_projects_entries is Not setup for Apperson Data Import.
There are not exactly 6 criteria for judgeteam ".$team_num." project number ".$project_num."
"; fclose($fh); // delete the file unlink($filename); echo "

Return
"; exit; } } fclose($fh); // delete the file unlink($filename); echo $row." records entered in database
"; //echo "

File deleted
"; } } } else { echo "Invalid file"; } echo "

Return
"; ?>