0) { $where .= "and userid = '" . db_escape_string($selected_userid) . "' "; $report_subtitle .= " / " . getLanguageText('TEXT-USER-ID') . ": " . $selected_userid; } // View only a selected ip if (isset($selected_ip) && strlen($selected_ip) > 0) { $where .= "and user_ip = '$selected_ip' "; $report_subtitle .= " / " . getLanguageText('TEXT-IP-ADDRESS') . ": " . $selected_ip; } // View only a selected activity if (isset($selected_activity) && strlen($selected_activity) > 0) { $where .= "and activity = '$selected_activity' "; $report_subtitle .= " / " . getLanguageText('TEXT-ACTIVITY') . ": " . $selected_activity; } // Search text processing if (isset($search_text) && strlen($search_text) > 0) { $where .= "and information LIKE '%$search_text%' "; $report_subtitle .= " / " . getLanguageText('TEXT-SEARCH-TEXT') . ": " . $search_text; } if ($_SESSION['UserInfo']['type'] != 'SuperUser') { $where .= "and userid != 'superuser' "; } // // 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; // Setup parameters for this document $max_rows = 250; $title_width = 190; $left_col = 10; $start_row = 10; $incr = 4; $cols = array(); $widths = array(); $cols[0] = $left_col; $widths[] = 50; $widths[] = 50; $widths[] = 40; $widths[] = 50; // Setup columns based on width values for ($i = 0; $i < count($widths); $i++) { $cols[$i + 1] = $cols[$i] + $widths[$i]; } $headings = array(getLanguageText('TEXT-NAME'), getLanguageText('TEXT-ACTIVITY-TIME'), getLanguageText('TEXT-IP-ADDRESS'), getLanguageText('TEXT-ACTIVITY')); // // Setup PDF document // require("tcpdf/config/lang/eng.php"); require("tcpdf/tcpdf.php"); $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, $cols, $widths, $headings; $row = $start_row; // Print the header $this->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc")); $this->SetFont($document_font,"B",$document_font_size + 1); $this->SetXY($left_col,$row); $this->Cell($title_width,$incr + 1,$report_title,'0',1,'L',true,'',1); $this->SetFont($document_font,"B",$document_font_size); if (isset($report_subtitle) && strlen($report_subtitle) > 0) { $row = $row + $incr + 2; $this->SetXY($left_col,$row); $this->Cell($title_width,$incr + 1,$report_subtitle,'0',1,'L',true,'',1); } $this->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd")); if (isset($headings) && is_array($headings) && count($headings)) { $row += $incr * 2; for ($i = 0; $i < count($headings); $i++) { $col = $cols[$i]; $width = $widths[$i]; $this->SetXY($col,$row); $this->Cell($width,$incr + 1,' ' . $headings[$i],'1',1,'L',true,'',1); } } } 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','',1); $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','',1); } } // Force exact physical size for Letter: 8.5 x 11 inches => 215.9mm x 279.4mm (portrait) $pageFormat = array(215.9, 279.4); $pdf= new PDF('P', '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); $pdf->addPage(); // // Get set of records // $query = "SELECT userid,activity_datetime,user_ip,activity_time,activity " . "FROM activity_log $where order by activity_time desc,activity"; $activities = db_query($query); // // Generate the report // $curr_row = $start_row + 5 * $incr; $count = 0; while ($row = db_fetch_array($activities)) { // New page if current page is full if ($curr_row > $max_rows - $incr - 2) { $pdf->addPage(); $curr_row = $start_row + 5 * $incr; $count = 0; } extract($row); $pdf->SetFont($document_font,"",$document_font_size); $pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee")); $fill = true; if ($count % 2) $fill = false; $count++; $data = array(); $name = db_getVal("SELECT concat(first_name,' ',last_name) FROM users WHERE school_num = $base_school_num AND userid = '" . db_escape_string($userid) . "'"); if (strlen($name) == 0) $name = $userid; $data[0] = $name; $data[1] = $activity_datetime; $data[2] = $user_ip; $data[3] = $activity; for ($i = 0; $i < count($headings); $i++) { $col = $cols[$i]; $width = $widths[$i]; $pdf->SetXY($col,$curr_row); $pdf->Cell($width,$incr,$data[$i],'1',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=$file_name"); $pdf->Output($file_name,"D"); return; ?>