5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * http://fusionforge.org/
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once('../../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfwww.'include/HTML_Graphs.php';
29 $group_id = getIntFromRequest('group_id');
30 $survey_id = getIntFromRequest('survey_id');
32 if (!session_loggedin() || !user_ismember($group_id,'A')) {
33 echo '<div class="error">'._('Permission denied').'</div>';
37 function strip_commas($string) {
38 return preg_replace("/,/","",$string);
42 Select this survey from the database
47 $result = db_query_params ('SELECT * FROM surveys WHERE survey_id=$1',
51 Select the questions for this survey and show as top row
54 $questions=db_result($result, 0, "survey_questions");
55 $questions=str_replace(" ", "", $questions);
56 $quest_array=explode(',', $questions);
57 $count=count($quest_array);
72 echo "cust_id,first_name,field_1,email,field2,phone,field3,field4,field5,year,month,day,";
74 for ($i=0; $i<$count; $i++) {
75 $result = db_query_params ('SELECT question FROM questions WHERE question_id=$1 AND question_type <> 4',
76 array($quest_array[$i]));
77 if ($result && db_numrows($result) > 0) {
78 echo strip_commas(db_result($result, 0, 0)).",";
85 Now show the customer rows
88 $result = db_query_params ('SELECT DISTINCT customer_id FROM responses WHERE survey_id=$1',
91 $rows=db_numrows($result);
93 for ($i=0; $i<$rows; $i++) {
96 Get this customer's info
100 $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',
101 array (db_result($result, $i, "customer_id")));
103 if (db_numrows($result2) > 0) {
105 $cols=db_numfields($result2);
107 for ($i2=0; $i2<$cols; $i2++) {
108 echo strip_commas(db_result($result2, 0, $i2)).",";
112 Get this customer's responses. may have to be ordered by original question order
116 $result3 = db_query_params ('SELECT response FROM responses WHERE customer_id=$1 AND survey_id=$2',
117 array (db_result($result, $i, "customer_id"),
120 $rows3=db_numrows($result3);
122 for ($i3=0; $i3<$rows3; $i3++) {
123 echo strip_commas(db_result($result3, $i3, "response")).",";