3 * GForge Survey Facility
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 require_once('../../env.inc.php');
29 require_once $gfwww.'include/pre.php';
30 require_once $gfwww.'include/HTML_Graphs.php';
31 require_once $gfwww.'survey/survey_utils.php';
33 $group_id = getIntFromRequest('group_id');
34 $survey_id = getIntFromRequest('survey_id');
36 if (!session_loggedin() || !user_ismember($group_id,'A')) {
37 echo "<h1>"._('Permission denied')."</h1>";
41 function strip_commas($string) {
42 return ereg_replace(",","",$string);
46 Select this survey from the database
49 $sql="select * from surveys where survey_id='$survey_id'";
51 $result=db_query($sql);
54 Select the questions for this survey and show as top row
57 $questions=db_result($result, 0, "survey_questions");
58 $questions=str_replace(" ", "", $questions);
59 $quest_array=explode(',', $questions);
60 $count=count($quest_array);
75 echo "cust_id,first_name,field_1,email,field2,phone,field3,field4,field5,year,month,day,";
77 for ($i=0; $i<$count; $i++) {
78 $result=db_query("select question from questions where question_id='$quest_array[$i]' AND question_type <> '4'");
79 if ($result && db_numrows($result) > 0) {
80 echo strip_commas(db_result($result, 0, 0)).",";
87 Now show the customer rows
90 $sql="SELECT DISTINCT customer_id FROM responses WHERE survey_id='$survey_id'";
92 $result=db_query($sql);
94 $rows=db_numrows($result);
96 for ($i=0; $i<$rows; $i++) {
99 Get this customer's info
101 $sql="SELECT DISTINCT cust_id,first_name,people.last_name,people.email,people.email2,people.phone,".
102 "people.beeper,people.cell,people.yes_interested,responses.response_year,".
103 "responses.response_month,responses.response_day FROM people,responses ".
104 "WHERE cust_id='".db_result($result, $i, "customer_id")."' AND cust_id=responses.customer_id";
106 $result2=db_query($sql);
108 if (db_numrows($result2) > 0) {
110 $cols=db_numfields($result2);
112 for ($i2=0; $i2<$cols; $i2++) {
113 echo strip_commas(db_result($result2, 0, $i2)).",";
117 Get this customer's responses. may have to be ordered by original question order
119 $sql="SELECT response FROM responses WHERE customer_id='".db_result($result, $i, "customer_id")."' AND survey_id='$survey_id'";
121 $result3=db_query($sql);
123 $rows3=db_numrows($result3);
125 for ($i3=0; $i3<$rows3; $i3++) {
126 echo strip_commas(db_result($result3, $i3, "response")).",";