|
|
include("../../lib/FormUILib.php");
include("../../lib/ValidateLib.php");
include("course_lists.php");
$TODAY = date("F j, Y, g:i a");
$ugcourse_max_num = 1133;
$semester_info = SpringOrFall(1);
$semester = $semester_info["SemesterName"];
$year = $semester_info["Year"];
# Use the function error_color for error notification.
function error_color($var)
{
if($_POST['Submit'])
{
if($var)
$color = '';
else
$color = 'red';
}
else
$color = '';
return $color;
}
# The function test_field re-implements the text field function in FormUILib to
# include the background error color. This significantly cleans up the code for
# the form.
function text_field($name,$size,$max)
{
$test_name = $name . '_test';
global $$test_name;
$color = error_color($$test_name);
$field = input_text_field($name,$size,$max,$color);
echo $field;
}
# Now we grab, rename, and test all the POST data.
foreach($_POST as $key=>$value)
{
$$key=$value;
}
$fname_valid = is_valid_name($firstname);
$lname_valid = is_valid_name($lastname);
$firstname_test= $fname_valid[0];
$lastname_test= $lname_valid[0];
$email_test = is_valid_email($email);
$othergradcourse1_test = has_no_code($othergradcourse1);
$othergradcourse2_test = has_no_code($othergradcourse2);
$othergradcourse3_test = has_no_code($othergradcourse3);
$other1_test = has_no_code($other1);
$other1a_test = has_no_code($other1a);
$other1b_test = has_no_code($other1b);
$other1c_test=has_no_code($other1c);
$other2_test=has_no_code($other2);
$other2a_test=has_no_code($other2a);
$other2b_test=has_no_code($other2b);
$other2c_test=has_no_code($other2c);
$other3_test=has_no_code($other3);
$other3a_test=has_no_code($other3a);
$other3b_test=has_no_code($other3b);
$other3c_test=has_no_code($other3c);
$other4_test=has_no_code($other4);
$other4a_test=has_no_code($other4a);
$other4b_test=has_no_code($other4b);
$other4c_test=has_no_code($other4c);
$comments_test=has_no_code($comments);
$gradcourse1_test = !($gradcourse1 == 'none');
$course1_test = !($course1 == 'none');
$course2_test = !($course2 == 'none');
$test = ($firstname_test && $lastname_test && $email_test && $othergradcourse1_test&& $othergradcourse2_test&& $othergradcourse3_test&& $other1_test&& $other1a_test&& $other1b_test && $other1c_test && $other2_test && $other2a_test && $other2b_test && $other2c_test && $other3_test && $other3a_test && $other3b_test && $other3c_test && $other4_test && $other4a_test && $other4b_test && $other4c_test && $comments_test);
if($test)
{
if( empty($comments)) $comments = "?";
$form_values = array($TODAY, $firstname, $lastname, $email, $grad, $gradcourse1, $gradcourse2, $gradcourse3, $gradcourse4, $othergradcourse1, $othergradcourse2, $othergradcourse3, $course1, $course2, $course3, $course4, $other1, $other1a, $other1b, $other1c, $other2, $other2a, $other2b, $other2c, $other3, $other3a, $other3b, $other3c, $other4, $other4a, $other4b, $other4c,$comments);
$file = "/MacUsers/projects/ugadmin/Data/Scheduleta_$semester" . "_$year.csv";
write_to_csv($file,$form_values);
echo "All Done! Thanks!";
$TO = $email;
$SUBJECT = "Teaching Preference Form acknowledgement";
$greeting="Dear $firstname:\n\n";
$paraBreak="\n\n";
$paragraph0 = 'Partial List of responses';
$paragraph1 = "$semester Teaching assignment choices: 1. Math " .$course1.', 2. Math '.$course2.', 3. Math '.$course3.', 4. Math '.$course4;
$paragraph2 = 'Graduate Course choices: 1. Math '.$gradcourse1.', 2. Math '.$gradcourse2.', 3. Math '.$gradcourse3.', 4. Math' .$gradcourse4;
$paragraph3 = 'Number of Graduate Courses that you expect to take: '.$grad;
$paragraph4 = 'Thank you';
$MESSAGE=$greeting.$paragraph0.$paraBreak.$paragraph1.$paraBreak.$paragraph2.$paraBreak.$paragraph3.$paraBreak.$paragraph4;
mail($TO, $SUBJECT, $MESSAGE);
}
else
{
$choices = get_courses_by_semester_year($semester,$year);
$gradcourse_choices = array_filter($choices,'is_gradcourse');
$gradcourse_choices[0]='display';
$teaching_choices = array_filter($choices,'is_ugcourse');
$teaching_choices[0]='display';
if(error_color($test))
{
print " There was an error. Please check the highlighted fields. ";
}
include("TAselection_Form.php");
}
?>
|
|