diff --git a/db/db.update.999.sql b/db/db.update.999.sql new file mode 100644 index 0000000..c77c3b2 --- /dev/null +++ b/db/db.update.999.sql @@ -0,0 +1,23 @@ +CREATE TABLE `isefforms` ( + `id` int(10) unsigned NOT NULL auto_increment, + `name` varchar(128) NOT NULL, + `required` enum('N','Y') NOT NULL, + `description` text NOT NULL, + `filename` varchar(128) default NULL, + `year` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM ; + +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1) Checklist for Adult Sponsor', 'Y', 'This completed form is required for ALL projects and must be completed before experimentation.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1A) Student Checklist', 'Y', 'This form is required for ALL projects.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1A2) Research Plan', 'Y', 'REQUIRED for ALL Projects Before Experimentation. A complete research hplan must accompany Checklist for Student (1A).', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1B) Approval Form', 'Y', 'A completed form is required for each student, including all team members.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(1C) Regulated Research Institutional/Industrial Setting Form', 'N', 'This form must be completed after experimentation by the adult supervising the student research conducted in a regulated research institution, industrial setting or an work site other than home, school or field.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(2) Qualified Scientist Form', 'N', 'May be required for researc involving human subjects, vertebrate animals, potentially hazardous biological agents, and DEA-controlled substances. Must be completed and signed before the start of student experimentation.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(3) Risk Assessment Form', 'N', 'Required for projects using hazardous chemicals, activities or devices. Must be completed before experimentation.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(4) Human Subjects Form', 'N', 'Required for all research involving human subjects. IRB approval required before experimentation.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(5A) Vertebrate Animal Form', 'N', 'Required for all research involving vertebrate animals that is conducted in a Non-Regulated Research Site. (SRC approval required before experimentation.)', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(5B) Vertebrate Animal Form', 'N', 'Required for all research involving vertebrate animals that is conducated at a Regulated Research Institution. (IACUC approval required before experimentation.)', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(6A) Potentially Hazardous Biological Agents Risk Assessment Form', 'N', 'Required for research involving microorganisms, rDNA, fresh/frozen tissue, blood and body fluids. SRC/IACUC/IBC approval required before experimentation.', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(6B) Human and Vertebrate Animal Tissue Form', 'N', 'Required for projects using fresh/frozen tissue, primary cell cultures, blood, blood products and body fluids. If the research involves living organisms, please ensure that the proper human or animal forms are completed. All projets using any tissue listed above, must also complete Form 6A', NULL, 2009); +INSERT INTO `isefforms` (`name`, `required`, `description`, `filename`, `year`) VALUES ('(7A) Continuation Projects Form', 'N', 'Required for projects that are a continuation in the same field of study as a previous project. This form must be accompanied by the previous year\'s abstract, Form (1A) and Research Plan', NULL, 2009); diff --git a/register_participants_isefforms.php b/register_participants_isefforms.php new file mode 100644 index 0000000..de721ba --- /dev/null +++ b/register_participants_isefforms.php @@ -0,0 +1,370 @@ + + + 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. +*/ +?> +<< ".i18n("Back to Participant Registration Summary")."
"; + echo "
"; + + if($_POST['action']=="save") + { + //do the "No" responses first + if(count($_POST['yesno'])) + { + foreach($_POST['yesno'] AS $k=>$v) + { + //always delete it, because if we had previousy selected "no" then we change it to "yes" we want the record to be removed + //because it will be added below by the _FILES, and if its not added there then that means we just said yes and didnt upload anything + //so removing it makes it go all red again so you are aware + + mysql_query("DELETE FROM TC_ProjectForms WHERE ProjectID='$r->id' AND FormID='$k' AND `year`='$CURRENT_FAIRYEAR'"); + + //just look at hte first letter, since its either "no:" or "yes:"; + if($v[0]=="n") + { + mysql_query("INSERT INTO TC_ProjectForms (`FormID`,`ProjectID`,`uploaded`,`dt`,`year`) VALUES ( + + '$k', + '$r->id', + '0', + NOW(), + '$CURRENT_FAIRYEAR' + )"); + + } + + + } + } + + if(!file_exists($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR)) + mkdir($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR); + + if(!file_exists($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/".$r->id)) + mkdir($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/".$r->id); + + + if(is_array($_FILES['form'])) + $keys=array_keys($_FILES['form']['name']); + else + $keys=null; + if(is_array($keys)) + { + foreach($keys AS $k) + { + if($_FILES['form']['error'][$k]==UPLOAD_ERR_OK) //==0 + { + // echo "Processing $k: ".$_FILES['form']['name'][$k]; + + //make sure its a PDF, not just a file renamed to PDF extension + $fp=fopen($_FILES['form']['tmp_name'][$k],"r"); + $firstline=fgets($fp,512); + fclose($fp); + if(substr($firstline,0,4)=="%PDF") + { + //make sure the year folder exists + $display_happy[]=i18n("PDF form [%1] detected, accepting upload",array($_FILES['form']['name'][$k])); + move_uploaded_file($_FILES['form']['tmp_name'][$k],$TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id/$k.pdf"); + + $pdfinfo=exec("pdfinfo ".$TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id/$k.pdf |grep \"Pages\""); + list($pgtext,$pgs)=split(":",$pdfinfo); + $pgs=trim($pgs); + if($pgs) $p="'$pgs'"; + else $p="null"; + + mysql_query("DELETE FROM TC_ProjectForms WHERE ProjectID='$r->id' AND FormID='$k' AND `year`='$CURRENT_FAIRYEAR'"); + mysql_query("INSERT INTO TC_ProjectForms (`FormID`,`ProjectID`,`uploaded`,`filename`,`pages`,`dt`,`year`) VALUES ( + '$k', + '$r->id', + '1', + '".mysql_escape_string($_FILES['form']['name'][$k])."', + $p, + NOW(), + '$CURRENT_FAIRYEAR' + )"); + + } + else + $display_error[]=i18n("Could not save form [%1]. It's not a PDF!",array($_FILES['form']['name'][$k])); + } + } + } + /* + if($_FILES['report']['error']==UPLOAD_ERR_OK) + { + //make sure its a PDF, not just a file renamed to PDF extension + $fp=fopen($_FILES['report']['tmp_name'],"r"); + $firstline=fgets($fp,512); + fclose($fp); + if(substr($firstline,0,4)=="%PDF") + { + //make sure the year folder exists + if(!file_exists($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR)) + mkdir($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR); + + $display_happy=i18n("PDF report detected, accepting upload"); + move_uploaded_file($_FILES['report']['tmp_name'],$TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id.pdf"); + + //now figur out some other info about the PDF + $pdfinfo=exec("pdfinfo ".$TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id.pdf |grep \"Pages\""); + list($pgtext,$pgs)=split(":",$pdfinfo); + $pgs=trim($pgs); + if($pgs) $pgquery=", ReportPages='$pgs'"; + mysql_query("UPDATE TC_Projects SET ReportFile='".$r->id.".pdf' $pgquery WHERE id='".$r->id."'"); + } + else + $display_error=i18n("Could not save uploaded report. It's not a PDF!"); + } + */ + $display_notice=i18n("Changes successfully saved"); + } + + + if($_GET['action']=="delete" && $_GET['delete']) + { + //first we need to make sure that this is their own! + $chq=mysql_query("SELECT * FROM TC_ProjectForms WHERE id='".$_GET['delete']."' AND ProjectID='$r->id' AND `year`='$CURRENT_FAIRYEAR'"); + if($chr=mysql_fetch_object($chq)) + { + @unlink($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id/$chr->FormID.pdf"); + mysql_query("DELETE FROM TC_ProjectForms WHERE id='".$_GET['delete']."' AND ProjectID='$r->id' AND `year`='$CURRENT_FAIRYEAR'"); + $display_happy=i18n("Form successfully deleted"); + } + else + { + $display_error=i18n("You do not have access to delete that form"); + } + } + + send_header("ISEF Forms"); +?> + + + +"; + echo ""; + //echo "

".htmlspecialchars($r->ProjectTitle)."

"; +// echo "
"; + echo i18n("Please use the ISEF Rules Wizard to determine which forms you need to upload"); + echo "
"; + //FIXME: this redirects to societyforscience.org somewhere, fix the url + echo "www.sciserv.org/isef/students/wizard/index.asp"; + echo "
"; + echo "
"; + + echo ""; + +/* +//FIXME: put this back in once hte table is created, took it out to avoid errors temporarily + $ufq=mysql_query("SELECT * FROM TC_ProjectForms WHERE ProjectID='$r->id' AND `year`='".$CURRENT_FAIRYEAR."'"); + $uploadedforms=array(); + while($ufr=mysql_fetch_object($ufq)) + { + $uploadedforms[$ufr->FormID]=$ufr; + } + */ + + $fq=mysql_query("SELECT * FROM isefforms ORDER BY name"); + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + while($fr=mysql_fetch_object($fq)) + { + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; +// echo ""; + + } + +/* + if(file_exists($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id.pdf")) + { + echo i18n("Your report has been uploaded. Use the link below to download your report for confirmation, or you may re-upload your report by using the 'Re-Upload Report' file selector below"); + echo "
"; + echo "
"; + echo "
".i18n("Form")."".i18n("Required?")."".i18n("Upload / File")."
"; + if($fr->filename) { + echo "description\" href=\"tcforms/$CURRENT_FAIRYEAR/".rawurlencode($fr->filename)."\">"; + } + echo $fr->name; + if($fr->filename) + echo ""; + echo "
$fr->description
"; + if($fr->required=="Y") + echo i18n("required"); + else + echo i18n("optional"); + echo ""; + if($uploadedforms[$fr->id]->uploaded) + { + echo "id]->id}\">"; + } + echo ""; + + // if(file_exists("$TCFORMSLOCATION/$CURRENT_FAIRYEAR/$r->id/$fr->id.pdf")) + if($uploadedforms[$fr->id]->uploaded) + { + $uf=$uploadedforms[$fr->id]; + + // echo happy("id\">".htmlspecialchars($uf->filename)."",true); + echo "id\">".htmlspecialchars($uf->filename).""; + } + else + { + if($fr->required=="Y") + echo error(i18n("No file uploaded"),true); + + if($fr->required=="N") + { + if($uploadedforms[$fr->id]) + echo "
"; + else + echo "
"; + + echo i18n("Upload this form?")." "; + if($uploadedforms[$fr->id] && !$uploadedforms[$fr->id]->uploaded) + { + $ch="checked=\"checked\""; + $nodivdisplay=""; + } + else + { + $nodivdisplay="none"; + $ch=""; + } + echo ""; + echo "id]\" value=\"no:$fr->id\">No "; + echo "id]\" value=\"yes:$fr->id\">Yes "; + echo ""; + echo "
"; + echo "
id\">"; + echo "id]\">"; + echo "
"; + echo "
id\">"; + echo i18n("I do not need to upload this form"); + echo "
"; + } + else + { + echo "id]\">"; + + } + } + + echo "
"; + echo "id\">".i18n("Download Report").""; + echo i18n("Filesize: %1 bytes",array(filesize($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id.pdf")))."
"; + echo i18n("Uploaded: %1",array(date("Y-m-d H:i:s",filemtime($TCFORMSLOCATION."/".$CURRENT_FAIRYEAR."/$r->id.pdf"))))."
"; + echo i18n("Pages: %1",array($r->ReportPages))."
"; + echo "
"; + $uploadtext="Re-Upload Report"; + echo "
"; + } + else + { + echo i18n("Please upload your new project report (max 6MB). It must be a PDF file."); + $uploadtext="Upload Report"; + } + */ + + echo ""; + echo i18n("After selecting your files, you must click 'Save and Upload Forms' at the bottom of this page to finish uploading the selected forms. Please be patient as it might take a few minutes depending on the speed of your internet connection"); + echo ""; + + echo " "; + + echo ""; + echo ""; + echo ""; +send_footer(); +?>