* Copyright (C) 2005 James Grant * * 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. */ // This file was modified March of 2015 by Sebastian Ruan // Receive all button was added ?> 'committee_main.php', 'Administration' => 'admin/index.php', 'Participant Registration' => 'admin/registration.php')); echo '
'; $showformatbottom = true; if (get_value_from_array($_POST, 'action') == 'received' && get_value_from_array($_POST, 'registration_number')) { $q = $pdo->prepare("SELECT * FROM registrations WHERE num=? AND year=?"); $q->execute([$_POST['registration_number'],$config['FAIRYEAR']]); if ($q->rowCount() == 1) { $r = $q->fetch(PDO::FETCH_OBJ); $reg_id = $r->id; $reg_num = $r->num; $reg_status = $r->status; if ($r->status == 'new') { echo error(i18n('Invalid Registration Status (%1 is New). Cannot receive an empty form.', array($_POST['registration_number']))); } else { // make sure all of the statuses are correct $statusstudent = studentStatus($reg_id); $statusemergencycontact = emergencycontactStatus($reg_id); $statusproject = projectStatus($reg_id); if ($config['participant_mentor'] == 'yes') $statusmentor = mentorStatus($reg_id); else $statusmentor = 'complete'; $statussafety = safetyStatus($reg_id); $statusnamecheck = namecheckStatus($reg_id); if ( $statusstudent == 'complete' && $statusemergencycontact == 'complete' && $statusproject == 'complete' && $statusmentor == 'complete' && $statussafety == 'complete' && $statusnamecheck == 'complete' ) { $q = $pdo->prepare("SELECT projects.title, projectcategories.category, projectdivisions.division FROM projects,projectcategories,projectdivisions WHERE projects.registrations_id=? AND projects.projectcategories_id=projectcategories.id AND projects.projectdivisions_id=projectdivisions.id AND projectcategories.year=projects.year AND projectdivisions.year=projects.year "); $q->execute([$reg_id]); show_pdo_errors_if_any($pdo); $projectinfo = $q->fetch(PDO::FETCH_OBJ); echo ''; echo ''; switch ($reg_status) { case 'paymentpending': $status_text = 'Payment Pending'; break; case 'complete': $status_text = 'Complete'; break; case 'open': $status_text = 'Open'; break; } echo '"; echo '"; echo '"; echo '"; $q = $pdo->prepare("SELECT students.firstname, students.lastname, schools.school FROM students,schools WHERE students.registrations_id=? AND students.schools_id=schools.id "); $q->execute([$reg_id]); $studnum = 1; while ($studentinfo = $q->fetch(PDO::FETCH_OBJ)) { echo '"; echo '"; $studnum++; } list($regfee, $regfeedata) = computeRegistrationFee($reg_id); echo ''; echo "
' . i18n('Registration Summary for %1', array($reg_num)) . '
' . i18n('Registration Status') . "$status_text
' . i18n('Registration Number') . "$reg_num
' . i18n('Project Title') . "$projectinfo->title
' . i18n('Category / Division') . "$projectinfo->category / $projectinfo->division
' . i18n('School %1', array($studnum)) . "$studentinfo->school
' . i18n('Student %1', array($studnum)) . "$studentinfo->firstname $studentinfo->lastname
' . i18n('Registration Fee') . '' . sprintf('$%.02f', $regfee) . '
\n"; echo '
'; if ($r->status != 'complete') { echo ''; echo ''; echo ''; echo '\n"; echo ''; echo '
'; echo i18n('Is this the correct form to register?'); echo '
'; echo '
'; echo ""; echo ''; echo ''; echo '
'; if ($config['regfee'] > 0) { echo '
'; echo ""; echo ''; echo ''; echo '
'; echo '
'; echo ""; echo ''; echo ''; echo '
'; } else { echo '
'; echo ""; echo ''; echo ''; echo '
'; } echo '
'; echo "
'; $showformatbottom = false; } else { echo i18n('This form has already been received. Registration is complete'); echo '
'; echo "" . i18n('Click here to unregister this project') . ''; echo '
'; echo '
'; } } else { echo error(i18n('All registration sections are not complete. Cannot register incomplete form')); } } } else { echo error(i18n('Invalid Registration Number (%1)', array($_POST['registration_number']))); } } else if ((get_value_from_array($_POST, 'action') == 'receivedyes' || get_value_from_array($_POST, 'action') == 'receivedyesnocash') && get_value_from_array($_POST, 'registration_number')) { $regnum = intval($_POST['registration_number']); $checkNumQuery = $pdo->prepare("SELECT projectnumber FROM projects, registrations WHERE projects.registrations_id = registrations.id AND num=? AND registrations.year=?"); $checkNumQuery->execute([$regnum,$config['FAIRYEAR']]); $checkNumResults = $checkNumQuery->fetch(PDO::FETCH_OBJ); $projectnum = $checkNumResults->projectnumber; $q = $pdo->prepare("SELECT id FROM registrations WHERE num=? AND year=?"); $q->execute([$regnum, $config['FAIRYEAR']]); $r = $q->fetch(PDO::FETCH_OBJ); $reg_id = $r->id; if ($projectnum == null) { list($projectnumber, $ps, $pns, $pss) = generateProjectNumber($reg_id); $stmt = $pdo->prepare("UPDATE projects SET projectnumber='$projectnumber', projectsort='$ps',projectnumber_seq='$pns',projectsort_seq='$pss' WHERE registrations_id='$reg_id' AND year=$config{['FAIRYEAR']}"); $stmt->execute(); echo happy(i18n('Assigned Project Number: %1', array($projectnumber))); } else $projectnumber = $projectnum; // get all students with this registration number $recipients = getEmailRecipientsForRegistration($reg_id); if ($_POST['action'] == 'receivedyes') { // actually set it to 'complete' $stmt = $pdo->prepare("UPDATE registrations SET status='complete' WHERE num=? AND year=?"); $stmt->execute([$regnum,$config['FAIRYEAR']]); foreach ($recipients AS $recip) { $to = $recip['to']; $subsub = array(); $subbod = array( 'TO' => $recip['to'], 'EMAIL' => $recip['email'], 'FIRSTNAME' => $recip['firstname'], 'LASTNAME' => $recip['lastname'], 'NAME' => $recip['firstname'] . ' ' . $recip['lastname'], 'REGNUM' => $regnum, 'PROJECTNUMBER' => $projectnumber, ); email_send('register_participants_received', $to, $subsub, $subbod); } echo happy(i18n('Registration of form %1 successfully completed', array($regnum))); } else if ($_POST['action'] == 'receivedyesnocash') { // actually set it to 'paymentpending' $stmt = $pdo->prepare("UPDATE registrations SET status='paymentpending' WHERE num=? AND year=?"); $stmt->execute([$regnum,$config['FAIRYEAR']]); foreach ($recipients AS $recip) { $to = $recip['to']; $subsub = array(); $subbod = array( 'TO' => $recip['to'], 'EMAIL' => $recip['email'], 'FIRSTNAME' => $recip['firstname'], 'LASTNAME' => $recip['lastname'], 'NAME' => $recip['firstname'] . ' ' . $recip['lastname'], 'REGNUM' => $regnum, 'PROJECTNUMBER' => $projectnumber, ); email_send('register_participants_paymentpending', $to, $subsub, $subbod); } echo happy(i18n('Registration of form %1 marked as payment pending', array($regnum))); } } else if (get_value_from_array($_POST, 'action') == 'receivedno' && get_value_from_array($_POST, 'registration_number')) { echo notice(i18n('Registration of form %1 cancelled', array($_POST['registration_number']))); } else if (get_value_from_array($_GET, 'action') == 'unregister' && get_value_from_array($_GET, 'registration_number')) { $reg_num = intval(trim($_GET['registration_number'])); $q = $pdo->prepare("SELECT registrations.id AS reg_id, projects.id AS proj_id FROM projects,registrations WHERE projects.registrations_id=registrations.id AND registrations.year=? AND registrations.num=?"); $q->execute([$config['FAIRYEAR'],$reg_num]); $r = $q->fetch(PDO::FETCH_OBJ); $stmt = $pdo->prepare("UPDATE projects SET projectnumber=null, projectsort=null, projectnumber_seq=0, projectsort_seq=0 WHERE id=? AND year=?"); $stmt->execute([$r->proj_id,$config['FAIRYEAR']]); $stmt = $pdo->prepare("UPDATE registrations SET status='open' WHERE id=? AND year=?"); $stmt->execute([$r->reg_id,$config['FAIRYEAR']]); echo happy(i18n('Successfully unregistered project')); } if ($showformatbottom) { echo ''; echo ''; echo '
'; echo '
'; echo ''; echo i18n("Enter the registration number from the $signatureformpermissionform : ") . '
'; echo ''; echo ''; echo '
'; ?>
'; echo '
'; echo 'This button does not keep track of payments'; echo '
'; echo '
'; echo ''; echo '"; echo '
'; echo '
'; echo '
'; echo i18n(" 'Receive All' notes: "); } if (get_value_from_array($_POST, 'action') == 'receive_all') { // Grab all projects that don't have project numbers. Status should therefor be open or new but not complete $query_noprojectnumber = $pdo->prepare('SELECT * FROM projects WHERE projectnumber IS NULL AND year =?'); // Define arrays to append to later $query_noprojectnumber->execute([$config['FAIRYEAR']]); $completed_students = array(); $incomplete_students = array(); $newstatus_students = array(); // loop through each project that doesn't have a project number while ($studentproject = $query_noprojectnumber->fetch(PDO::FETCH_ASSOC)) { // Grab registration information about the current project $q = $pdo->prepare("SELECT * FROM registrations WHERE id=? AND year=?"); $q->execute([$studentproject['registrations_id'],$config['FAIRYEAR']]); $r = $q->fetch(PDO::FETCH_OBJ); $reg_id = $r->id; $reg_num = $r->num; $reg_status = $r->status; // student has completed some or all of the registration process for their project. Let's find out which one is true if ($r->status != 'new') { // make sure all of the statuses are correct $statusstudent = studentStatus($reg_id); $statusemergencycontact = emergencycontactStatus($reg_id); $statusproject = projectStatus($reg_id); if ($config['participant_mentor'] == 'yes') $statusmentor = mentorStatus($reg_id); else $statusmentor = 'complete'; $statussafety = safetyStatus($reg_id); $statusnamecheck = namecheckStatus($reg_id); if ( $statusstudent == 'complete' && $statusemergencycontact == 'complete' && // S$statusproject == "complete" && $statusmentor == 'complete' && $statussafety == 'complete' && $statusnamecheck == 'complete' && $r->status != 'complete' // above: project status must not be complete. If it is complete signature page/permission form has already been received. ) { // Generate project number and update it in data base list($projectnumber, $ps, $pns, $pss) = generateProjectNumber($reg_id); $stmt = $pdo->prepare("UPDATE projects SET projectnumber=?, projectsort=?,projectnumber_seq=?,projectsort_seq=? WHERE registrations_id=? AND year=?"); $stmt->execute([$projectnumber,$ps,$pns,$pss,$reg_id,$config['FAIRYEAR']]); // email stuff // get all students with this registration number // $recipients=getEmailRecipientsForRegistration($reg_id); // Set status to 'complete' $stmt = $pdo->prepare("UPDATE registrations SET status='complete' WHERE num=? AND year=?"); $stmt->execute([$reg_num,$config['FAIRYEAR']]); /*foreach($recipients AS $recip) { $to=$recip['to']; $subsub=array(); $subbod=array( "TO"=>$recip['to'], "EMAIL"=>$recip['email'], "FIRSTNAME"=>$recip['firstname'], "LASTNAME"=>$recip['lastname'], "NAME"=>$recip['firstname']." ".$recip['lastname'], "REGNUM"=>$regnum, "PROJECTNUMBER"=>$projectnumber, ); email_send("register_participants_received",$to,$subsub,$subbod); }*/ // End email stuff // add cuurent registration number to completed_students array $completed_students[] = $reg_num; } else { // or add current registration number to incomplete_student array $incomplete_students[] = $reg_num; } } // New status automatically means student has not completed the registration process for their project. So execute below: else { // or add current registration number to newstatus_students array $newstatus_students[] = $reg_num; } } // Find how many project numbers were assigned/how many projects have complete status (ie signature page/permission form is considered received) $total_completed = count($completed_students); // since incomplete_students and newstatus_students both did not get project numbers and are not considered as having signature page/permission form received // combine them $total_incomplete = array_merge($incomplete_students, $newstatus_students); echo '

'; echo ''; echo ''; // display below only if there are registration numbers that don't have project numbers and the students have not completed the registration process if (count($total_incomplete) > 0) { echo ''; echo ''; $string = ''; echo ''; echo ''; echo ''; } echo '
' . i18n("$total_completed student(s) registered as $non_capital_participationform received.") . '
' . i18n("Registration numbers which are NOT marked as having their $non_capital_participationform received are shown below:") . '
 
'; // create a string that contains all incomplete registration numbers foreach ($total_incomplete as $regnum) { $string = $string . i18n($regnum); $string = $string . ', '; } // delete the comma at the end of the string $string = substr($string, 0, strlen($string) - 2); echo $string; echo '
 
'; echo i18n('The above registration numbers correspond to projects in which the registration process has not been completed by the student.'); echo '
'; echo happy_(i18n('Received all permision forms for complete students')); } send_footer(); ?>