~adamzammit/quexs/quexslinkcall

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
<?php 
/**
 * Display sample details of respondent
 *
 *
 *	This file is part of queXS
 *	
 *	queXS is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *	
 *	queXS is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *	
 *	You should have received a copy of the GNU General Public License
 *	along with queXS; if not, write to the Free Software
 *	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *
 * @author Adam Zammit <adam.zammit@acspri.org.au
 * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011
 * @package queXS
 * @subpackage user
 * @link http://www.acspri.org.au/ queXS was writen for ACSPRI
 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
 * 
 */

/**
 * Configuration file
 */
include ("config.inc.php");

/**
 * Database file
 */
include ("db.inc.php");

/** 
 * Authentication
 */
require ("auth-interviewer.php");


/**
 * XHTML functions
 */
include ("functions/functions.xhtml.php");

/**
 * Calendar functions
 */
include("functions/functions.calendar.php");

/**
 * Operator functions
 */
include("functions/functions.operator.php");

/**
 * Input functions
 */
include("functions/functions.input.php");

if (isset($_GET['interface2'])) { if (browser_ie()) $jsw = "js/window_ie6_interface2.js"; else $jsw = "js/window_interface2.js"; } 
else { if (browser_ie()) $jsw = "js/window_ie6.js"; else $jsw = "js/window.js"; }
$js = array($jsw);

if (AUTO_LOGOUT_MINUTES !== false)
{
        $js[] = "include/jquery/jquery-1.4.2.min.js";
	$js[] = "js/childnap.js";
}

xhtml_head(T_("Contact details"),false,array("css/table.css","css/respondent_interface2.css"),$js);


global $db;

$db->StartTrans();

$operator_id = get_operator_id();
$call_attempt_id = get_call_attempt($operator_id,false);
$case_id = get_case_id($operator_id);

if (isset($_POST['submit']))
	add_respondent($case_id,$_POST['firstName'],$_POST['lastName'],$_POST['Time_zone_name']);


if (isset($_GET['respondent_id']) && $_GET['respondent_id'] == 0)
{
?>
	<form method="post" action="?">
	<?php  display_respondent_form(false,$case_id); ?>
	<div class="text"><input type='submit' name='submit' id='submit' value='<?php  echo T_("Add respondent"); ?>'/></div>
	</form>
	<div><a href="?"><?php  echo T_("Go back"); ?></a></div>

<?php 
}
else
{
	print "<div class='text'>" . T_("Case id:") . " $case_id</div>";
	print "<div class='text'>" . T_("Respondent:");

	if (isset($_GET['respondent_id']) && $_GET['respondent_id'] != 0)
	{
		$respondent_id = bigintval($_GET['respondent_id']);
	
		$sql = "UPDATE `call_attempt` 
			SET respondent_id = '$respondent_id'
			WHERE call_attempt_id = '$call_attempt_id'";
	
		$db->Execute($sql);
	}

	/* List respondents
	 *
	 */


	$sql = "SELECT r.firstName, r.lastName, r.respondent_id,r.Time_zone_name,CASE WHEN c.respondent_id = r.respondent_id THEN 'selected=\'selected\'' ELSE '' END AS selected
		FROM respondent AS r
		LEFT JOIN call_attempt AS c ON ( c.call_attempt_id = '$call_attempt_id' )
		WHERE r.case_id = '$case_id'";
		
	$rs = $db->GetAll($sql);


	$timezone = "";
	if (ALLOW_RESPONDENT_SELECTOR)
	{
		print "<select id='respondent' name='respondent' onchange=\"LinkUp('respondent')\"><option value='?respondent_id=0' class='addresp'>" . T_("Add respondent") . "</option>";
		if (!empty($rs))
		{
			foreach($rs as $r)
			{
				if (!empty($r['selected'])) $timezone = $r['Time_zone_name'];
				print "<option value='?respondent_id={$r['respondent_id']}' {$r['selected']}>{$r['firstName']} {$r['lastName']}</option>";
			}
		}
		print "</select></div>";
	}
	else
	{
		if (isset($rs[0]))
			print " " . $rs[0]['firstName'] . " " . $rs[0]['lastName'] . "</div>";
	}

	print "<div class='text'>$timezone</div>";



	//display sample details
	//  use sample_import_var_restrict to limit
	$sql = "SELECT sivr.var,sv.val
			FROM `sample_var` as sv, `sample_import_var_restrict` as sivr, `case` as c
			WHERE c.case_id = '$case_id'
			AND sv.sample_id = c.sample_id
			AND sivr.var_id = sv.var_id
			AND (sivr.restrict IS NULL OR sivr.restrict = 0)";
	
	$rs = $db->GetAll($sql);

	print "<div id='details' class='text'>";
	if (!empty($rs))
	{
		xhtml_table($rs,array("var","val"),array(T_("Var"),T_("Value")));
	}
	print "</div>";

}	

xhtml_foot();

$db->CompleteTrans();
?>