diff --git a/app/Resources/public/css/themes/chamilo/images/letterhead.png b/app/Resources/public/css/themes/chamilo/images/letterhead.png new file mode 100644 index 0000000000..0c2fd96026 Binary files /dev/null and b/app/Resources/public/css/themes/chamilo/images/letterhead.png differ diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index 3c9b95e344..4ed70f6bcd 100755 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -184,18 +184,23 @@ function getCustomTabs() * * @param string $theme The name of the theme folder from web/css/themes/ * + * @param bool $responsive add class img-responsive * @return string HTML string with logo as an HTML element */ -function return_logo($theme = '') +function return_logo($theme = '', $responsive = true) { $siteName = api_get_setting('siteName'); + $class = 'img-responsive'; + if(!$responsive){ + $class=''; + } return ChamiloApi::getPlatformLogo( $theme, [ 'title' => $siteName, - 'class' => 'img-responsive', - 'id' => 'header-logo', + 'class' => $class, + 'id' => 'header-logo' ] ); } diff --git a/main/inc/lib/pdf.lib.php b/main/inc/lib/pdf.lib.php index d2c36c2fa5..d0b4793c9e 100755 --- a/main/inc/lib/pdf.lib.php +++ b/main/inc/lib/pdf.lib.php @@ -343,17 +343,17 @@ class PDF /** * Converts an html string to PDF. * - * @param string $document_html valid html - * @param string $css CSS content of a CSS file - * @param string $pdf_name pdf name - * @param string $course_code course code + * @param string $document_html valid html + * @param string $css CSS content of a CSS file + * @param string $pdf_name pdf name + * @param string $course_code course code * (if you are using html that are located in the document tool you must provide this) - * @param string $outputMode the MPDF output mode can be: - * @param bool $saveInFile + * @param string $outputMode the MPDF output mode can be: + * @param bool $saveInFile * @param string $fileToSave - * @param bool $returnHtml - * @param bool $addDefaultCss - * @param bool $completeHeader + * @param bool $returnHtml + * @param bool $addDefaultCss + * @param bool $completeHeader * * 'I' (print on standard output), * 'D' (download file) (this is the default value), @@ -361,6 +361,7 @@ class PDF * 'S' (return as a string) * * @return string Web path + * @throws MpdfException */ public function content_to_pdf( $document_html, @@ -461,7 +462,11 @@ class PDF } if (!empty($css)) { - $this->pdf->WriteHTML($css, 1); + try { + $this->pdf->WriteHTML($css, 1); + } catch (MpdfException $e) { + error_log($e); + } } if ($addDefaultCss) { @@ -472,11 +477,19 @@ class PDF ]; foreach ($basicStyles as $style) { $cssContent = file_get_contents($style); - $this->pdf->WriteHTML($cssContent, 1); + try { + $this->pdf->WriteHTML($cssContent, 1); + } catch (MpdfException $e) { + error_log($e); + } } } - $this->pdf->WriteHTML($document_html); + try { + $this->pdf->WriteHTML($document_html); + } catch (MpdfException $e) { + error_log($e); + } if (empty($pdf_name)) { $output_file = 'pdf_'.date('Y-m-d-his').'.pdf'; diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 2511b713b3..d5142194b4 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -716,7 +716,9 @@ class Template // Logo $logo = return_logo($this->theme); + $logoPdf = return_logo($this->theme,false); $this->assign('logo', $logo); + $this->assign('logo_pdf', $logoPdf); $this->assign('show_media_element', 1); } diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index cd68101127..d7e76014cb 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -263,8 +263,10 @@ switch ($action) { $table->setCellContents(1, 2, $average); $courseTable = ''; + + if (!empty($courses)) { - $courseTable = ''; + $courseTable .= '
'; $courseTable .= ''; $courseTable .= ' @@ -359,15 +361,19 @@ switch ($action) { $studentInfo = api_get_user_info($student_id); - $content = - '

'.($sessionInfo['name']).'

'. - '
'.Display::page_subheader3($studentInfo['complete_name']).'
'. - $table->toHtml(). - sprintf( - get_lang('InSessionXYouHadTheFollowingResults'), - $sessionInfo['name'] - ). - $courseTable; + $tpl = new Template('', false, false, false, true, false, false); + $tpl->assign('title', $sessionInfo['name']); + $tpl->assign('student', $studentInfo['complete_name']); + $tpl->assign('table_progress', $table->toHtml()); + $tpl->assign('subtitle', sprintf( + get_lang('InSessionXYouHadTheFollowingResults'), + $sessionInfo['name'] + )); + $tpl->assign('table_course', $courseTable); + $template = $tpl->fetch($tpl->get_template('my_space/pdf_export_student.tpl')); + + $content = ''.$template; + $params = [ 'pdf_title' => get_lang('Resume'), @@ -383,17 +389,42 @@ switch ($action) { ]; $pdf = new PDF('A4', $params['orientation'], $params); - $pdf->content_to_pdf($content, - $css = '', - $pdf_name = '', - $course_code = null, - $outputMode = 'D', - $saveInFile = false, - $fileToSave = null, - $returnHtml = false, - $addDefaultCss = true, - $completeHeader = true - ); + try { + $theme = $tpl->theme; + $themeName = empty($theme) ? api_get_visual_theme() : $theme; + $themeDir = \Template::getThemeDir($theme); + $customLetterhead = $themeDir."images/letterhead.png"; + $urlPathLetterhead = api_get_path(SYS_CSS_PATH)."$customLetterhead"; + + $urlWebLetterhead = '#FFFFFF'; + $fullPage = false; + if (file_exists($urlPathLetterhead)) { + $fullPage = true; + $urlWebLetterhead = 'url('.api_get_path(WEB_CSS_PATH).$customLetterhead.')'; + } + + if($fullPage){ + $pdf->pdf->SetDisplayMode('fullpage'); + $pdf->pdf->SetDefaultBodyCSS('background',$urlWebLetterhead); + $pdf->pdf->SetDefaultBodyCSS('background-image-resize','6'); + } + + @$pdf->content_to_pdf($content, + $css = '', + $pdf_name = '', + $course_code = null, + $outputMode = 'D', + $saveInFile = false, + $fileToSave = null, + $returnHtml = false, + $addDefaultCss = true, + $completeHeader = false + ); + + + } catch (MpdfException $e) { + error_log($e); + } exit; break; case 'export_one_session_row': diff --git a/main/template/default/my_space/pdf_export_student.tpl b/main/template/default/my_space/pdf_export_student.tpl new file mode 100644 index 0000000000..9695f47ced --- /dev/null +++ b/main/template/default/my_space/pdf_export_student.tpl @@ -0,0 +1,18 @@ +
+ +
+

+ {{ title }} +

+
+ {{ student }} +
+
+ {{ table_progress }} +
+
+ {{ subtitle }} +
+
+ {{ table_course }} +
'.get_lang('Course').'