function build_report($report_object) { //-- this function is called from report_object.php $page_height = $report_object->page_height; $sectionArray = $GLOBALS['nuSections']; $total_pages = $sectionArray[count($sectionArray) - 1]['the_page'] + 1; $obj = array(); $st = ''; $the_page = -1; $timestamp = date('Y-m-d H:i:s'); tofile('mid html 1: ' . date("H:i:s")); for ($G = 0; $G < count($sectionArray); $G++) { unset($section_array); unset($record); unset($controls); unset($S); $nuS = gzuncompress($sectionArray[$G]['the_section']); eval($nuS); //-- make section_array, record and controls from table record $S = new nuSection($emptySection, $new_page); //-- build a section using nothing $S->load_from_array($section_array, $record); for ($ct = 0; $ct < count($controls); $ct++) { //-- add controls to rebuilt section $S->controls[$ct] = new nuControl(null, null); $S->controls[$ct]->load_from_array($controls[$ct]); } if (!in_array($S->name, $obj)) { $style = 'position:relative;height:' . $S->height . "px"; if ($S->background_color == '#ebebeb') { $S->background_color = '#FFFFFF'; } $style .= ';background-color:' . $S->background_color . ';border-width:0px'; $st .= ' .' . $S->name . ' { ' . $style . "}\n"; $obj[] = $S->name; } for ($c = 0; $c < count($S->controls); $c++) { if (!in_array($S->controls[$c]->name, $obj)) { $name = $S->controls[$c]->name; $style = 'overflow:hidden;position:absolute;font-size:' . parseint($S->controls[$c]->font_size) . "px"; $style .= ';font-family:' . $S->controls[$c]->font_name; $style .= ';font-weight:' . $S->controls[$c]->font_weight; $style .= ';background-color:' . $S->controls[$c]->background_color; $style .= ';color:' . $S->controls[$c]->color; $style .= ';text-align:' . $S->controls[$c]->text_align; $style .= ';top:' . parseint($S->controls[$c]->top) . "px"; $style .= ';left:' . parseint($S->controls[$c]->left) . "px"; $style .= ';width:' . parseint($S->controls[$c]->width) . "px"; $style .= ';border-width:' . parseint($S->controls[$c]->border_width) . "px"; $style .= ';border-color:' . $S->controls[$c]->border_color; $style .= ';border-style:' . $S->controls[$c]->border_style; $st .= ' .' . $S->controls[$c]->name . ' { ' . $style . "}\n"; $obj[] = $S->controls[$c]->name; } } } $st1 = ""; $st1 .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"; $st1 .= "<html><!--version 3-->\n<head>\n<title></title>\n"; $st1 .= "<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n"; $st1 .= "<script type='text/javascript' src='common.js'></script>\n"; $st1 .= "<style type='text/css'>\n\n\n"; print $st1 . $st . "</style>\n\n\n\n" . $report_object->javascript . "\n\n\n\n\n</head><body onload='LoadThis()' >\n\n\n\n"; for ($G = 0; $G < count($sectionArray); $G++) { unset($section_array); unset($record); unset($controls); unset($S); $nuS = gzuncompress($sectionArray[$G]['the_section']); eval($nuS); //-- make section_array, record and controls from table record $S = new nuSection($emptySection, $new_page); //-- build a section using nothing $S->load_from_array($section_array, $record); for ($ct = 0; $ct < count($controls); $ct++) { //-- add controls to rebuilt section $S->controls[$ct] = new nuControl(null, null); $S->controls[$ct]->load_from_array($controls[$ct]); } if ($sectionArray[$G]['the_page'] != $the_page) { //--end and start new page if ($the_page != -1) { //--if not first loop print "</div>\n\n"; print "<div style='position:relative;page-break-before:always;font-size:1px'>.</div>\n\n"; //15/07/09 nick: added in px } print "<div style='height:{$page_height}" . "px;'>\n"; $the_page = $sectionArray[$G]['the_page']; } if (!($S->height == '0' || $S->height == '0px')) { //--dont build it if the height is zero print " \n\n <div class='{$S->name}' style='height:{$S->height}" . "px;'>\n\n"; for ($c = 0; $c < count($S->controls); $c++) { $lineFormat = formatForPDFandHTML($S->controls[$c]->text_string[0]); //-- get any formatting stuff from the beginning of the string eg. #BOLD# $cHeight = $S->controls[$c]->height + $S->controls[$c]->extra_growth; $cSupposedToBeLine = $S->controls[$c]->height == 0 || $S->controls[$c]->height == '0'; $cName = $S->controls[$c]->name; $cTop = $S->controls[$c]->top; $data = ''; $style = $lineFormat['html']; $tags = ''; $endtags = ''; if ($lineFormat['bold'] == '1') { $tags = $tags . '<B>'; $endtags = $endtags . '</B>'; } if ($lineFormat['italic'] == '1') { $tags = $tags . '<I>'; $endtags = $endtags . '</I>'; } if ($lineFormat['underline'] == '1') { $tags = $tags . '<U>'; $endtags = $endtags . '</U>'; } for ($ts = 0; $ts < count($S->controls[$c]->text_string); $ts++) { if ($ts == 0) { $data = $data . iif($ts == 0, '', '<br />') . $lineFormat['string']; } else { $data = $data . iif($ts == 0, '', '<br />') . $S->controls[$c]->text_string[$ts]; } } $CC = $S->controls[$c]; if (!($cHeight == '0px' || $cHeight == '0') && !$cSupposedToBeLine) { $data = str_replace('#totalNumberOfPages#', $total_pages, $data); $data = str_replace('#thePageNumber#', $sectionArray[$G]['the_page'] + 1, $data); if (strtoupper($data) == '=NOW()' or strtoupper($data) == 'NOW()') { //-- set a timestamp $data = $timestamp; } print " <div class='{$cName}' style='top:{$cTop}" . "px;height:{$cHeight}{$style}" . "px'>{$tags}{$data}{$endtags}</div>\n"; } else { //what we are drawing is supposed to be a line, so set b/l/r border widths to 0 print " <div class='{$cName}' style='top:{$cTop}" . "px;height:{$cHeight}{$style}" . "px;border-left-width:0px;border-right-width:0px;border-bottom-width:0px;'>{$tags}{$data}{$endtags}</div>\n"; } } } print "\n </div>\n"; } print "</div>\n\n</html>\n\n"; }
public function buildObject($C) { $lineFormat = formatForPDFandHTML($C->text_string[0]); //-- get any formatting stuff from the beginning of the string eg. #BOLD# $can_grow = $C->can_grow == '1'; $temp_name = $this->temp_filename . $this->imagecount; $this->imagecount = $this->imagecount + 1; $draw = 'DF'; $BC = $C->border_color; if (lresize($C->border_width) == 0 or $BC == 'transparent' or strtolower($BC) == 'white' or strtolower($BC) == '#ffffff' or strtolower($BC) == 'ffffff') { $draw = str_replace('D', '', $draw); } $BC = $C->background_color; if ($BC == 'transparent' or strtolower($BC) == 'white' or strtolower($BC) == '#ffffff' or strtolower($BC) == 'ffffff') { $draw = str_replace('F', '', $draw); } if (count($lineFormat['bgcolor']) == 0) { //-- no specific bg color for this object $color = rgbcolor($C->background_color, $this->html); } else { $color = $lineFormat['bgcolor']; if (strpos($draw, 'F') === false) { $draw = $draw . 'F'; } } $this->SetFillColor($color['r'], $color['g'], $color['b']); $color = rgbcolor($C->border_color, $this->html); $this->SetDrawColor($color['r'], $color['g'], $color['b']); if (count($lineFormat['color']) == 0) { //-- no specific color for this object $color = rgbcolor($C->color, $this->html); } else { $color = $lineFormat['color']; } $this->SetTextColor($color['r'], $color['g'], $color['b']); $field_width = hresize($C->width); $this->SetLineWidth(lresize($C->border_width)); if ($C->type != 'Graph') { if ($draw != '') { $this->Rect(hresize($C->left), vresize($C->top) + $this->section_top + 2, $field_width, hresize($C->height) + hresize($C->extra_growth), $draw); } } if (strpos($lineFormat['style'], 'B') === false) { //-- no specific boldness for this object if ($C->font_weight == 'bold') { $weight = 'B'; } else { $weight = ''; } } else { $weight = 'B'; } $this->SetFont($C->font_name, $weight, fresize($C->font_size)); $offset_top = hresize($C->original_height) * 0.2; if ($C->type == 'Graph') { if ($C->format == 'image') { $PT = nuRunQuery("SELECT zzsys_image_id FROM zzsys_image WHERE sim_code = '{$C->graph}'"); $PR = db_fetch_object($PT); $logo = fopen(getPHPurl() . "formimage.php?dir=" . $_GET['dir'] . "&iid={$PR->zzsys_image_id}", "r"); } else { $chop_at = strrpos($C->text_string[0], " width='"); //-- chops off the "width='523' height='246' />" bit of the image $url = substr($C->text_string[0], 10, $chop_at - 11); $url = str_replace(" ", "%20", $url); $logo = fopen(getPHPurl() . $url, "r"); } file_put_contents($temp_name . '.png', $logo); if (filesize($temp_name . '.png') > 0) { $im = imagecreatefrompng($temp_name . '.png'); imageinterlace($im, 0); imagepng($im, $temp_name . '.png'); $this->Image($temp_name . '.png', hresize($C->left), vresize($C->top) + $this->section_top + 2, $field_width, hresize($C->height) + hresize($C->extra_growth)); unlink($temp_name . '.png'); } } else { $string_array = array(); if ($can_grow) { //-- already an array $string_array = $C->text_string; } else { //-- create an array $swap_br = array(chr(13), '<br/>', '<Br />', '<Br/>', '<BR />', '<BR/>'); $the_string = str_replace($swap_br, '<br />', $C->text_string[0]); $string_array = explode("<br />", $the_string); } for ($ts = 0; $ts < count($string_array); $ts++) { $data = ''; if ($ts == 0) { $data = $lineFormat['string']; //-- string with formatting removed } else { $data = $string_array[$ts]; } $data = str_replace('#totalNumberOfPages#', $this->total_pages, $data); $data = str_replace('#thePageNumber#', $this->page_no, $data); $data = str_replace(' ', ' ', $data); $data = str_replace(' ', ' ', $data); if (strtoupper($data) == '=NOW()' or strtoupper($data) == 'NOW()') { $data = $this->timestamp; } $text_width = $this->GetStringWidth($data); $resized_length = fwresize($text_width); $offset_left = 0; if ($C->text_align == 'right') { $offset_left = vresize($C->width - $resized_length); } if ($C->text_align == 'center') { $offset_left = vresize(($C->width - $resized_length) / 2); } if (!$can_grow and count($string_array) > 1) { //-- dont realign top $text_top = vresize($C->top) + fresize($C->font_size) / 2 * (1 * (1 + $ts)) + $this->section_top + 2; } else { $text_top = vresize($C->top) + hresize($C->original_height) * (1 * (1 + $ts)) + $this->section_top + 2; } $left = vresize($C->left); $this->Text(hresize($C->left) + $offset_left, $text_top - $offset_top, $data); } } if ($cHeight != 0) { } }