Browse Source

Add pdf header when exporting - refs BT#12441

Angel Fernando Quiroz Campos 8 years ago
parent
commit
6f5f7282f8

+ 3 - 0
app/Resources/public/css/print.css

@@ -709,3 +709,6 @@ table.page-footer td{
 .border-top {
 	border-top: 1px solid #000;
 }
+.border-bottom {
+	border-bottom: 1px solid #000;
+}

+ 15 - 65
main/inc/lib/pdf.lib.php

@@ -644,80 +644,30 @@ class PDF
         $this->pdf->defaultheaderfontstyle  = 'BI'; // blank, B, I, or BI
         $this->pdf->defaultheaderline       = 1; // 1 to include line below header/above footer
 
+        $userId = api_get_user_id();
+
         if (!empty($course_data['code'])) {
             $teacher_list = CourseManager::get_teacher_list_from_course_code($course_data['code']);
 
             $teachers = '';
             if (!empty($teacher_list)) {
                 foreach ($teacher_list as $teacher) {
-                    $teachers[] = $teacher['firstname'].' '.$teacher['lastname'];
-                }
-                if (count($teachers) > 1) {
-                    $teachers = get_lang('Teachers').': '.implode(', ', $teachers);
-                } else {
-                    $teachers = get_lang('Teacher').': '.implode('', $teachers);
-                }
+                    if ($teacher['user_id'] != $userId) {
+                        continue;
+                    }
 
-                // Do not show the teacher list see BT#4080 only the current teacher name
-                $user_info = api_get_user_info();
-                $teachers = $user_info['complete_name'];
+                    // Do not show the teacher list see BT#4080 only the current teacher name
+                    $teachers = api_get_person_name($teacher['firstname'], $teacher['lastname']);
+                }
             }
 
-            $left_content    = '';
-            $center_content  = '';
-            $right_content   = $teachers;
-
-            $header = array(
-                'odd' => array(
-                    'L' => array(
-                        'content' => $left_content,
-                        'font-size' => 10,
-                        'font-style' => 'B',
-                        'font-family' => 'serif',
-                        'color'=>'#000000'
-                    ),
-                    'C' => array(
-                        'content' => $center_content,
-                        'font-size' => 10,
-                        'font-style' => 'B',
-                        'font-family' => 'serif',
-                        'color'=>'#000000'
-                    ),
-                    'R' => array(
-                        'content' => $right_content,
-                        'font-size' => 10,
-                        'font-style' => 'B',
-                        'font-family' => 'serif',
-                        'color'=>'#000000'
-                    ),
-                    'line' => 1,
-                ),
-                'even' => array(
-                    'L' => array(
-                        'content' => $left_content,
-                        'font-size' => 10,
-                        'font-style' => 'B',
-                        'font-family' => 'serif',
-                        'color'=>'#000000'
-                    ),
-                    'C' => array(
-                        'content' => $center_content,
-                        'font-size' => 10,
-                        'font-style' => 'B',
-                        'font-family' => 'serif',
-                        'color'=>'#000000'
-                    ),
-                    'R' => array(
-                        'content' => $right_content,
-                        'font-size' => 10,
-                        'font-style' => 'B',
-                        'font-family' => 'serif',
-                        'color'=>'#000000'
-                    ),
-                    'line' => 1,
-                ),
-            );
-            $this->pdf->SetHeader($header); // ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title);
+            $view = new Template('', false, false, false, true, false, false);
+            $view->assign('teacher_name', $teachers);
+            $template = $view->get_template('export/pdf_header.tpl');
+            $headerHTML = $view->fetch($template);
+
+            $this->pdf->SetHTMLHeader($headerHTML, 'E');
+            $this->pdf->SetHTMLHeader($headerHTML, 'O');
         }
     }
 

+ 7 - 0
main/template/default/export/pdf_header.tpl

@@ -0,0 +1,7 @@
+<table border="0" class="full-width border-bottom page-footer">
+    <tr>
+        <td class="text-right">
+            <strong>{{ teacher_name }}</strong>
+        </td>
+    </tr>
+</table>