Gradebook export pdf results, adding logo and fixing teacher's name. Fixing wrong second page alignment

skala
Julio Montoya 14 years ago
parent 3387fff84e
commit e586b65b51
  1. 27
      main/gradebook/gradebook_flatview.php
  2. 39
      main/inc/lib/pdf.lib.php

@ -129,11 +129,17 @@ if (isset ($_GET['exportpdf'])) {
$html = '';
if (!empty($organization)) {
$html .= '<h2 align="center">'.$organization.'</h2>';
$img = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
if (file_exists($img)) {
$img = api_get_path(WEB_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
$html .= "<img src='$img'>";
} else {
if (!empty($organization)) {
$html .= '<h2 align="left">'.$organization.'</h2>';
}
}
$html .= '<h1 align="center">'.get_lang('FlatView').'</h1>';
$html .= '<p><strong>'.$report_name.'</strong></p>';
$html .= '<p><strong>'.api_convert_and_format_date(date('Y-m-d', time()), 2).'</strong></p>';
$html .= '<p><strong>'.get_lang('By').': '.$creator.'</strong></p>';
@ -177,9 +183,7 @@ if (isset ($_GET['exportpdf'])) {
}
$html .= $table->toHtml();
$html .= '<pagefooter name="myFooter1" content-left="My Book Title" content-center="myFooter1" content-right="{PAGENO}" footer-style="font-family:sans-serif; font-size:8pt; font-weight:bold; color:#008800;" footer-style-left="" line="on" />';
// Memory release
unset($printable_data);
@ -203,15 +207,8 @@ if (isset ($_GET['exportpdf'])) {
$file_name .= $course_code.'_';
}
$file_name .= get_lang('FlatView').'.pdf';
$pdf->content_to_pdf($html, $css, $file_name);
exit;
/*
$pdf->SetAuthor($creator_pdf);
$pdf->SetTitle($title_pdf);
$pdf->SetSubject($subject_pdf);
$pdf->SetKeywords($keywods_pdf);*/
$pdf->content_to_pdf($html, $css, $file_name, api_get_course_id());
exit;
} else {
Display :: display_header(get_lang('ExportPDF'));
}

@ -30,7 +30,9 @@ class PDF {
if(!in_array($orientation,array('P','L'))) {
$orientation = 'P';
}
$this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 30, 20, 27, 25, 16, 13, $orientation);
//$this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 30, 20, 27, 25, 16, 13, $orientation);
//left, right, top, bottom, margin_header, margin footer
$this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 15, 15, 20, 15, 8, 8, $orientation);
}
/**
@ -150,12 +152,12 @@ class PDF {
api_set_encoding_html($document_html, 'UTF-8'); // The library mPDF expects UTF-8 encoded input data.
$title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through
// $_GET[] too, as it is done with file name.
// At the moment the title is retrieved from the html document itself.
// At the moment the title is retrieved from the html document itself.
if (empty($title)) {
$title = $filename; // Here file name is expected to contain ASCII symbols only.
}
if (!empty($document_html)) {
if (!empty($document_html)) {
$this->pdf->WriteHTML($document_html,2);
}
} elseif (in_array($extension, array('jpg','jpeg','png','gif'))) {
@ -164,7 +166,7 @@ class PDF {
$this->pdf->WriteHTML('<html><body>'.$image.'</body></html>',2);
}
}
if (empty($pdf_name)) {
$output_file = 'pdf_'.date('Y-m-d-his').'.pdf';
} else {
@ -197,17 +199,16 @@ class PDF {
);
//Formatting the pdf
self::format_pdf($course_code);
if (!empty($course_code)) {
$course_data = api_get_course_info($course_code);
}
$course_data = api_get_course_info($course_code);
self::format_pdf($course_data);
$document_html = preg_replace($clean_search, '', $document_html);
//absolute path for frames.css //TODO: necessary?
$absolute_css_path=api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/frames.css';
$document_html=str_replace('href="./css/frames.css"',$absolute_css_path, $document_html);
$absolute_css_path = api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/frames.css';
$document_html = str_replace('href="./css/frames.css"',$absolute_css_path, $document_html);
//$document_html=str_replace('<link rel="stylesheet" http://my.chamilo.net/main/css/chamilo/frames.css type="text/css" />','', $document_html);
@ -412,7 +413,18 @@ class PDF {
}
}
$left_content = '';
/*$img = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
if (file_exists($img)) {
$img = api_get_path(WEB_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
$left_content = '<img src="'.$img.'">';
} else {
if (!empty($organization)) {
$html .= '<h2 align="left">'.$organization.'</h2>';
}
}*/
//$left_content = '';
$center_content = '';
$right_content = $teachers;
@ -464,7 +476,7 @@ class PDF {
$this->pdf->mirrorMargins = 1; // Use different Odd/Even headers and footers and mirror margins
//Adding watermark
if (api_get_setting('pdf_export_watermark_enable') == 'true') {
if (api_get_setting('pdf_export_watermark_enable') == 'true') {
$watermark_file = self::get_watermark($course_code);
if ($watermark_file) {
@ -491,6 +503,7 @@ class PDF {
$this->pdf->showWatermarkText = true;
}
}
if (empty($this->custom_header)) {
self::set_header($course_data);
} else {

Loading…
Cancel
Save