0) { $visit = 0; post_int($visit, 'visit'); $notes = $mysqli->real_escape_string($_POST['notes']); $mysqli->real_query("DELETE FROM visit_list WHERE uid='{$u['uid']}' AND pid='$pid'"); print($mysqli->error); $mysqli->real_query("INSERT INTO visit_list(`uid`,`pid`,`notes`,`visit`) VALUES('{$u['uid']}','$pid','$notes','$visit')"); print($mysqli->error); form_ajax_response(0); exit(); } form_ajax_response(1); exit(); case 'print': $projects = l_projects_load_all($mysqli, $config['year'], $u); $timeslots = timeslots_load_all($mysqli); $generate_rounds = array(); for($round=0;$round&$ts) { $timeslots_by_round[$ts['round']] = $ts; } foreach($projects as &$project) { $project['timeslots'] = array(); foreach($timeslots as $timeslot_id=>&$ts) { $project['timeslots'][$timeslot_id] = array(); } } $q = $mysqli->query("SELECT * FROM timeslot_assignments WHERE year='{$config['year']}'"); while($r = $q->fetch_assoc()) { $pid = $r['pid']; $judge_id = $r['judge_id']; $jteam_id = $r['judging_team_id']; $timeslot_num = $r['timeslot_num']; $timeslot_id = $r['timeslot_id']; /* Make a list of slot types for each round for each project */ $projects[$pid]['timeslots'][$timeslot_id][$timeslot_num] = $r['type']; } $pdf=new pdf( "Visit List", $config['year'] ); foreach($generate_rounds as $round ) { $ts = &$timeslots_by_round[$round]; $timeslot_id = $ts['id']; /* Do the rounds in order, we built this array in order */ $pdf->AddPage(); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->setFontSize(14); $pdf->SetXY(-40, 10); $pdf->Cell(30, 0, $ts['name'], 0); $pdf->SetXY($x, $y); $pdf->setFontSize(11); $n = array(); $html = "

{$u['firstname']}'s Visit List




"; $pdf->WriteHTML($html); $table = array('col'=>array(), 'widths'=>array() ); $table['fields'] = array('time'); $table['header']['time'] = 'Time'; $table['col']['time'] = array('on_overflow' => '', 'align' => 'center'); $table['widths']['time'] = 20; $table['total'] = 0; $table['data'] = array(); /* Use the same logic for cusp and SA teams, except query a different slot type */ $slot_type = 'special'; $table['header']['time'] = 'Project'; for($itimeslot=0; $itimeslot<$ts['num_timeslots']; $itimeslot++) { $table['fields'][] = "T$itimeslot"; $table['header']["T$itimeslot"] = date("g:i", $ts['timeslots'][$itimeslot]['start_timestamp']); $table['col']["T$itimeslot"] = array('on_overflow' => '', 'align' => 'center'); $table['widths']["T$itimeslot"] = 20; } $sorted_project_ids = array(); foreach($projects as &$p) { $sorted_project_ids[$p['number_sort']] = $p['pid']; } ksort($sorted_project_ids); $showed_vbar = false; foreach($sorted_project_ids as $pid) { $row = array(); $project = &$projects[$pid]; if($project['visit'] == 0) continue; $row['time'] = $project['number']; for($itimeslot=0; $itimeslot<$ts['num_timeslots']; $itimeslot++) { if($project['timeslots'][$timeslot_id] == NULL) { print("project $pid timeslots [$timeslot_id] is nULL\n"); print_r($project); } if(!array_key_exists($itimeslot, $project['timeslots'][$timeslot_id])) { print("
Timeslot $itimeslot doesn't exist in timeslots[$timeslot_id] for pid:$pid: ");
						print_r($project);
						exit();
					}

			
				$txt = '';
				if($project['timeslots'][$timeslot_id][$itimeslot] == $slot_type) {
					$txt = 'O';
				} else if($slot_type == 'special' && $project['timeslots'][$timeslot_id][$itimeslot] == 'divisional') {
					$txt = '+';
					$showed_vbar =true;
				}
				$row["T$itimeslot"] = $txt;
			}
			$table['data'][] = $row;
		}


		$pdf->add_table($table);
		$pdf->WriteHTML("
"); } print($pdf->output()); exit(); } function l_projects_load_all($mysqli, $year, &$u) { /* Load projects first */ $q = $mysqli->query("SELECT * FROM projects WHERE year='$year' ORDER BY number_sort "); $projects_tmp = array(); while($p = $q->fetch_assoc()) { $p_temp = project_load($mysqli, $p['pid'], $p); $projects_tmp[$p['pid']] = $p_temp; } $projects = array(); /* Now match users to projects, copying projects * into the real return array as we find them */ $q = $mysqli->query("SELECT users.*,schools.school FROM users LEFT JOIN schools ON users.schools_id=schools.id WHERE users.year='$year' AND users.enabled = '1' AND users.new = '0' AND FIND_IN_SET('student', users.`roles`)>0 "); $users = array(); while($j = $q->fetch_assoc()) { $p_user = user_load($mysqli, -1, -1, NULL, $j); $pid = $p_user['s_pid']; if($pid == 0) { print("No project for student uid={$p_user['uid']}
"); } if(!array_key_exists($pid, $projects)) { $projects[$pid] = $projects_tmp[$pid]; $projects[$pid]['students'] = array(); $projects[$pid]['s_complete'] = true; } $projects[$pid]['students'][] = $p_user; if($p_user['s_complete'] == 0) { $projects[$pid]['s_complete'] = false; } $projects[$pid]['visit'] = false; $projects[$pid]['visit_notes'] = ''; } $q = $mysqli->query("SELECT pid,notes,visit FROM visit_list WHERE uid='{$u['uid']}'"); while($d = $q->fetch_row()) { $pid = (int)$d[0]; $notes = $d[1]; $visit = (int)$d[2]; if(array_key_exists($pid, $projects)) { $projects[$pid]['visit'] = $visit; $projects[$pid]['visit_notes'] = $notes; } } return $projects; } $page_id = 'c_visit_list'; $help = '

'; sfiab_page_begin($u, "Visit List", $page_id, $help); ?>

Visit List

  • Project :

    , Grade ,

    'Visit'); form_check_group($form_id, 'visit', NULL, $data, $p['visit']); ?>