\n"); $error_message = "Invalid Access"; header("Location: /?error_message=" . urlencode($error_message)); exit(); } // startLog("class-list.print.php"); unset($student_num); if (array_key_exists('student_num',$_GET)) $student_num = intval($_GET['student_num']); if (array_key_exists('student_num',$_POST)) $student_num = intval($_POST['student_num']); if ($_SESSION['UserInfo']['type'] == 'Parent' || isset($student_num)) { if ($school_record['display_class_lists'] == 'Y') { if (!isset($student_num)) { echo("
\n"); $error_message = getLanguageText('ERRORMSG-INVALID-ACCESS'); header("Location: /?error_message=" . urlencode($error_message)); exit(); } // Verify that this student is linked to the current user $unum = $_SESSION['UserInfo']['record_num']; $query = "select * from people " . "where school_num = $base_school_num " . "and user_num = $unum " . "and people_type = 'Student' " . "and record_num = $student_num"; $results = db_query($query); if (db_num_rows($results) == 0) { echo("
\n"); $error_message = getLanguageText('ERRORMSG-INVALID-ACCESS'); header("Location: /?error_message=" . urlencode($error_message)); exit(); } $student = db_fetch_array($results); // Get class_num $class_num = $student['class_num']; if ($school_record['verified_only_class_list'] == 'Y' && $student['status'] != 'Verified') { echo("
\n"); $error_message = getLanguageText('ERRORMSG-ACCESS-NOT-PERMITTED'); header("Location: /?error_message=" . urlencode($error_message)); exit(); } } // Handle 'All' class lists flexibility if ($school_record['display_class_lists'] == 'A') { unset($class_num); if (array_key_exists('class_num',$_GET)) $class_num = intval($_GET['class_num']); if (array_key_exists('class_num',$_POST)) $class_num = intval($_POST['class_num']); } // Deal with 'No' class lists if ($school_record['display_class_lists'] == 'N') { echo("
\n"); $error_message = getLanguageText('ERRORMSG-INVALID-ACCESS'); header("Location: /?error_message=" . urlencode($error_message)); exit(); } } else { unset($class_num); if (array_key_exists('class_num',$_GET)) $class_num = intval($_GET['class_num']); if (array_key_exists('class_num',$_POST)) $class_num = intval($_POST['class_num']); } // Get class info if (isset($class_num)) { $query = "select * from classes as c " . "where c.school_num = $school_num " . "and c.record_num = $class_num"; } else { $query = "select * from classes as c " . "where c.school_num = $school_num " . "order by c.sequence"; } $classes = db_query($query); // // Setup the PDF // $document_font = $school_record['document_font']; if (strlen($document_font) == 0) $document_font = "Helvetica"; $document_font_weight = ""; $document_text_color = "#000000"; $document_font_size = 9; $left_col = 20; $middle_col = 100; // // Setup PDF document // require("tcpdf/tcpdf.php"); // Set parameters for this document $left_col = 15; $title_width = 250; $max_rows = 190; $name_col = 15; $contact_col = 65; $home_phone_col = 115; $work_phone_col = 145; $cell_phone_col = 175; $email_col = 205; $name_width = $contact_col - $name_col - 1; $contact_width = $home_phone_col - $contact_col - 1; $phone_width = $work_phone_col - $home_phone_col - 1; $email_width = 60; $start_row = 10; $incr = 4.5; $logo_url = $school_record['logo_url']; $logo_image = "images/" . $school_record['logo_image']; $logo_row = $max_rows + 5; class PDF extends TCPDF { function Header() { global $incr, $left_col, $start_row, $title_width, $document_font, $document_font_size, $report_title, $report_subtitle, $class_parent_name; // Print the header $this->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee")); $this->SetFont($document_font,"B",$document_font_size + 2); $this->SetXY($left_col,$start_row); $this->Cell($title_width,$incr + 1," $report_title",'0',1,'L',true); if (isset($report_subtitle) && strlen($report_subtitle) > 0) { $offset = 150; $this->SetXY($left_col + $offset,$start_row); $this->Cell($title_width - $offset,$incr + 1,"$report_subtitle ",'0',1,'R',true); } if (isset($class_parent_name) && strlen($class_parent_name) > 0) { $this->SetFont($document_font,"B",$document_font_size + 0); $this->SetXY($left_col,$start_row + $incr + 2); $this->Cell($title_width,$incr," ",'0',1,'L',true); $offset = 150; $this->SetXY($left_col + $offset,$start_row + $incr + 2); $this->Cell($title_width - $offset,$incr,getLanguageText('TEXT-CLASS-PARENT').": $class_parent_name ",'0',1,'R',true); } } function Footer() { global $incr, $left_col, $title_width, $max_rows, $document_font, $document_font_size, $document_name, $logo_image, $logo_url, $logo_row, $school_name; // Print the date $this->SetFont($document_font,"",$document_font_size - 1); $this->SetXY($left_col,$logo_row); $date = dateString('datetime'); $this->Cell($title_width,$incr - 1,"$document_name: $date",'0',1,'R'); $this->SetXY($left_col,$logo_row + $incr); $this->Cell($title_width,$incr - 1,"$school_name",'0',1,'R','',1); $this->Image($logo_image,10,$logo_row, 50); $this->SetXY(20,$logo_row + 9); $this->SetFont($document_font,"B",$document_font_size); $this->Cell($title_width,$incr,$logo_url,'0',1,'L'); } } // Force exact physical size for Letter: 8.5 x 11 inches => 279.4mm x 215.9mm (landscape) $pageFormat = array(279.4, 215.9); $pdf = new PDF('L', 'mm', $pageFormat, true, 'UTF-8', false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $font_red = hexdec("00"); $font_green = hexdec("00"); $font_blue = hexdec("00"); $pdf->SetTextColor($font_red,$font_green,$font_blue); $pdf->SetFont($document_font,"",$document_font_size); $school_name = $school_record['school_name']; $document_name = getLanguageText('TEXT-CLASS-LIST'); // Set student display flag based on user type $swhere = "and display = 'Y' "; if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Communications Administrator','Staff','Administration Team','Schedule Team'))) $swhere = ""; // Process selected teacher(s) while ($class = db_fetch_array($classes)) { $class_num = $class['record_num']; $class_parent = $class['class_parent']; $class_info = getClassInfo($class_num); $class_parent_name = ''; if (isset($class_parent) && intval($class_parent) > 0) { $class_parent_name = db_getVal("SELECT concat(first_name,' ',last_name) FROM users WHERE school_num = $base_school_num AND record_num = $class_parent"); } $curr_row = $max_rows; // Get students in this class $query = "select * from people " . "where school_num = $base_school_num " . "and class_num = $class_num " . "and people_type = 'Student' " . $swhere . "order by last_name,first_name"; $students = db_query($query); $student_count = 0; while ($row = db_fetch_array($students)) { if ($curr_row > $max_rows - 5) { $report_title = $school_name; $report_subtitle = $class_info; $pdf->addPage(); $curr_row = $start_row + $incr * 2; if (isset($class_parent) && intval($class_parent) > 0) $curr_row += $incr; // Print headers $pdf->SetFont($document_font,"B",10); $pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd")); $pdf->SetXY($name_col,$curr_row); $pdf->Cell($name_width,$incr,getLanguageText('TEXT-NAME'),'0',1,'L',true); $ctext = ""; if ($school_record['c_display_name'] == 'Y') $ctext = getLanguageText('TEXT-CONTACT'); $pdf->SetXY($contact_col,$curr_row); $pdf->Cell($contact_width,$incr,$ctext,'0',1,'L',true); $ctext = ""; if ($school_record['c_display_home_phone'] == 'Y') $ctext = getLanguageText('TEXT-HOME'); $pdf->SetXY($home_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$ctext,'0',1,'L',true); $ctext = ""; if ($school_record['c_display_work_phone'] == 'Y') $ctext = getLanguageText('TEXT-WORK'); $pdf->SetXY($work_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$ctext,'0',1,'L',true); $ctext = ""; if ($school_record['c_display_cell_phone'] == 'Y') $ctext = getLanguageText('TEXT-CELL'); $pdf->SetXY($cell_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$ctext,'0',1,'L',true); $ctext = ""; if ($school_record['c_display_home_email'] == 'Y') $ctext = getLanguageText('TEXT-EMAIL'); $pdf->SetXY($email_col,$curr_row); $pdf->Cell($email_width,$incr,$ctext,'0',1,'L',true); $pdf->SetFont($document_font,"",9); $pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee")); $curr_row += $incr; } $snum = $row['record_num']; $name = $row['first_name'] . " " . $row['last_name']; $unum = $row['user_num']; if ($school_record['display_class_lists'] != 'Y') { $query = "select *,email AS home_email,daytime_phone AS work_phone from users " . "where school_num = $base_school_num " . "and record_num = $unum " . "order by last_name,first_name"; $contacts = db_query($query); } else { $query = "select * from contacts " . "where school_num = $school_num " . "and user_num = $unum " . "order by last_name,first_name"; $contacts = db_query($query); } if (db_num_rows($contacts) > 0) { $fill = false; if ($student_count % 2) $fill = true; $student_count++; while ($row = db_fetch_array($contacts)) { extract($row); $contact = $first_name . " " . $last_name; $pdf->SetXY($name_col,$curr_row); $pdf->Cell($name_width,$incr,$name,'0',1,'L',$fill,'',1); if ($school_record['c_display_name'] == 'N') $contact = ""; $pdf->SetXY($contact_col,$curr_row); $pdf->Cell($contact_width,$incr,$contact,'0',1,'L',$fill,'',1); if ($school_record['c_display_home_phone'] == 'N') $home_phone = ""; $pdf->SetXY($home_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$home_phone,'0',1,'L',$fill,'',1); if ($school_record['c_display_work_phone'] == 'N') $work_phone = ""; $pdf->SetXY($work_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$work_phone,'0',1,'L',$fill,'',1); if ($school_record['c_display_cell_phone'] == 'N') $cell_phone = ""; $pdf->SetXY($cell_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$cell_phone,'0',1,'L',$fill,'',1); if ($school_record['c_display_home_email'] == 'N') $home_email = ""; $pdf->SetXY($email_col,$curr_row); $pdf->Cell($email_width,$incr,$home_email,'0',1,'L',$fill,'',1); $curr_row += $incr; $name = ""; } } else { $fill = false; if ($student_count % 2) $fill = true; $student_count++; $pdf->SetXY($name_col,$curr_row); $pdf->Cell($name_width,$incr,$name,'0',1,'L',$fill,'',1); $contact = ""; $pdf->SetXY($contact_col,$curr_row); $pdf->Cell($contact_width,$incr,$contact,'0',1,'L',$fill,'',1); $home_phone = ""; $pdf->SetXY($home_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$home_phone,'0',1,'L',$fill,'',1); $work_phone = ""; $pdf->SetXY($work_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$work_phone,'0',1,'L',$fill,'',1); $cell_phone = ""; $pdf->SetXY($cell_phone_col,$curr_row); $pdf->Cell($phone_width,$incr,$cell_phone,'0',1,'L',$fill,'',1); $home_email = ""; $pdf->SetXY($email_col,$curr_row); $pdf->Cell($email_width,$incr,$home_email,'0',1,'L',$fill,'',1); $curr_row += $incr; } } } // Output the completed PDF header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private',false); header('Content-type: application/pdf'); header("Content-Disposition: attachment; filename=class_list.pdf"); header('Content-Transfer-Encoding: binary'); $pdf->Output("classlist.pdf","D"); return; ?>