Beispiel #1
0
	// CUSTOM REPORTS
	$reports = array_var($customReports, $type_id, array());
	
?>
<div class="report_header"><?php echo lang('custom reports') ?></div>
<?php 
	if(count($reports) > 0){
		$alt = true;
?>
	<ul>
	<?php foreach($reports as $report){
			$alt = !$alt; 
	?>
		<li style="padding-top:4px">
		<div style="max-width:700px;<?php echo $alt ? 'background-color:#ECEFF7;' : '';?>">
			<a style="font-weight:bold;margin-right:15px" class="internalLink" href="<?php echo get_url('reporting','view_custom_report', array('id' => $report->getId()))?>"><?php echo $report->getObjectName() ?></a>
			<div style="float:right;padding-left:15px;">
			<?php if ($report->canEdit(logged_user())) { ?>
				<a style="margin-right:5px" class="internalLink coViewAction ico-edit" href="<?php echo get_url('reporting','edit_custom_report', array('id' => $report->getId()))?>"><?php echo lang('edit') ?></a>
			<?php } ?>
			<?php if ($report->canDelete(logged_user())) { ?>
				<a style="margin-right:5px" class="internalLink coViewAction ico-delete" href="javascript:og.deleteReport(<?php echo $report->getId() ?>)"><?php echo lang('delete') ?></a>
			<?php } ?>
			</div>
			<div style="float:right;max-width:700px;" id="report-<?php echo $report->getId();?>">
				<span class="breadcrumb"></span>
				<script>
					<?php $crumbOptions = json_encode($report->getMembersToDisplayPath());
					$crumbJs = " og.getCrumbHtml($crumbOptions) ";?>
					var crumbHtml = <?php echo $crumbJs;?>;
					$("#report-<?php echo $report->getId()?> .breadcrumb").html(crumbHtml);
Beispiel #2
0
<div class="report_header"><?php 
    echo lang('custom reports');
    ?>
</div>
<?php 
    if (count($reports) > 0) {
        ?>
	<ul>
	<?php 
        foreach ($reports as $report) {
            ?>
		<li style="padding-top:4px"><div><a style="font-weight:bold;margin-right:15px" class="internalLink" href="<?php 
            echo get_url('reporting', 'view_custom_report', array('id' => $report->getId()));
            ?>
"><?php 
            echo $report->getObjectName();
            ?>
</a>
			<?php 
            if ($report->canEdit(logged_user())) {
                ?>
				<a style="margin-right:5px" class="internalLink coViewAction ico-edit" href="<?php 
                echo get_url('reporting', 'edit_custom_report', array('id' => $report->getId()));
                ?>
"><?php 
                echo lang('edit');
                ?>
</a>
			<?php 
            }
            ?>
 function generatePDFReport(Report $report, $results)
 {
     $results['columns'][] = lang("status");
     $types = self::get_report_column_types($report->getId());
     $ot = ObjectTypes::findById($report->getReportObjectTypeId());
     eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
     $externalCols = $managerInstance->getExternalColumns();
     $filename = str_replace(' ', '_', $report->getObjectName()) . date('_YmdHis');
     $pageLayout = $_POST['pdfPageLayout'];
     $fontSize = $_POST['pdfFontSize'];
     include_once LIBRARY_PATH . '/pdf/fpdf.php';
     $pdf = new FPDF($pageLayout);
     $pdf->setTitle($report->getObjectName());
     $pdf->AddPage();
     $pdf->SetFont('Arial', '', $fontSize);
     $pdf->Cell(80);
     $report_title = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($report->getObjectName(), ENT_COMPAT));
     $pdf->Cell(30, 10, $report_title);
     $pdf->Ln(20);
     $colSizes = array();
     $maxValue = array();
     $fixed_col_sizes = array();
     foreach ($results['rows'] as $row) {
         $i = 0;
         array_shift($row);
         foreach ($row as $k => $value) {
             if (!isset($maxValue[$i])) {
                 $maxValue[$i] = '';
             }
             if (strlen(strip_tags($value)) > strlen($maxValue[$i])) {
                 $maxValue[$i] = strip_tags($value);
             }
             $i++;
         }
     }
     $k = 0;
     foreach ($maxValue as $str) {
         $col_title_len = $pdf->GetStringWidth($results['columns'][$k]);
         $colMaxTextSize = max($pdf->GetStringWidth($str), $col_title_len);
         $db_col = $results['columns'][$k];
         $colType = array_var($types, array_var($results['db_columns'], $db_col, ''), '');
         if ($colType == DATA_TYPE_DATETIME && !($report->getObjectTypeName() == 'event' && $results['db_columns'][$db_col] == 'start')) {
             $colMaxTextSize = $colMaxTextSize / 2;
             if ($colMaxTextSize < $col_title_len) {
                 $colMaxTextSize = $col_title_len;
             }
         }
         $fixed_col_sizes[$k] = $colMaxTextSize;
         $k++;
     }
     $fixed_col_sizes = self::fix_column_widths($pageLayout == 'P' ? 172 : 260, $fixed_col_sizes);
     $max_char_len = array();
     $i = 0;
     foreach ($results['columns'] as $col) {
         $colMaxTextSize = $fixed_col_sizes[$i];
         $colFontSize = $colMaxTextSize + 5;
         $colSizes[$i] = $colFontSize;
         $col_name = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($col, ENT_COMPAT));
         $pdf->Cell($colFontSize, 7, $col_name);
         $max_char_len[$i] = self::get_max_length_from_pdfsize($pdf, $colFontSize);
         $i++;
     }
     $lastColX = $pdf->GetX();
     $pdf->Ln();
     $pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
     foreach ($results['rows'] as $row) {
         $i = 0;
         $more_lines = array();
         $col_offsets = array();
         foreach ($row as $k => $value) {
             if ($k == 'object_type_id') {
                 continue;
             }
             $db_col = isset($results['db_columns'][$results['columns'][$i]]) ? $results['db_columns'][$results['columns'][$i]] : '';
             $cell = format_value_to_print($db_col, html_to_text($value), $k == 'link' ? '' : array_var($types, $k), array_var($row, 'object_type_id'), '', is_numeric(array_var($results['db_columns'], $k)) ? "Y-m-d" : user_config_option('date_format'));
             $cell = iconv(mb_internal_encoding(), "ISO-8859-1", html_entity_decode($cell, ENT_COMPAT));
             $splitted = self::split_column_value($cell, $max_char_len[$i]);
             $cell = $splitted[0];
             if (count($splitted) > 1) {
                 array_shift($splitted);
                 $ml = 0;
                 foreach ($splitted as $sp_val) {
                     if (!isset($more_lines[$ml]) || !is_array($more_lines[$ml])) {
                         $more_lines[$ml] = array();
                     }
                     $more_lines[$ml][$i] = $sp_val;
                     $ml++;
                 }
                 $col_offsets[$i] = $pdf->x;
             }
             $pdf->Cell($colSizes[$i], 7, $cell);
             $i++;
         }
         foreach ($more_lines as $ml_values) {
             $pdf->Ln();
             foreach ($ml_values as $col_idx => $col_val) {
                 $pdf->SetX($col_offsets[$col_idx]);
                 $pdf->Cell($colSizes[$col_idx], 7, $col_val);
             }
         }
         $pdf->Ln();
         $pdf->SetDrawColor(220, 220, 220);
         $pdf->Line($pdf->GetX(), $pdf->GetY(), $lastColX, $pdf->GetY());
         $pdf->SetDrawColor(0, 0, 0);
     }
     $filename = ROOT . "/tmp/" . gen_id() . ".pdf";
     $pdf->Output($filename, "F");
     download_file($filename, "application/pdf", $report->getObjectName(), true);
     unlink($filename);
     die;
 }