⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runreport.php

📁 jsp程序开发系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
								$result[$val] = $change['tech'][$result[$val]];
							} else {
								$result[$val] = "<I>None Assigned</I>";
							}
							break;
						case 'userid': 
							if (isset($result[$val])) {
								$result[$val] = $change['userid'][$result[$val]];
							} else {
								$result[$val] = "<I>None</I>";
							}
							break;
						case 'is_open': $result[$val] = $change['is_open'][$result[$val]]; break;
						case 'awaiting_tech': $result[$val] = $change['awaiting_tech'][$result[$val]]; break;
					}

					// Again, for custom fields we have to calculate the
					// display name here.

					if (stristr($val, 'custom')) {
						$items = explode('|||', $result[$val]);
						$tmptitle = array();
						foreach ($items AS $ikey => $ival) {
							if (is_array($tfields[$val])) {
								foreach ($tfields[$val] AS $tkey => $tval) {
									if ($tval[0] == $ival) {
										$tmptitle[] = $tval[2];
									}
								}
							}
						}
						$result[$val] = join(', ', $tmptitle);
					}
					$html .= "<td bgcolor=\"#FFFFFF\"><B>$result[$val]</B></TD>";
				}
				$html .= "<td align=\"center\" bgcolor=\"#FFFFFF\"><B><A HREF=\"../tech/tickets/ticketview.php?id=$result[id]\">View</A></B></td>";
				$html .= "</tr>\n";
			}
		} else {
			$html .= "<tr bgcolor=\"#FFFF99\"><td align=\"center\"><B>No Tickets Found</B></td></tr></table></td></tr></table>";
		}
		$html .= "</table></td></tr></table>";
	} else {
		$html = NULL;
	}

	return $html;
}

// ============================================
// Function make_barchart
// ============================================
// Generates a graphical bar chart showing the
// number of tickets matched per grouping
// during the reporting run.
// ============================================
// Arguments:
// 		data	First series of data
//		data2	First and second series of data
//		stat	Statistic definition from DB
//		style	Style definition from DB
//		do_pdf	If true, add the resulting
//				graph to the PDF object,
//				otherwise, generate the file
//				and output a link to it.
// ============================================
// Returns:
//		Nothing; directly outputs to browser or
//		adds data to the PDF object
// ============================================

function make_barchart($data = NULL, $data2 = NULL, $stat, $style = NULL, $do_pdf = 0) {
	global $pdf;
	$html = "<font size=\"+1\"><B>$stat[title]</B></font><br />\n<b>$stat[description]</b></font><br />\n<br />\n";
	$html .= "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td bgcolor=\"#000000\"><table cellspacing=\"1\" cellpadding=\"3\">";

	include_once("./../includes/graph/jpgraph.php");
	include_once ("./../includes/graph/jpgraph_bar.php");

	error_reporting(0);

	if (!($data) AND !($data2)) { // If no tickets, don't bother with a graphic
		if ($do_pdf) {
			return make_pdf_table($data, $data2, $stat);
		} else {
			return make_table($data, $data2, $stat);
		}
	}

	// If we're making a PDF, set up the headers for the stat in the PDF
	// object.

	if ($do_pdf) {
		$pdf->SetFont('Times', 'B', 20);
		$pdf->Write(8, trim($stat['title'])."\n");
		$pdf->SetFontSize(12);
		$pdf->Write(6, trim($stat['description'])."\n");
	}

	// Set up the graph object and set basic attributes.

	$angle = 0;
	$graph = new Graph(700,350);
	$graph->SetScale('textlin');
	$graph->img->SetMargin(45,50,40,65);
	$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);

	if ($data2) { // We're generating a group bar graph

		// Set up colors, and count rows and columns.

		$colors = array('gray', 'red', 'orange', 'yellow', 'green', 'blue', 'purple', 'white', 'black');
		foreach ($data2 AS $key1 => $var1) {
			$cols[$key1] = 1;
		}

		$rowdata = 0;
		foreach ($data2 AS $key1 => $var1) {
			if (is_array($var1)) {
				foreach ($var1 AS $key2 => $var2) {
					$rows[$key2] = 1;
					$rowdata = 1;
				}
			}
		}

		// If there isn't at least one row with valid data, don't continue with
		// the graphic.

		if (!$rowdata) {
			if ($do_pdf) {
				return make_pdf_table($data, $data2, $stat);
			} else {
				return make_table($data, $data2, $stat);
			}
		}

		// Otherwise, generate the graph, one X axis entry at a time.

		foreach ($rows AS $key1 => $var1) {
			$axis_x = array();
			$names = array();
			foreach ($cols AS $key2 => $var2) {
				$names[] = $key2;
				if (strlen($key2) > 10) { 
					$angle = 12; 
				}
				if (isset($data2[$key2][$key1])) {
					$axis_x[] = $data2[$key2][$key1];
				} else {
					$axis_x[] = 0;
				}
			}

			$bargraph = new BarPlot($axis_x);
			if (!($color = next($colors))) {
				$color = reset($colors);
			}
			$bargraph->SetFillColor($color);
			if ($key1) {
				$bargraph->SetLegend($key1);
			} else {
				$bargraph->SetLegend('None Assigned');
			}
			$bargraphs[] = $bargraph;
		}

		$group = new GroupBarPlot($bargraphs);
		$graph->Add($group);
	} elseif ($data) {

		// Generate a single-axis graph.

		foreach ($data AS $key1 => $var1) {
			$names[] = $key1;
			if (strlen($key1) > 10) { 
				$angle = 12; 
			}
			if ($data[$key1]) {
				$axis_x[] = $data[$key1];
			} else {
				$axis_x[] = 0;
			}
		}

		$bargraph = new BarPlot($axis_x);
		$graph->Add($bargraph);
	}

	// Labels tend to run together if there's more than just a few of them;
	// when there's more than five, angle the labels to 25 degrees so they
	// won't run into each other unless there's hundreds of them (that's where
	// a table is most appropriate anyway)

	if (count($names) > 5) {
		$angle = 25;
	}

	// If there are more than 10 labels, we're probably running an
	// interval-based statistic with hundreds of labels, so we don't need to
	// show them all. Only show an eighth of the labels.

	if (count($names) > 10) {
		$count = 0;
		$newnames = array();
		$factor = (int)(count($names) / 8);
		foreach ($names AS $namekey => $nameval) {
			$count++;
			if ($count == $factor) {
				$newnames[] = $nameval;
				$count = 0;
			} else {
				$newnames[] = '';
			}
		}
		$names = $newnames;
	}

	// Now set up the graph axis labels and other features.

	$graph->xaxis->SetTickLabels($names);
	$graph->xaxis->SetLabelAngle($angle);
	$graph->title->Set($stat['title']);

	$graph->SetMarginColor("silver");
	$graph->legend->Pos(0.01,0.01);

	// Set up the title for the graph
	$graph->title->SetFont(FF_VERDANA,FS_NORMAL,14);
	$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,8);
	$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,8);
	$graph->legend->SetFont(FF_VERDANA,FS_NORMAL,8);

	// Show 0 label on Y-axis (default is not to show)
	$graph->yscale->ticks->SupressZeroLabel(false);

	// Finally write the image to the browser.
	$x = rand(1, 1000000);
	$graph->Stroke("graphs/$x.png");

	// If we're generating a PDF, write the image straight to the PDF object.

	if ($do_pdf) {
		$ix = $pdf->GetX();
		$iy = $pdf->GetY();
		$pdf->Image("graphs/$x.png", $ix, $iy, 150);
		$pdf->AddPage();
		return;
	}

	if (isset($stat['title_colour'])) {
		$tc = " color=\"$stat[title_colour]\"";
	} else {
		$tc = NULL;
	}

	if (isset($stat['description_colour'])) {
		$dc = " color=\"$stat[description_colour]\"";
	} else {
		$dc = NULL;
	}

	// Write the image tag to the browser.
	echo "<img src=\"graphs/$x.png\"><br />\n";
	echo "<I><FONT SIZE=\"-1\" $dc>$stat[description]</FONT></I>\n";
}

// ============================================
// Function make_piechart
// ============================================
// Generates a graphical pie chart showing the
// number of tickets matched per grouping
// during the reporting run.
// ============================================
// Arguments:
// 		data	First series of data
//		data2	First and second series of data
//		stat	Statistic definition from DB
//		style	Style definition from DB
//		do_pdf	If true, add the resulting
//				graph to the PDF object,
//				otherwise, generate the file
//				and output a link to it.
// ============================================
// Returns:
//		Nothing; directly outputs to browser or
//		adds data to the PDF object
// ============================================
// Note:
//		For two-series graphs, we generate one
//		pie graph per first-series datum since
//		pie graphs are by nature one-axis-only.

function make_piechart($data = NULL, $data2 = NULL, $stat, $style = NULL, $do_pdf = 0) {
	global $pdf;
	$html = "<font size=\"+1\"><B>$stat[title]</B></font><br />\n<b>$stat[description]</b></font><br />\n<br />\n";

	include_once("./../includes/graph/jpgraph.php");
	include_once ("./../includes/graph/jpgraph_pie.php");
	include_once ("./../includes/graph/jpgraph_pie3d.php");

	error_reporting(0);

	if (!($data) AND !($data2)) { // If no tickets, don't bother with a graphic
		if ($do_pdf) {
			return make_pdf_table($data, $data2, $stat);
		} else {
			return make_table($data, $data2, $stat);
		}
	}

	$angle = 0;

	if (!$do_pdf) {
		echo $html;
	}

	// Use different sizes for PDF versus online viewing; PDF is higher
	// resolution (when printed, anyway).

	if ($do_pdf) {
		$width = 800;
		$height = 550;
		$minifont = 8;
	} else {
		$width = 450;
		$height = 300;
		$minifont = 6;
	}

	if ($data2) { // Processing for 2-axis graphs
		foreach ($data2 AS $key2 => $var2) {
			$names = array();
			$graph = new PieGraph($width,$height);
			$graph->legend->SetFont(FF_VERDANA,FS_NORMAL,7);
			$axis_x = array();
			foreach ($var2 AS $key1 => $var1) {
				if (!$key1) {
					if (!$data2[$key2][$key1]) {
						// Don't even bother putting this on the legend if it won't show up
						// on the pie graph.
						continue;
					}
				}
				if ($data2[$key2][$key1]) {
					$axis_x[] = $data2[$key2][$key1];
				} else {
					$axis_x[] = 0;
				}
				if (!$key1) {
					$key1 = '(none)';
				}
				$names[] = $key1;
			}

			if (!array_sum($axis_x)) {
				if ($do_pdf) {
					$pdf->Write(8, "No data to show for $key2.");
				}
				continue;
			}

			// Set up the graph's attributes and labels, then plot.
			$piegraph = new PiePlot3D($axis_x);
			$piegraph->title->SetFont(FF_VERDANA,FS_NORMAL,14);
			$piegraph->value->SetFont(FF_VERDANA,FS_NORMAL,$minifont);
			$piegraph->title->Set($key2);
			$piegraph->SetLegends($names);
			$piegraph->SetCenter(0.5,0.5);
			$piegraph->SetSize(0.5);
			$graph->Add($piegraph);

			$graph->legend->Pos(0.01,0.01);
			$graph->SetMarginColor("silver");

			// Finally write the graph to disk.
			$x = rand(1, 1000000);
			$graph->Stroke("graphs/$x.png");

			if ($do_pdf) { // Add to the PDF object.
				$pdf->SetFont('Times', 'B', 20);
				$pdf->Write(8, trim($stat['title'])."\n");
				$pdf->SetFontSize(12);
				$pdf->Write(6, trim($stat['description'])."\n");
				$ix = $pdf->GetX();
				$iy = $pdf->GetY();
				$pdf->Image("graphs/$x.png", $ix, $iy, 150);
				$pdf->AddPage();
				continue;
			}

			if ($stat['title_colour']) {
				$tc = " color=\"$stat[title_colour]\"";
			}

			if ($stat['description_colour']) {
				$dc = " color=\"$stat[description_colour]\"";
			}

			// Emit an image tag to the browser.
			echo "<img src=\"graphs/$x.png\"><br /><br />\n";
		}
	} elseif ($data) { // 1-axis data processing
		if ($do_pdf) {
			$pdf->SetFont('Times', 'B', 20);
			$pdf->Write(8, trim($stat['title'])."\n");
			$pdf->SetFontSize(12);
			$pdf->Write(6, trim($stat['description'])."\n");
		}
		$graph = new PieGraph($width,$height);
		foreach ($data AS $key1 => $var1) {
			$names[] = $key1;
			if ($data[$key1]) {
				$axis_x[] = $data[$key1];
			} else {
				$axis_x[] = 0;
			}
		}

		// Set up the graph's attributes and labels, then plot.
		$piegraph = new PiePlot3D($axis_x);
		$piegraph->title->SetFont(FF_VERDANA,FS_NORMAL,14);
		$piegraph->value->SetFont(FF_VERDANA,FS_NORMAL,$minifont);
		$piegraph->title->Set($stat['title']);
		$graph->legend->SetFont(FF_VERDANA,FS_NORMAL,8);
		$piegraph->SetLegends($names);
		$piegraph->SetCenter(0.5,0.41);
		$piegraph->SetSize(0.45);
		$graph->Add($piegraph);
	
		$graph->legend->Pos(0.01,0.01);
		$graph->SetMarginColor("silver");

		// Finally write the graph to disk.
		$x = rand(1, 1000000);
		$graph->Stroke("graphs/$x.png");

		if ($do_pdf) { // Add to the PDF object.
			$ix = $pdf->GetX();
			$iy = $pdf->GetY();
			$pdf->Image("graphs/$x.png", $ix, $iy, 150);
			$pdf->AddPage();
			return;
		}

		if (isset($stat['title_colour'])) {
			$tc = " color=\"$stat[title_colour]\"";
		} else {
			$tc = NULL;
		}

		if (isset($stat['description_colour'])) {
			$dc = " color=\"$stat[description_colour]\"";
		} else {
			$dc = NULL;
		}
		
		// Emit image tag to the browser.
		echo "<img src=\"graphs/$x.png\"><br />\n";
		echo "<I><FONT SIZE=\"-1\" $dc>$stat[description]</FONT></I>\n";
	}
}

// ============================================
// Function make_table
// ============================================
// Generates an HTML table showing the
// number of tickets matched per grouping
// during the reporting run.
// ============================================
// Arguments:
// 		data	First series of data
//		data2	First and second series of data
//		stat	Statistic definition from DB
// ============================================
// Returns:
//		The HTML to display.
// ============================================

function make_table($data = NULL, $data2 = NULL, $stat) {
	// Set up styles, if any.

	if (isset($stat['title_colour'])) {
		$tc = " color=\"$stat[title_colour]\"";
	} else {
		$tc = NULL;
	}

	if (isset($stat['description_colour'])) {
		$dc = " color=\"$stat[description_colour]\"";
	} else {
		$dc = NULL;
	}

	// Generate the table headings.

	$html = "<font size=\"+1\" $tc><B>$stat[title]</B></font><br />\n<font $dc><b>$stat[description]</b></font><br />\n<br />\n";
	$html .= "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td bgcolor=\"#000000\"><table cellspacing=\"1\" cellpadding=\"3\">";

	if ((!$data) AND (!$data2)) { // If it's an empty data set, return an empty table
		$html .= "<td bgcolor=\"#FFFF99\">No tickets found</td></tr></table></td></tr></table>";
		return $html;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -