-
Notifications
You must be signed in to change notification settings - Fork 4
/
feedback_browse.php
262 lines (238 loc) · 12.8 KB
/
feedback_browse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
// browse_feedback.php - View a list of feedback
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//
// by Ivan Lucas <ivanlucas[at]users.sourceforge.net>, June 2004
$permission = 51; // View Feedback
require ('core.php');
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
$title = $strBrowseFeedback;
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
// External variables
$formid = cleanvar($_REQUEST['id']);
$responseid = cleanvar($_REQUEST['responseid']);
$sort = cleanvar($_REQUEST['sort']);
$order = cleanvar($_REQUEST['order']);
$mode = cleanvar($_REQUEST['mode']);
$completed = cleanvar($_REQUEST['completed']);
switch ($mode)
{
case 'viewresponse':
echo "<h2>{$strFeedback}</h2>";
$sql = "SELECT * FROM `{$dbFeedbackRespondents}` WHERE id='{$responseid}'";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
$response = mysql_fetch_object($result);
echo "<table class='vertical' align='center'>";
echo "<tr><th>{$strContact}</th><td>{$response->contactid} - ".contact_realname($response->contactid)."</td></tr>\n";
echo "<tr><th>{$strIncident}</th><td><a href=\"javascript:incident_details_window('{$response->incidentid}','incident{$response->incidentid}')\">{$response->incidentid} - ".incident_title($response->incidentid)."</a></td>\n";
echo "<tr><th>{$strForm}</th><td>{$response->formid}</td>\n";
echo "<tr><th>{$strDate}</th><td>{$response->created}</td>\n";
echo "<tr><th>{$strCompleted}</th><td>{$response->completed}</td>\n";
echo "</table>\n";
echo "<h3>{$strResponsesToFeedbackForm}</h3>";
$totalresult=0;
$numquestions=0;
$qsql = "SELECT * FROM `{$dbFeedbackQuestions}` WHERE formid='{$response->formid}' AND type='rating' ORDER BY taborder";
$qresult = mysql_query($qsql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
if (mysql_num_rows($qresult) >= 1)
{
$html .= "<table align='center' class='vertical'>";
while ($qrow = mysql_fetch_object($qresult))
{
$numquestions++;
$html .= "<tr><th>Q{$qrow->taborder}: {$qrow->question}</th>";
$sql = "SELECT * FROM `{$dbFeedbackRespondents}` AS f, `{$dbIncidents}` AS i, `{$dbUsers}` AS u, `{$dbFeedbackResults}` AS r ";
$sql .= "WHERE f.incidentid=i.id ";
$sql .= "AND i.owner=u.id ";
$sql .= "AND f.id=r.respondentid ";
$sql .= "AND r.questionid='{$qrow->id}' ";
$sql .= "AND f.id='$responseid' ";
$sql .= "AND f.completed = 'yes' \n";
$sql .= "ORDER BY i.owner, i.id";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
$numresults = 0;
$cumul = 0;
$percent = 0;
$average = 0;
while ($row = mysql_fetch_object($result))
{
if (!empty($row->result))
{
$cumul+=$row->result;
$numresults++;
}
}
if ($numresults>0) $average=number_format(($cumul/$numresults), 2);
$percent =number_format((($average-1) * (100 / ($CONFIG['feedback_max_score'] -1))), 0);
$totalresult+=$average;
$html .= "<td>{$average}</td></tr>";
// <strong>({$percent}%)</strong><br />";
}
$html .= "</table>\n";
$total_average = number_format($totalresult/$numquestions,2);
$total_percent = number_format((($total_average-1) * (100 / ($CONFIG['feedback_max_score'] -1))), 0);
$qsql = "SELECT * FROM `{$dbFeedbackQuestions}` WHERE formid='{$response->formid}' AND type='text' ORDER BY taborder";
$qresult = mysql_query($qsql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
if (mysql_num_rows($qresult) >= 1)
{
while ($qrow = mysql_fetch_object($qresult))
{
$sql = "SELECT * FROM `{$dbFeedbackRespondents}` AS f, `{$dbIncidents}` AS i, `{$dbUsers}` AS u, `{$dbFeedbackResults}` AS r ";
$sql .= "WHERE f.incidentid = i.id ";
$sql .= "AND i.owner = u.id ";
$sql .= "AND f.id = r.respondentid ";
$sql .= "AND r.questionid = '{$qrow->id}' ";
$sql .= "AND f.id = '$responseid' ";
$sql .= "AND f.completed = 'yes' \n";
$sql .= "ORDER BY i.owner, i.id";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
while ($row = mysql_fetch_object($result))
{
$html .= "<p align='center'><strong>Q{$qrow->taborder}: {$qrow->question}</strong></p>";
if (!empty($row->result))
{
$html .= "<p align='center'>{$row->result}</p>";
}
else
{
$html .= "<p align='center'><em>{$strNoAnswerGiven}</em></p>";
}
}
}
}
$html .= "<p align='center'>{$strPositivity}: {$total_average} <strong>({$total_percent}%)</strong></p>";
$surveys += $numresults;
//if ($total_average>0)
echo $html;
echo "\n\n\n<!-- $surveys -->\n\n\n";
}
else echo "<p class='error'>{$strNoResponseFound}</p>";
echo "<p align='center'><a href='{$_SERVER['PHP_SELF']}'>{$strBackToList}</p>";
break;
default:
$sql = "SELECT * FROM `{$dbFeedbackForms}`";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
if (mysql_num_rows($result) == 0)
{
// no feedback forms
echo "<h3>{$title}</h3>";
echo "<p class='error' align='center'>{$strNoFeedbackFormsDefined}</p>";
echo "<p align='center'><a href='feedback_form_edit.php?action=new'>{$strCreateNewForm}</a></p>";
}
else
{
if (empty($formid) AND !empty($CONFIG['feedback_form'])) $formid=$CONFIG['feedback_form'];
else $formid=1;
$sql = "SELECT *, fr.id AS respid FROM `{$dbFeedbackRespondents}` AS fr, `{$dbFeedbackForms}` AS ff ";
$sql .= "WHERE fr.formid = ff.id ";
if ($completed=='no') $sql .= "AND completed='no' ";
else $sql .= "AND completed='yes' ";
if (!empty($formid)) $sql .= "AND formid='$formid'";
if ($order=='a' OR $order=='ASC' OR $order='') $sortorder = "ASC";
else $sortorder = "DESC";
switch ($sort)
{
case 'created': $sql .= " ORDER BY created $sortorder"; break;
case 'contactid': $sql .= " ORDER BY contactid $sortorder"; break;
case 'incidentid': $sql .= " ORDER BY incidentid $sortorder"; break;
default: $sql .= " ORDER BY created DESC"; break;
}
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
$countrows = mysql_num_rows($result);
if (!empty($formid))
{
if ($completed=='no') echo "<h3>{$strFeedbackRequested}: $formid</h3>";
else echo "<h3>{$strResponsesToFeedbackForm}: $formid</h3>";
echo "<p align='center'><a href='feedback_form_edit.php?formid={$formid}'>{$strEdit}</a></p>";
}
else echo "<h3>{$strResponsesToAllFeedbackForms}</h3>";
if ($countrows >= 1)
{
echo "<table summary='feedback forms' width='95%' align='center'>";
echo "<tr>";
echo colheader('created',$strDate, $sort, $order, $filter);
echo colheader('contactid',$strContact,$sort, $order, $filter);
echo colheader('incidentid',$strIncident,$sort, $order, $filter);
echo "<th>{$strOperation}</th>";
echo "</tr>\n";
$shade='shade1';
while ($resp = mysql_fetch_object($result))
{
$respondentarr=explode('-',$resp->respondent);
$responserefarr=explode('-',$resp->responseref);
$hashtext=urlencode($resp->formid)."&&".urlencode($resp->contactid)."&&".urlencode($resp->incidentid);
// $hashcode=urlencode(trim(base64_encode(gzcompress(str_rot13($hashtext)))));
$hashcode4=str_rot13($hashtext);
$hashcode3=gzcompress($hashcode4);
$hashcode2=base64_encode($hashcode3);
$hashcode1=trim($hashcode2);
$hashcode=urlencode($hashcode1);
echo "<tr class='$shade'>";
echo "<td>".ldate($CONFIG['dateformat_datetime'],mysqlts2date($resp->created))."</td>";
echo "<td><a href='contact_details.php?id={$resp->contactid}' title='{$resp->email}'>".contact_realname($resp->contactid)."</a></td>";
echo "<td><a href=\"javascript:incident_details_window('{$resp->incidentid}','incident{$resp->incidentid}')\">";
echo "{$strIncident} [{$resp->incidentid}]</a> - ";
echo incident_title($resp->incidentid)."</td>";
$url = "feedback.php?ax={$hashcode}";
if ($resp->multi=='yes') $url .= "&rr=1";
echo "<td>";
if ($resp->completed == 'no') echo "<a href='{$url}' title='{$url}' target='_blank'>URL</a>";
$eurl = urlencode($url);
$eref = urlencode($resp->responseref);
if ($resp->completed == 'no')
{
//if ($resp->remind<1) echo "<a href='formactions.php?action=remind&id={$resp->respid}&url={$eurl}&ref={$eref}' title='Send a reminder by email'>Remind</a>";
//elseif ($resp->remind==1) echo "<a href='formactions.php?action=remind&id={$resp->respid}&url={$eurl}&ref={$eref}' title='Send a Second reminder by email'>Remind Again</a>";
//elseif ($resp->remind==2) echo "<a href='formactions.php?action=callremind&id={$resp->respid}&url={$eurl}&ref={$eref}' title='Send a Third reminder by phone call, click here when its done'>Remind by Phone</a>";
//else echo "<strike title='Already sent 3 reminders'>Remind</strike>";
//echo " • ";
//echo "<a href='formactions.php?action=delete&id={$resp->respid}' title='Remove this form'>Delete</a>";
}
else
{
echo "<a href='{$_SERVER['PHP_SELF']}?mode=viewresponse&responseid={$resp->respid}'>{$strViewResponse}</a>";
}
echo "</td>";
echo "</tr>\n";
if ($shade=='shade1') $shade='shade2';
else $shade='shade1';
}
echo "</table>\n";
}
else
{
echo "<p class='error' align='center'>{$strNoResponseFound}</p>";
}
if ($completed=='no')
{
$sql = "SELECT COUNT(id) FROM `{$dbFeedbackRespondents}` WHERE formid='{$formid}' AND completed='yes'";
$result = mysql_query($sql);
list($completedforms) = mysql_fetch_row($result);
if ($completedforms > 0)
echo "<p align='center'>".sprintf($strFeedbackFormsReturned, "<a href='{$_SERVER['PHP_SELF']}'>{$completedforms}</a>")."</p>";
}
else
{
$sql = "SELECT COUNT(id) FROM `{$dbFeedbackRespondents}` WHERE formid='{$formid}' AND completed='no'";
$result = mysql_query($sql);
list($waiting) = mysql_fetch_row($result);
if ($waiting > 0) echo "<p align='center'>".sprintf($strFeedbackFormsWaiting, "<a href='{$_SERVER['PHP_SELF']}?completed=no'>{$waiting}")."</p>";
}
}
}
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
?>