'; $printdata .= '

'.$view.' : '.$coursename.'

'; //@todo not necessary here //$printdata .= '

'.get_lang('Date').' : '.api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT).'

'; $printdata .= ''; foreach ($header_names as $header) { $printdata .= ''; } foreach ($data_array as $data) { $printdata .= ''; foreach ($data as $rowdata) { $printdata .= ''; } $printdata .= ''; } $printdata .= '
'.$header.'
'.$rowdata.'
'; return $printdata; } /** * This function get a content html for export inside a pdf file * @param array table headers * @param array table body * @param array pdf headers * @param array pdf footers * @return void */ function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footers_pdf, $title_pdf) { require_once api_get_path(LIBRARY_PATH).'pdf.lib.php'; $headers_in_pdf = ''; if (is_array($headers_pdf)) { // preparing headers pdf $header = '

'.$title_pdf.'

'.$headers_pdf[0][0].' '.$headers_pdf[0][1].' '.$headers_pdf[1][0].' '.$headers_pdf[1][1].'
'.$headers_pdf[2][0].' '.$headers_pdf[2][1].' '.$headers_pdf[3][0].' '.$headers_pdf[3][1].'
'.$headers_pdf[4][0].' '.$headers_pdf[4][1].' '.$headers_pdf[5][0].' '.$headers_pdf[5][1].'
'; } // preparing footer pdf $footer = ''; if (is_array($footers_pdf)) { $footer .= ''; foreach ($footers_pdf as $foot_pdf) { $footer .= ''; } $footer .= ''; } $footer .= '
'.$foot_pdf.'
'; $footer .= '
{PAGENO}/{nb}
'; // preparing content pdf $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).api_get_setting('stylesheets').'/print.css'; if (file_exists($css_file)) { $css = @file_get_contents($css_file); } else { $css = ''; } $items_per_page = 30; $count_pages = ceil(count($data_table) / $items_per_page); for ($x = 0; $x<$count_pages; $x++) { $content_table .= ''; // header table $content_table .= ''; $i = 0; if (is_array($headers_table)) { foreach ($headers_table as $head_table) { if (!empty($head_table[0])) { $width = (!empty($head_table[1])?$head_table[1].'%':''); $content_table .= ''; $i++; } } } $content_table .= ''; // body table if (is_array($data_table) && count($data_table) > 0) { $offset = $x*$items_per_page; $data_table = array_slice ($data_table, $offset, count($data_table)); $i = 1; $item = $offset+1; foreach ($data_table as $data) { $content_table .= ''; $content_table .= ''; foreach ($data as $key => $content) { if (isset($content)) { $key == 1 ? $align='align="left"':$align='align="center"'; $content_table .= ''; } } $content_table .= ''; $i++; $item++; if ($i > $items_per_page) { break; } } } else { $content_table .= ''; } $content_table .= '
'.$head_table[0].'
'.($item<10?'0'.$item:$item).''.$content.'
'.get_lang('Empty').'
'; if ($x < ($count_pages - 1)) { $content_table .= ''; } } $pdf = new PDF(); $pdf->set_custom_footer($footer); $pdf->set_custom_header($headers_in_pdf); $pdf->content_to_pdf($header.$content_table, $css, $title_pdf ); exit; } /** * Exports the data as a table on a PDF page * @param resource The PDF object (ezpdf class) used to generate the file * @param array The data array * @param array Table headers * @param string Format (portrait or landscape) */ function export_pdf($pdf,$newarray,$header_names,$format) { $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->ezSetCmMargins(0,0,0,0); $pdf->ezSetY(($format=='portrait')?'820':'570'); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); //$pdf->ezText(get_lang('FlatView').' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')',12,array('justification'=>'center')); if ($format=='portrait') { $pdf->line(40,790,540,790); $pdf->line(40,40,540,40); } else { $pdf->line(40,540,790,540); $pdf->line(40,40,790,40); } $pdf->ezSetY(($format=='portrait')?'750':'520'); $pdf->ezTable($newarray,$header_names,'',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,'rowGap'=>3,'width'=>(($format=='portrait')?'500':'750'))); $pdf->ezStream(); }