reports.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:31k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: reports.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.61 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Report and statistic maintenance and launcher (administration
- // | interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- feature_check('reports');
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "listreports";
- }
- // globalise variables
- $global = array (
- array('id', 'number')
- );
- rg($global);
- ############################### LIST REPORTS ###############################
- if ($_REQUEST['do'] == "viewreports") {
- admin_header('Reports', 'View Reports');
- $db->query("SELECT id, title FROM report_stat");
- while ($result = $db->row_array()) {
- $stat[$result[id]] = $result[title];
- }
- $db->query("SELECT * FROM report_relations");
- while ($result = $db->row_array()) {
- $relations[$result[reportid]][] = $stat[$result[statid]];
- }
- $db->query("SELECT * FROM report");
- while ($result = $db->row_array()) {
- $table[] = array(
- "<form method="post" action="runreport.php"><b>$result[name]</b>",
- 'Start on ' . form_date('date', '', '', '', '', date('Y-m-d', strtotime(date('Y-m-01') . '-1 month'))).
- ' and report for ' .
- form_input('number',
- 1,
- 4)
- . form_select('type',
- array('days' => 'day(s)',
- 'months' => 'month(s)',
- 'years' => 'year(s)'),
- '',
- 'months')
- . form_hidden('id', $result[id])
- . "<input type="submit" name="Run" value="Run"></form>",
- "<a href="reports.php?do=editreport&id=$result[id]">View / Edit Report",
- jprompt('Are you sure you want to delete this report?',
- "reports.php?do=deletereport&id=$result[id]", 'Delete')
- );
- }
- $cols = array('Report Title', 'Specify Date Range', 'View/Edit Report', 'Delete');
- table_header('Reports', 'runreport.php');
- table_content($cols, $table);
- table_footer();
- }
- ############################### DELETE REPORT ###############################
- if ($_REQUEST['do'] == "deletereport") {
- $db->query("DELETE FROM report WHERE id = '$id'");
- $db->query("DELETE FROM report_relations WHERE reportid = '$id'");
- jump('reports.php?do=viewreports', 'Report Deleted');
- }
- ############################### DELETE STAT ###############################
- if ($_REQUEST['do'] == "deletestat") {
- $db->query("DELETE FROM report_stat WHERE id = '$id'");
- jump('reports.php?do=viewstats', 'Statistic Deleted');
- }
- ############################### LIST STATS ###############################
- if ($_REQUEST['do'] == "viewstats") {
- admin_header('Reports', 'View Stats');
- $db->query("SELECT id, title, description FROM report_stat");
- while ($result = $db->row_array()) {
- $table[] = array(
- $result[title],
- $result[description],
- "<a href="reports.php?do=editstat&id=$result[id]">View / Edit Statistic</A>",
- "<a href="runreport.php?do=previewstat&id=$result[id]">Preview</A>",
- jprompt('Are you sure you want to delete this statistic?', "reports.php?do=deletestat&id=$result[id]", 'Delete')
- );
- }
- $cols = array('Statistic Title', 'Statistic Description', 'View/Edit Statistic', 'Preview', 'Delete');
- table_header('Reports');
- table_content($cols, $table);
- table_footer();
- }
- ############################### EDIT / NEW REPORT ###############################
- if ($_REQUEST['do'] == "editreport" OR $_REQUEST['do'] == "newreport") {
- if ($_REQUEST['do'] == 'newreport') {
- admin_header('Reports', 'New Report');
- } else {
- admin_header('Reports', 'Edit Report');
- }
- $report = $db->query_return("SELECT * FROM report WHERE id = '$id'");
- echo get_javascript('selectBox.js');
- $table[] = array('<b>Report Name</b><BR>
- This report's short (display) name.',
- form_input('name', $report[name])
- );
- $table[] = array('<b>Report Title</b><br />
- This report's printed name (shown on the generated report)',
- form_input('title', $report[title])
- );
- $table[] = array('<b>Report Description</b><br />
- This report's detailed description (shown on the generated report)',
- form_textarea('description', 60, 5, $report[description])
- );
- $db->query("SELECT name, id FROM report_style");
- while ($result = $db->row_array()) {
- $styles[$result[id]] = $result[name];
- }
- $table[] = array('<b>Report Style</b><BR>
- Select the desired style to apply to this report.',
- form_select('style', $styles, '', $report[style])
- );
- $table[] = array('<b>E-mail Report</b><br />
- [Optional] Comma-separated list of addresses to e-mail a copy of the
- generated report to.',
- form_textarea('email', 60, 6, $report[email])
- );
- give_default($report[path], '');
- $table[] = array('<b>Save Report</b><br />
- [Optional] Save a copy of the generated report as ...
- <I>(this requires write access to the given directory)</I>',
- form_input('path', $report[path])
- );
- $table[] = array('<b>Report Format</b><BR>
- Select the desired reporting format.',
- form_select('format', array('HTML' => 'HTML', 'PDF' => 'PDF'),
- '',
- $report[format])
- );
- $month = array('1' => 'Jan',
- '2' => 'Feb',
- '3' => 'Mar',
- '4' => 'Apr',
- '5' => 'May',
- '6' => 'Jun',
- '7' => 'Jul',
- '8' => 'Aug',
- '9' => 'Sep',
- '10' => 'Oct',
- '11' => 'Nov',
- '12' => 'Dec'
- );
- $table[] = table_midheader('Statistics to Use');
- $reportarray = array();
- if ($_REQUEST['do'] == "editreport") {
- $db->query("SELECT report_stat.id, report_stat.title
- FROM report_relations
- LEFT JOIN report_stat ON (report_stat.id = report_relations.statid)
- WHERE reportid = '$id'
- ");
-
- while ($result = $db->row_array()) {
- $reportarray[] = $result[id];
- $html2 .= "<option value="$result[id]">$result[title]</option>";
- }
- }
- $db->query("SELECT id, title FROM report_stat");
- while ($result = $db->row_array()) {
- if (!in_array($result[id], $reportarray)) {
- $html .= "<option value="$result[id]">$result[title]</option>";
- }
- }
- $table[] = array("<b>Select Statistics</b><BR>
- Select which statistics should be included in this report. Note that
- each statistic will generate its own data table or graph <I>(Note:
- CSV-format statistics cannot be mixed with other formats. Only one
- CSV-format statistic can be specified a single report (and it must be
- the only statistic in the report.).</I>", "
- <TABLE BORDER=0>
- <TR>
- <TD VALIGN=MIDDLE ALIGN=CENTER>
- <b>Available Statistics</b><br />
- <SELECT style="width:200px" NAME="list11" MULTIPLE SIZE=10 onDblClick="moveSelectedOptions(this.form.list11,this.form.list21,false)">
- $html
- </SELECT>
- </TD>
- <td> </td>
- <TD VALIGN=MIDDLE ALIGN=CENTER>
- <INPUT TYPE="button" NAME="right" VALUE="Add >>" onClick="moveSelectedOptions(document.forms[0].list11,document.forms[0].list21,false);return false;"><BR><BR>
- <INPUT TYPE="button" NAME="right" VALUE="Add All >>" onClick="moveAllOptions(document.forms[0].list11,document.forms[0].list21,false); return false;"><BR><BR>
- <INPUT TYPE="button" NAME="left" VALUE="<< Delete" onClick="moveSelectedOptions(document.forms[0].list21,document.forms[0].list11,false); return false;"><BR><BR>
- <INPUT TYPE="button" NAME="left" VALUE="<< Delete All" onClick="moveAllOptions(document.forms[0].list21,document.forms[0].list11,false); return false;">
- </TD>
- <td> </td>
- <TD VALIGN=MIDDLE ALIGN=CENTER>
- <b>Selected Statistics</b><br />
- <SELECT style="width:200px" NAME="list21" MULTIPLE SIZE=10 onDblClick="moveSelectedOptions(this.form.list21,this.form.list11,false)">
- $html2
- </SELECT>
- </TD>
- <td> </td>
- <TD ALIGN="CENTER" VALIGN="MIDDLE">
- <b>Move Selected Statistic</b><br />
- <input type="hidden" name="stats">
- <INPUT TYPE="button" VALUE=" Up " onClick="moveOptionUp(this.form.list21)">
- <INPUT TYPE="button" VALUE="Down" onClick="moveOptionDown(this.form.list21)">
- </TD>
- </TR>
- </TABLE>");
- $table[] = table_midheader('Repetition Options');
- if (!$report[repeattype]) {
- $table[] = array('<b>No Repeat</b>',
- "<input type="radio" name="type" value="0" checked=checked> Don't run this report automatically "
- );
- } else {
- $table[] = array('<b>Daily Repeat</b>',
- "<input type="radio" name="type" value="0"> Don't run this report automatically "
- );
- }
-
- if ($report[repeattype] == 1) {
- $table[] = array('<b>Daily Repeat</b>',
- "<input type="radio" name="type" value="1" checked=checked> Run this report every "
- . form_input('type1_day', $report[value1], 1) . " day(s)<br />"
- );
- } else {
- $table[] = array('<b>Daily Repeat</b>',
- "<input type="radio" name="type" value="1"> Run this report every "
- . form_input('type1_day', '', 1) . " day(s)<br />"
- );
- }
-
- if ($report[repeattype] == 2) {
- $days = unserialize($report[value2]);
- $table[] = array('<b>Weekly Repeat</b>',
- "<input type="radio" name="type" value="2" checked=checked>
- Run this report every "
- . form_input('type2_week', $report[value1], 1)
- . " week(s) on <br /> "
- . form_checkbox_single('1', 1, @in_array(1, $days), 'type2_day') . " Mon "
- . form_checkbox_single('2', 1, @in_array(2, $days), 'type2_day') . " Tue "
- . form_checkbox_single('3', 1, @in_array(3, $days), 'type2_day') . " Wed "
- . form_checkbox_single('4', 1, @in_array(4, $days), 'type2_day') . " Thu "
- . form_checkbox_single('5', 1, @in_array(5, $days), 'type2_day') . " Fri "
- . form_checkbox_single('6', 1, @in_array(6, $days), 'type2_day') . " Sat "
- . form_checkbox_single('7', 1, @in_array(7, $days), 'type2_day') . " Sun "
- );
- } else {
- $table[] = array('<b>Weekly Repeat</b>',
- "<input type="radio" name="type" value="2">
- Run this report every "
- . form_input('type2_week', '', 1) . " week(s) on <br /> "
- . form_checkbox_single('1', 1, '', 'type2_day') . " Mon "
- . form_checkbox_single('2', 1, '', 'type2_day') . " Tue "
- . form_checkbox_single('3', 1, '', 'type2_day') . " Wed "
- . form_checkbox_single('4', 1, '', 'type2_day') . " Thu "
- . form_checkbox_single('5', 1, '', 'type2_day') . " Fri "
- . form_checkbox_single('6', 1, '', 'type2_day') . " Sat "
- . form_checkbox_single('7', 1, '', 'type2_day') . " Sun "
- );
- }
-
- if ($report[repeattype] == 3) {
- $table[] = array('<b>Monthly Repeat</b>',
- "<input type="radio" name="type" value="3" checked=checked>
- Run this report on the "
- . form_select('type3_day', make_numberarray(1, 31), '', $report[value1])
- . " day of every "
- . form_input('type3_month', $report[value2], 3)
- . " month(s)"
- );
- } else {
- $table[] = array('<b>Monthly Repeat</b>',
- "<input type="radio" name="type" value="3">
- Run this report on the "
- . form_select('type3_day', make_numberarray(1, 31), '', $report[value1])
- . " day of every "
- . form_input('type3_month', '', 3)
- . " month(s)"
- );
- }
- if ($report[repeattype] == 4) {
- $table[] = array('<b>Yearly Repeat</b>',
- "<input type="radio" name="type" value="4" checked=checked>
- Run this report every year on "
- . form_select('type4_day', make_numberarray(1, 31), '', $report[value1])
- . " "
- . form_select('type4_month', $month, '', $report[value2])
- );
- } else {
- $table[] = array('<b>Yearly Repeat</b>',
- "<input type="radio" name="type" value="4">
- Run this report every year on "
- . form_select('type4_day', make_numberarray(1, 31))
- . " "
- . form_select('type4_month', $month)
- );
- }
- if ($_REQUEST['do'] == 'editreport') {
- $hidden = array('do' => 'editreport2', 'id' => $report[id]);
- $end = 'Edit Report';
- } else {
- $hidden = array('do' => 'newreport2');
- $end = 'Create Report';
- }
- $width = array('40%', '60%');
- table_header('Field Display Properties', 'reports.php', $hidden, '', 'dpform');
- table_content('', $table, '', '', '', '', $width);
- table_footer($end, 'center', '', '', "onclick="submitAllOptions(this.form.list21, this.form.stats)"");
- }
- ############################### EDIT / NEW REPORT ###############################
- if ($_REQUEST['do'] == "newreport2" OR $_REQUEST['do'] == "editreport2") {
- if ($_REQUEST[type] == '1') {
- $repeattype = 'daily';
- $val1 = $_REQUEST[type1_day];
- } elseif ($_REQUEST[type] == '2') {
- $repeattype = 'weekly';
- $val1 = $_REQUEST[type2_week];
- if (is_array($_REQUEST[type2_day])) {
- foreach ($_REQUEST[type2_day] AS $key => $var) {
- if ($var > 0) {
- $tmp_array[] = $key;
- }
- }
- }
- $val2 = serialize($tmp_array);
- unset($tmp_array);
- } elseif ($_REQUEST[type] == '3') {
- $repeattype = 'monthly';
- $val1 = $_REQUEST[type3_day];
- $val2 = $_REQUEST[type3_month];
- } elseif ($_REQUEST[type] == '4') {
- $repeattype = 'yearly';
- $val1 = $_REQUEST[type4_day];
- $val2 = $_REQUEST[type4_month];
- }
- if ($_REQUEST['do'] == 'newreport2') {
- $db->query("INSERT INTO report SET
- name = '" . mysql_escape_string($_REQUEST[name]) . "',
- title = '" . mysql_escape_string($_REQUEST[title]) . "',
- description = '" . mysql_escape_string($_REQUEST[description]) . "',
- style = '" . mysql_escape_string($_REQUEST[style]) . "',
- format = '" . mysql_escape_string($_REQUEST[format]) . "',
- path = '" . mysql_escape_string($_REQUEST[path]) . "',
- value1 = '" . mysql_escape_string($val1) . "',
- value2 = '" . mysql_escape_string($val2) . "',
- repeattype = '$repeattype',
- email = '" . mysql_escape_string($_REQUEST[email]) . "'
- ");
- $id = $db->last_id();
- } else {
- $db->query("UPDATE report SET
- name = '" . mysql_escape_string($_REQUEST[name]) . "',
- title = '" . mysql_escape_string($_REQUEST[title]) . "',
- description = '" . mysql_escape_string($_REQUEST[description]) . "',
- style = '" . mysql_escape_string($_REQUEST[style]) . "',
- format = '" . mysql_escape_string($_REQUEST[format]) . "',
- path = '" . mysql_escape_string($_REQUEST[path]) . "',
- value1 = '" . mysql_escape_string($val1) . "',
- value2 = '" . mysql_escape_string($val2) . "',
- repeattype = '$repeattype',
- email = '" . mysql_escape_string($_REQUEST[email]) . "'
- WHERE id = '$id'
- ");
- $db->query("DELETE FROM report_relations WHERE reportid = '$id'");
- }
- $relations = split(',', $_REQUEST[stats]);
- foreach ($relations AS $key => $var) {
- if ($var) {
- $array[] = array($id, $var);
- }
- }
- if (is_array($array)) {
- $db->query("INSERT INTO report_relations (reportid, statid) VALUES " . insertsql($array));
- }
- if ($_REQUEST['do'] == 'newreport2') {
- jump("reports.php?do=editreport&id=$id", 'New Report Created');
- } else {
- jump("reports.php?do=editreport&id=$id", 'Report Updated');
- }
- }
- ############################### EDIT / NEW STAT ###############################
- if ($_REQUEST['do'] == "newstat2" OR $_REQUEST['do'] == "editstat2") {
-
- // sort out ticket fields
- if ($_REQUEST[awaiting_status]) {
- $fixed_general[awaiting_status] = $_REQUEST[awaiting_status];
- }
- if ($_REQUEST[open_status]) {
- $fixed_general[open_status] = $_REQUEST[open_status];
- }
- if ($_REQUEST[category]) {
- $fixed_general[category] = $_REQUEST[category];
- }
- if ($_REQUEST[priority]) {
- $fixed_general[priority] = $_REQUEST[priority];
- }
- // sort out ticket fields
- $db->query("SELECT * from ticket_def");
- while ($result = $db->row_array()) {
- $data = field_def_val($result, $_REQUEST[ticketfields][$result[name]], $_REQUEST[ticketfields]["extra" . $result[name]], 1);
- $fixed_ticket[$result[name]] = $data;
- $fixed_ticket["$result[name]_not"] = $_REQUEST['ticketfields'][$result[name].'_not'];
- $fixed_ticket["$result[name]_match"] = $_REQUEST['ticketfields'][$result[name].'_match'];
- }
- // sort out user fields
- $db->query("SELECT * from user_def");
- while ($result = $db->row_array()) {
- $data = field_def_val($result, $_REQUEST[userfields][$result[name]], $_REQUEST[userfields]["extra" . $result[name]], 1);
- $fixed_user[$result[name]] = $data;
- $fixed_user["$result[name]_not"] = $_REQUEST['userfields'][$result[name].'_not'];
- $fixed_user["$result[name]_match"] = $_REQUEST['userfields'][$result[name].'_match'];
- }
- $fixed_user = serialize($fixed_user);
- $fixed_ticket = serialize($fixed_ticket);
- $fixed_general = serialize($fixed_general);
- $interval = intval($_REQUEST[txtYears]).','.
- intval($_REQUEST[txtDays]).','.
- intval($_REQUEST[txtHours]).','.
- intval($_REQUEST[txtMinutes]);
-
- if ($_REQUEST['do'] == 'newstat2') {
- $db->query("INSERT INTO report_stat SET
- title = '" . mysql_escape_string($_REQUEST[title]) . "',
- description = '" . mysql_escape_string($_REQUEST[description]) . "',
- variable1 = '" . mysql_escape_string($_REQUEST[variable1]) . "',
- variable2 = '" . mysql_escape_string($_REQUEST[variable2]) . "',
- appendix = '" . mysql_escape_string($_REQUEST[appendix]) . "',
- dateaffect = '" . mysql_escape_string($_REQUEST[dateaffect]) . "',
- displaytype = '" . mysql_escape_string($_REQUEST[displaytype]) . "',
- fixed_user = '" . mysql_escape_string($fixed_user) . "',
- displayfields = '" . mysql_escape_string($_REQUEST[fields]) . "',
- fixed_ticket = '" . mysql_escape_string($fixed_ticket) . "',
- fixed_general = '" . mysql_escape_string($fixed_general) . "',
- variable1times = '" . mysql_escape_string($interval) . "'
- ");
- $id = $db->last_id();
- } else {
- $db->query("UPDATE report_stat SET
- title = '" . mysql_escape_string($_REQUEST[title]) . "',
- description = '" . mysql_escape_string($_REQUEST[description]) . "',
- variable1 = '" . mysql_escape_string($_REQUEST[variable1]) . "',
- variable2 = '" . mysql_escape_string($_REQUEST[variable2]) . "',
- appendix = '" . mysql_escape_string($_REQUEST[appendix]) . "',
- dateaffect = '" . mysql_escape_string($_REQUEST[dateaffect]) . "',
- displaytype = '" . mysql_escape_string($_REQUEST[displaytype]) . "',
- fixed_user = '" . mysql_escape_string($fixed_user) . "',
- displayfields = '" . mysql_escape_string($_REQUEST[fields]) . "',
- fixed_ticket = '" . mysql_escape_string($fixed_ticket) . "',
- fixed_general = '" . mysql_escape_string($fixed_general) . "',
- variable1times = '" . mysql_escape_string($interval) . "'
- WHERE id = '$id'
- ");
- }
- if ($_REQUEST['do'] == 'newstat2') {
- jump("reports.php?do=editstat&id=$id", 'New Statistic Created');
- } else {
- jump("reports.php?do=editstat&id=$id", 'Statistic Updated');
- }
- }
- ############################### EDIT / NEW STAT ###############################
- if ($_REQUEST['do'] == "editstat" OR $_REQUEST['do'] == "newstat") {
- if ($_REQUEST['do'] == 'editstat') {
- admin_header('Reports', 'Edit Stat');
- } else {
- admin_header('Reports', 'New Stat');
- }
- echo get_javascript('selectBox.js');
- if ($_REQUEST['do'] == "editstat") {
- $stat = $db->query_return("SELECT * FROM report_stat WHERE id = '$id'");
- $fixed_user = unserialize($stat[fixed_user]);
- $fixed_general = unserialize($stat[fixed_general]);
- $fixed_ticket = unserialize($stat[fixed_ticket]);
- }
- $db->query("SELECT id, name FROM ticket_cat");
- while ($result = $db->row_array()) {
- $cat_array[$result[id]] = $result[name];
- }
- $db->query("SELECT id, name FROM ticket_pri");
- while ($result = $db->row_array()) {
- $pri_array[$result[id]] = $result[name];
- }
- $table[] = array('<b>Title</b> ' . ahelp('Reports', 'Title'),
- form_input('title', $stat[title])
- );
- $table[] = array('<b>Description</b> ' . ahelp('Reports', 'Description'),
- form_textarea('description', 60, 5, $stat[description])
- );
- $table[] = array('<b>Display Type</b> ' . ahelp('Reports', 'Display Type'),
- form_select('displaytype',
- array('data' => 'Data (Show a Table)',
- 'bar' => 'Bar Graph',
- 'databar' => 'Table and Bar Graph',
- 'pie' => 'Pie Chart',
- 'datapie' => 'Table and Pie Chart',
- 'csv' => 'CSV File'),
- '',
- $stat[displaytype])
- );
- $table[] = array('<b>Date Affects</B> ' . ahelp('Reports','Date Affects'),
- form_select('dateaffect',
- array('none' => 'None',
- 'opened' => '[interval] Ticket Opened',
- 'closed' => '[interval] Ticket Closed',
- 'reply' => '[interval] Ticket Replied',
- '1streply_less' => '[length] 1st Ticket Reply (less than)',
- '1streply_greater' => '[length] 1st Ticket Reply (greater than)',
- 'span_less' => '[length] Ticket Lifetime (less than)',
- 'span_more' => '[length] Ticket Lifetime (greater than)'),
- '',
- $stat[dateaffect])
- );
- $intervals = explode(',', $stat[variable1times]);
- if (isset($intervals[0])) {
- $i_years = $intervals[0];
- } else {
- $i_years = 0;
- }
- if (isset($intervals[1])) {
- $i_days = $intervals[1];
- } else {
- $i_days = 0;
- }
- if (isset($intervals[2])) {
- $i_hours = $intervals[2];
- } else {
- $i_hours = 0;
- }
- if (isset($intervals[3])) {
- $i_mins = $intervals[3];
- } else {
- $i_mins = 0;
- }
- $table[] = array('<b>Search Length/Interval</b> ' . ahelp('Reports', 'Search Length/Interval'),
- form_input('txtYears', $i_years, 5) . ' Year(s)<BR>' .
- form_input('txtDays', $i_days, 5) . ' Day(s)<BR>' .
- form_input('txtHours', $i_hours, 5) . ' Hour(s)<BR>' .
- form_input('txtMinutes', $i_mins, 5) . ' Minute(s)<BR>'
- );
- $array = array(
- 'is_open' => 'Ticket Status: open/closed',
- 'priority' => 'Ticket Priority',
- 'category' => 'Ticket Category',
- 'awaiting_tech' => 'Awaiting Response From: tech/user',
- 'tech' => 'Assigned Technician',
- 'userid' => 'User'
- );
- // get rest of ticket data
- $db->query(
- "SELECT * from ticket_def
- ORDER by displayorder"
- );
- while ($result = $db->row_array()) {
- unset($name, $description, $error, $html);
- $tmp = unserialize($result[display_name]);
- $name = $tmp[$settings[default_language]];
- $array[$result[name]] = $name;
- }
- $table[] = array('<b>1st Variable</b> ' . ahelp('Reports', '1st Variable'),
- form_select('variable1', $array, '', $stat[variable1])
- );
- $array = array_merge(array(''), $array);
- $table[] = array('<b>2nd Variable</b> ' . ahelp('Reports', '2nd Variable'),
- form_select('variable2', $array, '', $stat[variable2])
- );
- // <body onLoad="retrieveVals()"> <input type="button" name="Submit" value="Submit" onClick="postThis()">
- $table[] = table_midheader('Ticket Search Restrictions');
- $table[] = array('<b>Open/Closed</b><BR> [Optional] Search only for open
- (or closed) tickets.',
- form_select('open_status',
- array('',
- 'closed' => 'Ticket Closed',
- 'open' => 'Ticket Open'
- ),
- '',
- $fixed_general[open_status],
- 1)
- );
- $table[] = array('<b>Awaiting Response From...</b><BR> [Optional] Search
- only for tickets awaiting a response from a technician (or a user).',
- form_select('awaiting_status',
- array('',
- 'tech' => 'Awaiting Technician Reponse',
- 'user' => 'Awaiting User Response'
- ),
- '',
- $fixed_general[awaiting_status], 1)
- );
- $table[] = array('<b>Priority</b><BR> [Optional] Search only for tickets
- with a priority of...',
- form_select('priority',
- $pri_array,
- '',
- $fixed_general[priority],
- '',
- '',
- 5)
- );
- $table[] = array('<b>Category</b><BR> [Optional] Search only for tickets
- with a category of...',
- form_select('category',
- $cat_array,
- '',
- $fixed_general[category],
- '',
- '',
- 5)
- );
- // used for fields to display
- $statarray = split(',', $stat[displayfields]);
- unset($options, $options2);
- if (!in_array('subject', $statarray)) {
- $options .= "<option value="subject">Subject</option>n";
- } else {
- $options2 .= "<option value="subject">Subject</option>n";
- }
- if (!in_array('category', $statarray)) {
- $options .= "<option value="category">Category</option>n";
- } else {
- $options2 .= "<option value="category">Category</option>n";
- }
- if (!in_array('priority', $statarray)) {
- $options .= "<option value="priority">Priority</option>n";
- } else {
- $options2 .= "<option value="priority">Priority</option>n";
- }
- if (!in_array('tech', $statarray)) {
- $options .= "<option value="tech">Tech Owner</option>n";
- } else {
- $options2 .= "<option value="tech">Tech Owner</option>n";
- }
- if (!in_array('user', $statarray)) {
- $options .= "<option value="user">User Owner</option>n";
- } else {
- $options2 .= "<option value="user">User Owner</option>n";
- }
- // get rest of ticket data
- $db->query(
- "SELECT * from ticket_def
- ORDER by displayorder"
- );
- while ($result = $db->row_array()) {
- unset($name, $description, $error, $html);
- $tmp = unserialize($result[display_name]);
- $name = $tmp[$settings[default_language]];
- // for fields
- if (in_array($result[name], $statarray)) {
- $options2 .= "<option value="$result[name]">$name</option>n";
- } else {
- $options .= "<option value="$result[name]">$name</option>n";
- }
- if ($_REQUEST['do'] == "editstat") {
- $action = 1;
- }
- if ($fixed_ticket[$result[name]]) { // Function iff() doesn't quite do what we need it to here
- $html = field_def($result, iff($action, 'edit', 'default'), '', '', $fixed_ticket[$result[name]], 'ticketfields', 1, $fixed_ticket["$result[name]_match"], $fixed_ticket["$result[name]_not"]);
- } else {
- $html = field_def($result, iff($action, 'edit', 'default'), '', '', '', 'ticketfields', 1, $fixed_ticket["$result[name]_match"], $fixed_ticket["$result[name]_not"]);
- }
- $description = unserialize($result[description]);
- if ($description[1]) {
- $description = "<BR>$description[1]";
- } else {
- $description = "<BR><I>No description</I>";
- }
- $table[] = array("<b>$name</b>$description", $html);
- }
- $table[] = table_midheader('User Search Restrictions');
- $table[] = array('<I>Make selections here to restrict which users' tickets are included by this statistic.</I>');
- // get rest of ticket data
- $db->query(
- "SELECT * from user_def
- ORDER by displayorder"
- );
- $custom = array();
- while ($result = $db->row_array()) {
- unset($name, $description, $error, $html);
- $tmp = unserialize($result[display_name]);
- $name = $tmp[$settings[default_language]];
- if ($fixed_user[$result[name]]) { // Function iff() doesn't quite do what we need it to here
- $html = field_def($result, iff($action, 'edit', 'default'), '', '', $fixed_user[$result[name]], 'userfields', 1, $fixed_user["$result[name]_match"], $fixed_user["$result[name]_not"]);
- } else {
- $html = field_def($result, iff($action, 'edit', 'default'), '', '', '', 'userfields', 1, $fixed_user["$result[name]_match"], $fixed_user["$result[name]_not"]);
- }
- $description = unserialize($result[description]);
- if ($description[1]) {
- $description = "<BR>[Custom] $description[1]";
- } else {
- $description = "<BR>[Custom] <I>No description</I>";
- }
- $table[] = array("<b>$name</b>$description", $html);
- }
- $display = array('ID', 'Subject', 'Category', 'Priority', 'Status');
- $table[] = table_midheader('Detailed Ticket Listing');
- $table[] = array('<b>List Matching Tickets After Statistic?</b><BR> If
- "yes", a list of all tickets matched by this statistic will be shown
- beneath the chart or graph of the data. <I>(Cannot be specified for CSV
- display types</I>.',
- form_radio_yn('appendix',
- '',
- $stat[appendix])
- );
- $table[] = array('<b>Fields to Display</b><BR> For each matched ticket,
- display these fields... <I>(note: selecting too many fields here can
- produce very wide reports, possibly causing formatting errors when
- displaying or printing reports)</I>',
- " <TABLE BORDER=0>
- <TR>
- <TD VALIGN=MIDDLE ALIGN=CENTER>
- <b>Avaliable Fields</b><br />
- <SELECT style="width:200px" NAME="list11" MULTIPLE SIZE=10 onDblClick="moveSelectedOptions(this.form.list11,this.form.list21,false)">
- $options
- </SELECT>
- </TD>
- <TD VALIGN=MIDDLE ALIGN=CENTER>
- <INPUT TYPE="button" NAME="right" VALUE=">>" onClick="moveSelectedOptions(document.forms[0].list11,document.forms[0].list21,false);return false;"><BR><BR>
- <INPUT TYPE="button" NAME="right" VALUE="All >>" onClick="moveAllOptions(document.forms[0].list11,document.forms[0].list21,false); return false;"><BR><BR>
- <INPUT TYPE="button" NAME="left" VALUE="<<" onClick="moveSelectedOptions(document.forms[0].list21,document.forms[0].list11,false); return false;"><BR><BR>
- <INPUT TYPE="button" NAME="left" VALUE="All <<" onClick="moveAllOptions(document.forms[0].list21,document.forms[0].list11,false); return false;">
- </TD>
- <TD VALIGN=MIDDLE ALIGN=CENTER>
- <input type="hidden" name="fields">
- <b>Selected Fields</b><br />
- <SELECT style="width:200px" NAME="list21" MULTIPLE SIZE=10 onDblClick="moveSelectedOptions(this.form.list21,this.form.list11,false)">
- $options2
- </SELECT>
- </TD>
- </TR>
- </TABLE>");
- if ($_REQUEST['do'] == 'editstat') {
- $hidden = array('do' => 'editstat2', 'id' => $stat[id]);
- $end = 'Edit Statistic';
- } else {
- $hidden = array('do' => 'newstat2');
- $end = 'Create Statistic';
- }
- $width = array("40%", "60%");
- table_header('Statistic', 'reports.php', $hidden, '', 'dpform');
- table_content('', $table, '', '', '', '', $width);
- table_footer($end, 'center', '', '', "onclick="submitAllOptions(this.form.list21, this.form.fields)"");
- }