3 * GForge Survey Facility
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 require_once('../../env.inc.php');
27 require_once $gfwww.'include/pre.php';
28 require_once $gfwww.'include/HTML_Graphs.php';
29 require_once $gfwww.'survey/survey_utils.php';
31 $group_id = getIntFromRequest('group_id');
32 $survey_id = getIntFromRequest('survey_id');
34 if (!session_loggedin() || !user_ismember($group_id,'A')) {
35 echo '<div class="error">'._('Permission denied').'</div>';
39 function strip_commas($string) {
40 return ereg_replace(",","",$string);
44 Select this survey from the database
49 $result = db_query_params ('SELECT * FROM surveys WHERE survey_id=$1',
53 Select the questions for this survey and show as top row
56 $questions=db_result($result, 0, "survey_questions");
57 $questions=str_replace(" ", "", $questions);
58 $quest_array=explode(',', $questions);
59 $count=count($quest_array);
74 echo "cust_id,first_name,field_1,email,field2,phone,field3,field4,field5,year,month,day,";
76 for ($i=0; $i<$count; $i++) {
77 $result = db_query_params ('SELECT question FROM questions WHERE question_id=$1 AND question_type <> 4',
78 array($quest_array[$i]));
79 if ($result && db_numrows($result) > 0) {
80 echo strip_commas(db_result($result, 0, 0)).",";
87 Now show the customer rows
90 $result = db_query_params ('SELECT DISTINCT customer_id FROM responses WHERE survey_id=$1',
93 $rows=db_numrows($result);
95 for ($i=0; $i<$rows; $i++) {
98 Get this customer's info
102 $result2 = db_query_params ('SELECT DISTINCT cust_id,first_name,people.last_name,people.email,people.email2,people.phone,people.beeper,people.cell,people.yes_interested,responses.response_year,responses.response_month,responses.response_day FROM people,responses WHERE cust_id=$1 AND cust_id=responses.customer_id',
103 array (db_result($result, $i, "customer_id")));
105 if (db_numrows($result2) > 0) {
107 $cols=db_numfields($result2);
109 for ($i2=0; $i2<$cols; $i2++) {
110 echo strip_commas(db_result($result2, 0, $i2)).",";
114 Get this customer's responses. may have to be ordered by original question order
118 $result3 = db_query_params ('SELECT response FROM responses WHERE customer_id=$1 AND survey_id=$2',
119 array (db_result($result, $i, "customer_id"),
122 $rows3=db_numrows($result3);
124 for ($i3=0; $i3<$rows3; $i3++) {
125 echo strip_commas(db_result($result3, $i3, "response")).",";