2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Import from DCARF SVN

This commit is contained in:
azammitdcarf
2008-10-15 04:49:50 +00:00
parent 74c9cb7408
commit ec24d5af18
45 changed files with 12429 additions and 0 deletions

262
admin/addshift.php Normal file
View File

@@ -0,0 +1,262 @@
<?
/**
* Add and modify shifts by questionnaire
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Operator functions
*/
include ("../functions/functions.operator.php");
/**
* Display functions
*/
include ("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
/**
* Add shifts to the DB based on the shift_template table
*/
if (isset($_POST['year'])) $year = bigintval($_POST['year']); else $year = "YEAR(NOW())";
if (isset($_POST['woy'])) $woy = bigintval($_POST['woy']); else $woy = "WEEK(NOW(), 3)";
if (isset($_POST['qid'])) $questionnaire_id = bigintval($_POST['qid']); else $questionnaire_id = false;
if (isset($_GET['year'])) $year = bigintval($_GET['year']);
if (isset($_GET['woy'])) $woy = bigintval($_GET['woy']);
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
$y = $db->GetRow("SELECT $year as y");
$year = $y['y'];
$y = $db->GetRow("SELECT $woy as y");
$woy = $y['y'];
$operator_id = get_operator_id();
if (isset($_POST['submit']))
{
//process
//update or delete existing shifts
foreach($_POST as $key => $val)
{
if (substr($key,0,5) == "start")
{
$num = bigintval(substr($key,6));
if (isset($_POST["use_$num"]))
{
$sql = "UPDATE shift as s, operator as o
SET s.start = CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["dow_$num"]}),'%x %v %w'),' ','" . $_POST["start_$num"] . "'), o.Time_zone_name, 'UTC'),
s.end = CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["dow_$num"]}),'%x %v %w'),' ','" . $_POST["end_$num"] . "'), o.Time_zone_name, 'UTC')
WHERE o.operator_id = '$operator_id'
AND shift_id = '$num'";
$db->Execute($sql);
}
else
{
$sql = "DELETE FROM shift
WHERE shift_id = '$num'";
$db->Execute($sql);
}
}
}
//insert new shifts
foreach($_POST as $key => $val)
{
if (substr($key,0,7) == "NEW_use")
{
if ($val == "on")
{
$num = bigintval(substr($key,8));
$sql = "INSERT INTO shift (shift_id,questionnaire_id,start,end)
SELECT NULL,'$questionnaire_id', CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["NEW_dow_$num"]}),'%x %v %w'),' ','" . $_POST["NEW_start_$num"] . "'), Time_zone_name, 'UTC') , CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["NEW_dow_$num"]}),'%x %v %w'),' ','" . $_POST["NEW_end_$num"] . "'), Time_zone_name, 'UTC')
FROM operator
WHERE operator_id = '$operator_id'";
$db->Execute($sql);
}
}
}
}
xhtml_head(T_("Add shifts"),false,false,array("../js/window.js"));
?>
<style type="text/css">
.selected {
font-weight:bold;
font-size:larger;
}
</style>
</head>
<body>
<?
/**
* display years including current selected year
* display weeks of year including current selected week of year
* find if there are already shifts defined for this week of year / year and display them as selected, else show from template
* when submitted, add checked shifts, and delete unchecked shifts if they exist
*
* @todo Use javascript to add shifts if necessarry outside the template
*/
print "<h2>" . T_("Add shifts in your Time Zone") . "</h2>";
print "<h3>" . T_("Select a questionnaire from the list below") . "</h3>";
display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id != false)
{
print "<p>";
for ($i = $year - 1; $i < $year + 4; $i++)
{
if ($i == $year)
print "$i ";
else
print "<a href=\"?year=$i&amp;woy=$woy&amp;questionnaire_id=$questionnaire_id\">$i</a> ";
}
print "</p>";
print "<p>";
for ($i = 1; $i <= 53; $i++)
{
if ($i == $woy)
print "$i ";
else
print "<a href=\"?woy=$i&amp;year=$year&amp;questionnaire_id=$questionnaire_id\">$i</a> ";
}
print "</p>";
$sql = "SELECT shift_id, dt, dta,start,end
FROM (
(
SELECT shift_id, DATE_FORMAT( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) , '%W %d %M %Y' ) AS dt,
DATE( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) AS dta,
TIME( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) AS start,
TIME( CONVERT_TZ( s.end, 'UTC', o.Time_zone_name ) ) AS end
FROM shift AS s, operator AS o
WHERE WEEK( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) , 3 ) = '$woy'
AND YEAR( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) = '$year'
AND o.operator_id = '$operator_id'
AND s.questionnaire_id = '$questionnaire_id'
)
UNION (
SELECT NULL AS shift_id,
DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W %d %M %Y' ) AS dt,
STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) AS dta,
start,end
FROM shift_template
)
) AS sb
GROUP BY dta,start,end";
$shifts = $db->GetAll($sql);
$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W %d %M %Y') as dt, day_of_week - 1 as dow
FROM shift_template
GROUP BY dow";
$daysofweek = $db->Execute($sql);
?>
<form method="post" action="">
<table>
<?
print "<tr><th>" . T_("Day") . "</th><th>" . T_("Start") . "</th><th>" . T_("End") . "</th><th>" . T_("Use shift?") . "</th></tr>";
$count = 1;
foreach($shifts as $shift)
{
$checked="";
$shift_id="";
$prefix="";
if (!empty($shift['shift_id']))
{
$checked="checked=\"checked\""; $shift_id = $shift['shift_id'];
}
else
{
$shift_id = $count;
$prefix = "NEW_";
}
print "<tr><td>" . $daysofweek->GetMenu($prefix . "dow_$shift_id",$shift['dt']) . "</td><td><input size=\"8\" name=\"" . $prefix ."start_$shift_id\" maxlength=\"8\" type=\"text\" value=\"{$shift['start']}\"/></td><td><input name=\"" . $prefix ."end_$shift_id\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"{$shift['end']}\"/></td><td><input name=\"" . $prefix ."use_$shift_id\" type=\"checkbox\" $checked/></td></tr>";
$daysofweek->MoveFirst();
$count++;
}
?>
<!--<tr><td/><td/><td/><td>Select all</td></tr>-->
</table>
<!--<p><input type="submit" name="addshift" value="Add Shift"/></p>-->
<p><input type="submit" name="submit" value="Submit changes"/></p>
<p><input type="hidden" name="year" value="<? echo $year; ?>"/></p>
<p><input type="hidden" name="woy" value="<? echo $woy; ?>"/></p>
<p><input type="hidden" name="qid" value="<? echo $questionnaire_id; ?>"/></p>
</form>
<?
}
xhtml_foot();
?>

161
admin/assignsample.php Normal file
View File

@@ -0,0 +1,161 @@
<?
/**
* Assign sample(s) to a questionnaire
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max']))
{
//need to add sample to questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$sid = bigintval($_GET['sample']);
$cm = bigintval($_GET['call_max']);
$cam = bigintval($_GET['call_attempt_max']);
$am = bigintval($_GET['answering_machine_messages']);
$selecttype = 0;
if (isset($_GET['selecttype'])) $selecttype = 1;
$sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages)
VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am')";
$db->Execute($sql);
}
if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
{
//need to remove rsid from questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$sid = bigintval($_GET['rsid']);
$sql = "DELETE FROM questionnaire_sample
WHERE questionnaire_id = '$questionnaire_id'
AND sample_import_id = '$sid'";
$db->Execute($sql);
}
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
xhtml_head(T_("Assign Sample: Select sample to assign"),true,false,array("../js/window.js"));
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id != false)
{
print "<h1>" . T_("Samples selected for this questionnaire") . "</h1>";
$sql = "SELECT q.sample_import_id as sample_import_id,si.description as description, q.call_max, q.call_attempt_max, q.random_select
FROM questionnaire_sample as q, sample_import as si
WHERE q.sample_import_id = si.sample_import_id
AND q.questionnaire_id = '$questionnaire_id'";
$qs = $db->GetAll($sql);
foreach($qs as $q)
{
if ($q['random_select'] == 0) $rs = T_("Sequentially selected");
else $rs = T_("Randomly selected");
print "<p><a href=\"?questionnaire_id=$questionnaire_id&amp;rsid={$q['sample_import_id']}\">{$q['sample_import_id']} - {$q['description']}: " . T_("Max calls:") . " {$q['call_max']} " . T_("Max call attempts:") . " {$q['call_attempt_max']} $rs (" . T_("Click to unassign") . ")</a></p>";
}
$sql = "SELECT si.sample_import_id,si.description
FROM sample_import as si
LEFT JOIN questionnaire_sample as q ON (q.questionnaire_id = '$questionnaire_id' AND q.sample_import_id = si.sample_import_id)
WHERE q.questionnaire_id is NULL";
$qs = $db->GetAll($sql);
if (!empty($qs))
{
print "<h1>" . T_("Add a sample to this questionnaire:") . "</h1>";
?>
<form action="" method="get">
<p><label for="sample"><? echo T_("Select sample:"); ?></label><select name="sample" id="sample">
<?
foreach($qs as $q)
{
print "<option value=\"{$q['sample_import_id']}\">{$q['description']}</option>";
}
?>
</select><br/>
<label for="call_max"><? echo T_("Max calls (0 for unlimited)"); ?></label><input type="text" name="call_max" id="call_max" value="0"/><br/>
<label for="call_attempt_max"><? echo T_("Max call attempts (0 for unlimited)"); ?></label><input type="text" name="call_attempt_max" id="call_attempt_max" value="0"/> <br/>
<label for="answering_machine_messages"><? echo T_("Number of answering machine messages to leave per case (0 for never)"); ?></label><input type="text" name="answering_machine_messages" id="answering_machine_messages" value="1"/> <br/>
<label for="selecttype"><? echo T_("Select from sample randomly? (otherwise sequentially)"); ?></label><input type="checkbox" id = "selecttype" name="selecttype" /> <br/>
<input type="hidden" name="questionnaire_id" value="<? print($questionnaire_id); ?>"/>
<input type="submit" name="add_sample" value="Add sample"/></p>
</form>
<?
}
}
xhtml_foot();
?>

80
admin/callhistory.php Normal file
View File

@@ -0,0 +1,80 @@
<?
/**
* Display a list of calls and outcomes for all calls
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage user
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Operator functions
*/
include("../functions/functions.operator.php");
xhtml_head(T_("Call History List"),true,array("../css/table.css"));
//List the case call history
$operator_id = get_operator_id();
if ($operator_id)
{
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as start,DATE_FORMAT(CONVERT_TZ(c.end,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as end, o.description as des, (CONCAT(r.firstName,' ',r.lastName)) as firstName, opp.firstName as opname, CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id
FROM `call` as c
JOIN (operator as op, respondent as r) on (op.operator_id = '$operator_id' and r.respondent_id = c.respondent_id)
LEFT JOIN (outcome as o) on (c.outcome_id = o.outcome_id)
LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id)
ORDER BY c.start DESC
LIMIT 500";
$rs = $db->GetAll($sql);
if (empty($rs))
print "<p>" . T_("No calls ever made") . "</p>";
else
xhtml_table($rs,array("start","end","case_id","opname","des","firstName"),array(T_("Date/Time call start"),T_("Time end"),T_("Case ID"),T_("Operator"),T_("Outcome"),T_("Respondent")));
}
else
print "<p>" . T_("No operator") . "</p>";
xhtml_foot();
?>

View File

@@ -0,0 +1,273 @@
<?
/**
* Assign clients to questionnaires in a checkbox matrix
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Return if an client has already been assigned to this questionnaire
*
* @param int $client Client id
* @param int $questionnaire_id Questionnaire id
* @return int 1 if assigned otherwise 0
*
*/
function vq($client_id,$questionnaire_id)
{
global $db;
$sql = "SELECT client_id,questionnaire_id
FROM client_questionnaire
WHERE client_id = '$client_id' and questionnaire_id = '$questionnaire_id'";
$vq = $db->Execute($sql);
return $vq->RecordCount();
}
/**
* Assign an client to a questionnaire
*
* @param int $client_id Client id
* @param int $questionnaire_id Questionnaire id
*
*/
function vqi($client_id,$questionnaire_id)
{
global $db;
$sql = "INSERT INTO
client_questionnaire (client_id,questionnaire_id)
VALUES('$client_id','$questionnaire_id')";
$db->Execute($sql);
}
/**
* Unassign an client from a questionnaire
*
* @param int $client_id Client id
* @param int $questionnaire_id Questionnaire id
*
*/
function vqd($client_id,$questionnaire_id)
{
global $db;
$sql = "DELETE FROM
client_questionnaire
WHERE client_id = '$client_id' and questionnaire_id = '$questionnaire_id'";
$db->Execute($sql);
}
if (isset($_POST['submit']))
{
$db->StartTrans();
$sql = "DELETE
FROM client_questionnaire
WHERE 1";
$db->Execute($sql);
foreach ($_POST as $g => $v)
{
$a = explode("_",$g);
if ($a[0] == "cb")
vqi($a[2],$a[1]);
}
$db->CompleteTrans();
}
$sql = "SELECT questionnaire_id,description
FROM questionnaire
ORDER by questionnaire_id ASC";
$questionnaires = $db->GetAll($sql);
$sql = "SELECT client_id,firstname as description
FROM client
ORDER by client_id ASC";
$clients = $db->GetAll($sql);
xhtml_head(T_("Assign clients to questionnaires"),false,array("../css/table.css"));
?>
<script type="text/javascript">
<?
print "questionnaire_id = new Array(";
$s = "";
foreach($questionnaires as $q)
{
$s .= "'{$q['questionnaire_id']}',";
}
$s = substr($s,0,strlen($s) - 1);
print "$s);\n";
print "client_id = new Array(";
$s = "";
foreach($clients as $q)
{
$s .= "'{$q['client_id']}',";
}
$s = substr($s,0,strlen($s) - 1);
print "$s);\n";
?>
var QidOn = 0;
var VidOn = 0;
function checkQid(q)
{
for (y in client_id)
{
v = client_id[y];
cb = document.getElementById('cb_' + q + "_" + v);
if (QidOn == 0)
cb.checked = 'checked';
else
cb.checked = '';
}
if (QidOn == 0)
QidOn = 1;
else
QidOn = 0;
}
function checkVid(v)
{
for (y in questionnaire_id)
{
q = questionnaire_id[y];
cb = document.getElementById('cb_' + q + "_" + v);
if (VidOn == 0)
cb.checked = 'checked';
else
cb.checked = '';
}
if (VidOn == 0)
VidOn = 1;
else
VidOn = 0;
}
</script>
</head>
<body>
<?
print "<form action=\"\" method=\"post\"><table>";
print "<tr><th></th>";
foreach($questionnaires as $q)
{
print "<th><a href=\"javascript:checkQid({$q['questionnaire_id']})\">{$q['description']}</a></th>";
}
print "</tr>";
$class = 0;
foreach($clients as $v)
{
print "<tr class='";
if ($class == 0) {$class = 1; print "even";} else {$class = 0; print "odd";}
print "'>";
print "<th><a href=\"javascript:checkVid({$v['client_id']})\">{$v['description']}</a></th>";
foreach($questionnaires as $q)
{
$checked = "";
if (vq($v['client_id'],$q['questionnaire_id'])) $checked="checked=\"checked\"";
print "<td><input type=\"checkbox\" name=\"cb_{$q['questionnaire_id']}_{$v['client_id']}\" id=\"cb_{$q['questionnaire_id']}_{$v['client_id']}\" $checked></input></td>";
}
print "</tr>";
}
print "</table><p><input type=\"submit\" name=\"submit\"/></p></form>";
xhtml_foot();
?>

101
admin/clients.php Normal file
View File

@@ -0,0 +1,101 @@
<?
/**
* Create a client and link to a webserver username for authentication
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
* @todo Make timezone a drop down list
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
global $db;
$a = false;
if (isset($_POST['client']))
{
$client = $db->qstr($_POST['client'],get_magic_quotes_gpc());
$firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc());
$lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc());
$time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc());
if (!empty($_POST['client']))
{
$sql = "INSERT INTO client
(`client_id` ,`username` ,`firstName` ,`lastName`, `Time_zone_name`)
VALUES (NULL , $client, $firstname , $lastname, $time_zone_name);";
if ($db->Execute($sql))
$a = T_("Added: $client");
else
$a = T_("Could not add") . " " . $client . ". " . T_("There may already be an client of this name");
}
}
xhtml_head(T_("Add a client"));
if ($a)
{
?>
<h3><? echo $a; ?></h3>
<?
}
?>
<h1><? echo T_("Add a client"); ?></h1>
<p><? echo T_("Adding a client here will allow them to access project information in the client subdirectory. You can assign a client to a particular project using the"); ?> <a href="clientquestionnaire.php"><? echo T_("Assign client to Questionnaire"); ?></a> <? echo T_("tool."); ?></p>
<p><? echo T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here."); ?></p>
<form enctype="multipart/form-data" action="" method="post">
<p><? echo T_("Enter the username of an client to add:"); ?> <input name="client" type="text"/></p>
<p><? echo T_("Enter the first name of an client to add:"); ?> <input name="firstname" type="text"/></p>
<p><? echo T_("Enter the surname of an client to add:"); ?> <input name="lastname" type="text"/></p>
<p><? echo T_("Enter the Time Zone of an client to add:"); ?> <input name="Time_zone_name" type="text" value="<? echo DEFAULT_TIME_ZONE; ?>"/></p>
<p><input type="submit" value="Add user" /></p>
</form>
<?
xhtml_foot();
?>

154
admin/dataoutput.php Normal file
View File

@@ -0,0 +1,154 @@
<?php
/**
* Output data as a fixed width ASCII file
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Input functions
*/
include("../functions/functions.input.php");
if (isset($_GET['data']))
{
/**
* Limesurvey functions
*/
include("../functions/functions.limesurvey.php");
$questionnaire_id = false;
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
limesurvey_export_fixed_width($questionnaire_id,$sample_import_id);
exit();
}
/**
* Configuration file
*/
include_once(dirname(__FILE__).'/../config.inc.php');
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
if (isset($_GET['sample_var']))
{
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$sample_import_id = bigintval($_GET['sample_import_id']);
$sample_var = $db->quote($_GET['sample_var']);
$sql = "SELECT c.case_id, sv.val
FROM sample, `case` as c, sample_var as sv
WHERE c.questionnaire_id = '$questionnaire_id'
AND sample.import_id = '$sample_import_id'
AND c.sample_id = sample.sample_id
AND sv.sample_id = sample.sample_id
AND sv.var = $sample_var";
$list = $db->GetAll($sql);
$fn = "key_$questionnaire_id" . "_" . $sample_import_id .".csv";
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache"); // HTTP/1.0
echo("caseid,$sample_var\n");
if (!empty($list))
{
foreach($list as $l)
{
echo $l['case_id'] . "," . $l['val'] . "\n";
}
}
exit;
}
xhtml_head(T_("Data output"),true,false,array("../js/window.js"));
print "<h3>Please select a questionnaire</h3>";
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id)
{
print "<p><a href='?data&amp;questionnaire_id=$questionnaire_id'>Download all data for this questionnaire</a></p>";
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
display_sample_chooser($questionnaire_id,$sample_import_id);
if ($sample_import_id)
{
print "<p><a href='?data&amp;questionnaire_id=$questionnaire_id&amp;sample_import_id=$sample_import_id'>Download data for this sample</a></p>";
//get sample vars
$sql = "SELECT sv.var as value, sv.var as description
FROM `sample_var` as sv
WHERE sv.sample_id = (SELECT sample_id FROM sample WHERE import_id = '$sample_import_id' LIMIT 1)";
//download a key file linking the caseid to the sample
print "<h3>Download key file: select sample var</h3>";
display_chooser($db->GetAll($sql),"sample_var","sample_var",true,"questionnaire_id=$questionnaire_id&amp;sample_import_id=$sample_import_id");
}
}
xhtml_foot();
?>

View File

@@ -0,0 +1,100 @@
<?php
/**
* Display appointments
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include_once(dirname(__FILE__).'/../config.inc.php');
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Operator functions
*/
include ("../functions/functions.operator.php");
/**
* Input functions
*/
include ("../functions/functions.input.php");
if (isset($_GET['appointment_id']) && isset($_GET['case_id']))
{
$appointment_id = bigintval($_GET['appointment_id']);
$case_id = bigintval($_GET['case_id']);
$sql = "DELETE FROM appointment
WHERE appointment_id = '$appointment_id'";
$db->Execute($sql);
xhtml_head(T_("Now modify case outcome"));
print "<p>" . T_("The appointment has been deleted. Now you must modify the case outcome") . "</p>";
print "<p><a href='supervisor.php?case_id=$case_id'>" . T_("Modify case outcome") . "</a></p>";
}
else
{
$operator_id = get_operator_id();
xhtml_head(T_("Display Appointments"),true,array("../css/table.css"));
print "<h1>" . T_("Appointments") . "</h1><h2>" . T_("All appointments (with times displayed in your time zone)") . "</h2>";
$sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',o.Time_zone_name) as start, CONVERT_TZ(a.end,'UTC',o.Time_zone_name) as end, r.firstName, r.lastName, IFNULL(ou.description,'" . T_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName, CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id, CONCAT('<a href=\'?case_id=', c.case_id, '&amp;appointment_id=', a.appointment_id, '\'>". T_("Delete") . "</a>') as link
FROM appointment as a
JOIN (`case` as c, respondent as r, questionnaire as q, operator as o, operator as oo, call_attempt as cc) on (a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and o.operator_id = '$operator_id' and a.call_attempt_id = cc.call_attempt_id and cc.operator_id = oo.operator_id)
LEFT JOIN (`call` as ca, outcome as ou, operator as ooo) ON (ca.call_id = a.completed_call_id and ou.outcome_id = ca.outcome_id and ca.operator_id = ooo.operator_id)
WHERE a.end >= CONVERT_TZ(NOW(),'System','UTC')
ORDER BY a.start ASC";
$rs = $db->GetAll($sql);
if (!empty($rs))
xhtml_table($rs,array("description","case_id","start","end","makerName","firstName","lastName","outcome","callerName","link"),array(T_("Questionnaire"),T_("Case ID"),T_("Start"),T_("End"),T_("Operator Name"),T_("Respondent Name"),T_("Surname"),T_("Current outcome"),T_("Operator who called"),T_("Delete")));
else
print "<p>" . T_("No appointments in the future") . "</p>";
}
xhtml_foot();
?>

131
admin/import.php Normal file
View File

@@ -0,0 +1,131 @@
<?
/**
* Import a sample from a Headered CSV file
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Sample import functions
*/
include("../functions/functions.import.php");
session_start();
if (isset($_GET['import_form']))
{
//form has been submitted
xhtml_head(T_("Import: Validating and uploading"));
//verify each GET field is unique (except import_form)
$sfields = array();
foreach($_GET as $getv => $val)
//clean up?
$sfields[$getv] = $val;
$error = verify_fields($sfields);
$description = $_GET['description'];
if ($error == "")
{ //verified so upload
if (import_file($_SESSION['filename'],$description,$sfields))
{
print "<p>" . T_("Successfully imported file") . "</p>";
}
else
{
print "<p>" . T_("Error importing file. Please try again") . "</p>";
}
}
else
print "<p>" . T_("Error:") . " $error </p><p>" . T_("Please go back in your browser and fix the problem") . "</p>";
//verifiy that exactly one primary phone number is selected
//upload to database
xhtml_foot();
}
else if (isset($_POST['import_file']))
{
//file has been submitted
xhtml_head(T_("Import: Select columns to import"));
?>
<form action="" method="get">
<?
$tmpfname = tempnam("/tmp", "FOO");
move_uploaded_file($_FILES['file']['tmp_name'],$tmpfname);
$_SESSION['filename'] = $tmpfname;
display_table(get_first_row($tmpfname));
?>
<p><input type="hidden" name="description" value="<? if (isset($_POST['description'])) print($_POST['description']); ?>"/></p>
<p><input type="submit" name="import_form"/></p>
</form>
<?
xhtml_foot();
}
else
{
//need to supply file to upload
xhtml_head(T_("Import: Select file to upload"));
?>
<form enctype="multipart/form-data" action="" method="post">
<p><input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></p>
<p><? echo T_("Choose the CSV sample file to upload:"); ?><input name="file" type="file" /></p>
<p><? echo T_("Description for file:"); ?><input name="description" type="text" /></p>
<p><input type="submit" name="import_file"/></p>
</form>
<?
xhtml_foot();
}
?>

88
admin/index.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
/**
* Display an index of Admin tools
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Language file
*/
include ("../lang.inc.php");
/**
* Config file
*/
include ("../config.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
xhtml_head(T_("Administrative Tools"),true,array("../css/table.css","../css/admin.css"),array("../js/link.js"));
print "<div id='menu'><h3>" . T_("Questionnaire creation and management") . "</h3>";
print "<div><a href=\"javascript:link('mainobj','new.php');\">" . T_("Create a new questionnaire") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','" . LIME_URL . "admin/admin.php');\">" . T_("Administer questionnaires with Limesurvey") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','import.php');\">" . T_("Import a sample file (in CSV form)") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','assignsample.php');\">" . T_("Assign samples to questionnaires") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','questionnaireprefill.php');\">" . T_("Set values in questionnaire to pre fill") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','operators.php');\">" . T_("Add operators to the system") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','operatorquestionnaire.php');\">" . T_("Assign operators to questionnaires") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','operatorskill.php');\">" . T_("Modify operator skills") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','addshift.php');\">" . T_("Shift management (add/remove)") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','dataoutput.php');\">" . T_("Data output") . "</a></div>";
print "<h3>" . T_("Questionnaire progress") . "</h3>";
print "<div><a href=\"javascript:link('mainobj','displayappointments.php');\">" . T_("Display all future appointments") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','outcomes.php');\">" . T_("Questionnaire outcomes") . "</a></div>";
print "<h3>" . T_("Performance") . "</h3>";
print "<div><a href=\"javascript:link('mainobj','operatorperformance.php');\">" . T_("Operator performance") . "</a></div>";
print "<h3>" . T_("Client management") . "</h3>";
print "<div><a href=\"javascript:link('mainobj','clients.php');\">" . T_("Add clients to the system") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','clientquestionnaire.php');\">" . T_("Assign clients to questionnaires") . "</a></div>";
print "<h3>" . T_("Supervisor functions") . "</h3>";
print "<div><a href=\"javascript:link('mainobj','supervisor.php');\">" . T_("Assign outcomes to cases") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','samplesearch.php');\">" . T_("Search the sample") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','callhistory.php');\">" . T_("Call history") . "</a></div>";
print "<div><a href=\"javascript:link('mainobj','shiftreport.php');\">" . T_("Shift reports") . "</a></div>";
print "</div>";
print "<div id='main'><object class='embeddedobject' id='mainobj' data='new.php' standby='Loading panel...' type='application/xhtml+xml'><p>Error, try with Firefox</p></object></div>";
xhtml_foot();
?>

154
admin/new.php Normal file
View File

@@ -0,0 +1,154 @@
<?
/**
* Create a queXS questionnaire and link it to a LimeSurvey questionnaire
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
* @todo Create from queXML
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $ldb;
global $db;
xhtml_head(T_("New: Create new questionnaire"));
if (isset($_POST['import_file']))
{
//file has been submitted
global $db;
$ras =0;
$rws = 0;
$testing = 0;
$rs = 0;
$lime_sid = 0;
if (isset($_POST['ras'])) $ras = 1;
if (isset($_POST['rws'])) $rws = 1;
if (isset($_POST['testing'])) $testing = 1;
if (isset($_POST['rs'])) $rs = 1;
$name = $db->qstr($_POST['description'],get_magic_quotes_gpc());
$rs_intro = $db->qstr($_POST['rs_intro'],get_magic_quotes_gpc());
$rs_project_intro = $db->qstr($_POST['rs_project_intro'],get_magic_quotes_gpc());
$rs_project_end = $db->qstr($_POST['rs_project_end'],get_magic_quotes_gpc());
$rs_callback = $db->qstr($_POST['rs_callback'],get_magic_quotes_gpc());
$rs_answeringmachine = $db->qstr($_POST['rs_answeringmachine'],get_magic_quotes_gpc());
if ($_POST['select'] == "new")
{
//create one from scratch
include("../functions/functions.limesurvey.php");
$lime_sid = create_limesurvey_questionnaire($name);
}else if ($_POST['select'] == "quexml")
{
//create from queXML
}else
{
//use existing lime instrument
$lime_sid = bigintval($_POST['select']);
}
$sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing)
VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing')";
$rs = $db->Execute($sql);
if ($rs)
{
$qid = $db->Insert_ID();
print "<p>Successfully inserted $name as questionnaire $qid, linked to $lime_sid</p>";
}else
{
print "<p>Error: Failed to insert questionnaire</p>";
}
}
//create new questionnaire
?>
<form enctype="multipart/form-data" action="" method="post">
<p><input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></p>
<p><? echo T_("Name for questionnaire:"); ?> <input type="text" name="description"/></p>
<p><? echo T_("Select creation type:"); ?> <select name="select"><option value="quexml"><? echo T_("Create from queXML"); ?></option><option value="new"><? echo T_("Create new questionnaire in Limesurvey"); ?></option><?
$sql = "SELECT s.sid as sid, sl.surveyls_title AS title
FROM " . LIME_PREFIX . "surveys AS s
LEFT JOIN " . LIME_PREFIX . "surveys_languagesettings AS sl ON ( s.sid = sl.surveyls_survey_id
AND sl.surveyls_language = 'en' )
WHERE s.active = 'Y'";
$surveys = $ldb->GetAll($sql);
foreach($surveys as $s)
{
print "<option value=\"{$s['sid']}\">" . T_("Existing questionnaire:") . " {$s['title']}</option>";
}
?></select></p>
<p><? echo T_("Choose the queXML file (if required):"); ?> <input name="file" type="file" /></p>
<p><? echo T_("Restrict appointments to shifts?"); ?> <input name="ras" type="checkbox" checked="checked"/></p>
<p><? echo T_("Restrict work to shifts?"); ?> <input name="rws" type="checkbox" checked="checked"/></p>
<p><? echo T_("Questionnaire for testing only?"); ?> <input name="testing" type="checkbox"/></p>
<p><? echo T_("Use respondent selection text?"); ?> <input name="rs" type="checkbox" checked="checked"/></p>
<p><? echo T_("Respondent selection introduction:"); ?> <input type="text" name="rs_intro"/></p>
<p><? echo T_("Respondent selection project introduction:"); ?> <input type="text" name="rs_project_intro"/></p>
<p><? echo T_("Respondent selection project end:"); ?> <input type="text" name="rs_project_end"/></p>
<p><? echo T_("Respondent selection callback (already started questionnaire):"); ?> <input type="text" name="rs_callback"/></p>
<p><? echo T_("Message to leave on an answering machine:"); ?> <input type="text" name="rs_answeringmachine"/></p>
<p><input type="submit" name="import_file"/></p>
</form>
<?
xhtml_foot();
?>

View File

@@ -0,0 +1,113 @@
<?php
/**
* Display operator performance
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include_once(dirname(__FILE__).'/../config.inc.php');
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Performance functions
*/
include("../functions/functions.performance.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
/**
* Operator functions
*/
include("../functions/functions.operator.php");
xhtml_head(T_("Operator Performance"),true,false,array("../js/window.js"));
$rs = get_CPH();
print "<h2>" . T_("Overall") . "</h2>";
xhtml_table($rs,array("firstName","completions","time","CPH"),array(T_("Operator"),T_("Completions"),T_("Total time"),T_("Completions per hour")),"tclass");
xhtml_table(get_effectiveness(),array("firstName","effectiveness"),array(T_("Operator"),T_("Effectiveness (proportion of time on a call in a case)")),"tclass");
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id)
{
$rs = get_CPH_by_questionnaire($questionnaire_id);
print "<h2>" . T_("This project") . "</h2>";
xhtml_table($rs,array("firstName","completions","time","CPH"),array(T_("Operator"),T_("Completions"),T_("Total time"),T_("Completions per hour")),"tclass");
xhtml_table(get_effectiveness_by_questionnaire($questionnaire_id),array("firstName","effectiveness"),array(T_("Operator"),T_("Effectiveness (proportion of time on a call in a case)")),"tclass");
$operator_id = get_operator_id();
$shift_id = false;
if (isset($_GET['shift_id'])) $shift_id = bigintval($_GET['shift_id']);
$sql = "SELECT s.shift_id as value,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT . "'),' " . T_("till") . " ',DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as description,CASE WHEN s.shift_id = '$shift_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM shift as s
LEFT JOIN (operator as o) on (o.operator_id = '$operator_id')
WHERE s.questionnaire_id = '$questionnaire_id'
ORDER BY s.start ASC";
$rs = $db->GetAll($sql);
display_chooser($rs,"shift_id","shift_id",true,"questionnaire_id=$questionnaire_id");
if ($shift_id)
{
$rs = get_CPH_by_shift($questionnaire_id,$shift_id);
print "<h2>" . T_("This shift") . "</h2>";
xhtml_table($rs,array("firstName","completions","time","CPH"),array(T_("Operator"),T_("Completions"),T_("Total time"),T_("Completions per hour")),"tclass");
}
}
xhtml_foot();
?>

View File

@@ -0,0 +1,273 @@
<?
/**
* Assign operators to questionnaires in a checkbox matrix
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Return if an operator has already been assigned to this questionnaire
*
* @param int $operator_id Operator id
* @param int $questionnaire_id Questionnaire id
* @return int 1 if assigned otherwise 0
*
*/
function vq($operator_id,$questionnaire_id)
{
global $db;
$sql = "SELECT operator_id,questionnaire_id
FROM operator_questionnaire
WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'";
$vq = $db->Execute($sql);
return $vq->RecordCount();
}
/**
* Assign an operator to a questionnaire
*
* @param int $operator_id Operator id
* @param int $questionnaire_id Questionnaire id
*
*/
function vqi($operator_id,$questionnaire_id)
{
global $db;
$sql = "INSERT INTO
operator_questionnaire (operator_id,questionnaire_id)
VALUES('$operator_id','$questionnaire_id')";
$db->Execute($sql);
}
/**
* Unassign an operator from a questionnaire
*
* @param int $operator_id Operator id
* @param int $questionnaire_id Questionnaire id
*
*/
function vqd($operator_id,$questionnaire_id)
{
global $db;
$sql = "DELETE FROM
operator_questionnaire
WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'";
$db->Execute($sql);
}
if (isset($_POST['submit']))
{
$db->StartTrans();
$sql = "DELETE
FROM operator_questionnaire
WHERE 1";
$db->Execute($sql);
foreach ($_POST as $g => $v)
{
$a = explode("_",$g);
if ($a[0] == "cb")
vqi($a[2],$a[1]);
}
$db->CompleteTrans();
}
$sql = "SELECT questionnaire_id,description
FROM questionnaire
ORDER by questionnaire_id ASC";
$questionnaires = $db->GetAll($sql);
$sql = "SELECT operator_id,firstname as description
FROM operator
ORDER by operator_id ASC";
$operators = $db->GetAll($sql);
xhtml_head(T_("Assign operators to questionnaires"),false,array("../css/table.css"));
?>
<script type="text/javascript">
<?
print "questionnaire_id = new Array(";
$s = "";
foreach($questionnaires as $q)
{
$s .= "'{$q['questionnaire_id']}',";
}
$s = substr($s,0,strlen($s) - 1);
print "$s);\n";
print "operator_id = new Array(";
$s = "";
foreach($operators as $q)
{
$s .= "'{$q['operator_id']}',";
}
$s = substr($s,0,strlen($s) - 1);
print "$s);\n";
?>
var QidOn = 0;
var VidOn = 0;
function checkQid(q)
{
for (y in operator_id)
{
v = operator_id[y];
cb = document.getElementById('cb_' + q + "_" + v);
if (QidOn == 0)
cb.checked = 'checked';
else
cb.checked = '';
}
if (QidOn == 0)
QidOn = 1;
else
QidOn = 0;
}
function checkVid(v)
{
for (y in questionnaire_id)
{
q = questionnaire_id[y];
cb = document.getElementById('cb_' + q + "_" + v);
if (VidOn == 0)
cb.checked = 'checked';
else
cb.checked = '';
}
if (VidOn == 0)
VidOn = 1;
else
VidOn = 0;
}
</script>
</head>
<body>
<?
print "<form action=\"\" method=\"post\"><table>";
print "<tr><th></th>";
foreach($questionnaires as $q)
{
print "<th><a href=\"javascript:checkQid({$q['questionnaire_id']})\">{$q['description']}</a></th>";
}
print "</tr>";
$class = 0;
foreach($operators as $v)
{
print "<tr class='";
if ($class == 0) {$class = 1; print "even";} else {$class = 0; print "odd";}
print "'>";
print "<th><a href=\"javascript:checkVid({$v['operator_id']})\">{$v['description']}</a></th>";
foreach($questionnaires as $q)
{
$checked = "";
if (vq($v['operator_id'],$q['questionnaire_id'])) $checked="checked=\"checked\"";
print "<td><input type=\"checkbox\" name=\"cb_{$q['questionnaire_id']}_{$v['operator_id']}\" id=\"cb_{$q['questionnaire_id']}_{$v['operator_id']}\" $checked></input></td>";
}
print "</tr>";
}
print "</table><p><input type=\"submit\" name=\"submit\"/></p></form>";
xhtml_foot();
?>

137
admin/operators.php Normal file
View File

@@ -0,0 +1,137 @@
<?
/**
* Create an operator and link to a webserver username for authentication
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
* @todo Make timezone a drop down list
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
global $db;
$a = false;
if (isset($_POST['operator']))
{
$operator = $db->qstr($_POST['operator'],get_magic_quotes_gpc());
$firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc());
$lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc());
$time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc());
$extension = $db->qstr($_POST['extension'],get_magic_quotes_gpc());
$supervisor = 0;
$temporary = 0;
$refusal = 0;
if (isset($_POST['supervisor']) && $_POST['supervisor'] == "on") $supervisor = 1;
if (isset($_POST['refusal']) && $_POST['refusal'] == "on") $refusal = 1;
if (isset($_POST['temporary']) && $_POST['temporary'] == "on") $temporary = 1;
if (!empty($_POST['operator']))
{
$sql = "INSERT INTO operator
(`operator_id` ,`username` ,`firstName` ,`lastName`, `extension`, `Time_zone_name`)
VALUES (NULL , $operator, $firstname , $lastname, $extension, $time_zone_name);";
if ($db->Execute($sql))
{
$a = "Added: $operator";
$oid = $db->Insert_ID();
if ($temporary)
{
$db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id)
VALUES ('$oid','1')");
$db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id)
VALUES ('$oid','5')"); //and appointment
}
if ($supervisor)
$db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id)
VALUES ('$oid','2')");
if ($refusal)
$db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id)
VALUES ('$oid','3')");
}else
{
$a = "Could not add $operator. There may already be an operator of this name";
}
}
}
xhtml_head(T_("Add an operator"));
if ($a)
{
?>
<h3><? echo $a; ?></h3>
<?
}
?>
<h1><? echo T_("Add an operator"); ?></h1>
<p><? echo T_("Adding an operator here will give the user the ability to call cases"); ?> <a href="operatorquestionnaire.php"><? echo T_("Assign Operator to Questionnaire"); ?></a> <? echo T_("tool"); ?>.</p>
<p><? echo T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here."); ?></p>
<form enctype="multipart/form-data" action="" method="post">
<p><? echo T_("Enter the username of an operator to add:"); ?> <input name="operator" type="text"/></p>
<p><? echo T_("Enter the first name of an operator to add:"); ?> <input name="firstname" type="text"/></p>
<p><? echo T_("Enter the surname of an operator to add:"); ?> <input name="lastname" type="text"/></p>
<p><? echo T_("Enter the Time Zone of an operator to add:"); ?> <input name="Time_zone_name" type="text" value="<? echo DEFAULT_TIME_ZONE; ?>"/></p>
<p><? echo T_("Enter the telephone extension number:"); ?> <input name="extension" type="text"/></p>
<p><? echo T_("Is the operator a normal interviewer?"); ?> <input name="temporary" type="checkbox" checked="checked"/></p>
<p><? echo T_("Is the operator a supervisor?"); ?> <input name="supervisor" type="checkbox"/></p>
<p><? echo T_("Is the operator a refusal converter?"); ?> <input name="refusal" type="checkbox"/></p>
<p><input type="submit" value="<? echo T_("Add user"); ?>" /></p>
</form>
<?
xhtml_foot();
?>

272
admin/operatorskill.php Normal file
View File

@@ -0,0 +1,272 @@
<?
/**
* Assign operators to skills in a checkbox matrix
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Determine if an operator has been assigned to a skill (outcome_type)
*
* @param int $operator_id Operator id
* @param int $outcome_type_id Outcome type id (skill)
* @return int 1 if assigned to that skill otherwise 0
*
*/
function vq($operator_id,$outcome_type_id)
{
global $db;
$sql = "SELECT operator_id,outcome_type_id
FROM operator_skill
WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'";
$vq = $db->Execute($sql);
return $vq->RecordCount();
}
/**
* Assign an operator to a skill (outcome_type)
*
* @param int $operator_id Operator id
* @param int $outcome_type_id Outcome type id (skill)
*
*/
function vqi($operator_id,$outcome_type_id)
{
global $db;
$sql = "INSERT INTO
operator_skill (operator_id,outcome_type_id)
VALUES('$operator_id','$outcome_type_id')";
$db->Execute($sql);
}
/**
* Delete a skill (outcome_type) from an operator
*
* @param int $operator_id Operator id
* @param int $outcome_type_id Outcome type id (skill)
*
*/
function vqd($operator_id,$outcome_type_id)
{
global $db;
$sql = "DELETE FROM
operator_skill
WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'";
$db->Execute($sql);
}
if (isset($_POST['submit']))
{
$db->StartTrans();
$sql = "DELETE
FROM operator_skill
WHERE 1";
$db->Execute($sql);
foreach ($_POST as $g => $v)
{
$a = explode("_",$g);
if ($a[0] == "cb")
vqi($a[2],$a[1]);
}
$db->CompleteTrans();
}
$sql = "SELECT outcome_type_id,description
FROM outcome_type
ORDER by outcome_type_id ASC";
$outcome_types = $db->GetAll($sql);
$sql = "SELECT operator_id,firstname as description
FROM operator
ORDER by operator_id ASC";
$operators = $db->GetAll($sql);
xhtml_head(T_("Assign operators to Skills"),false,array("../css/table.css"));
?>
<script type="text/javascript">
<?
print "outcome_type_id = new Array(";
$s = "";
foreach($outcome_types as $q)
{
$s .= "'{$q['outcome_type_id']}',";
}
$s = substr($s,0,strlen($s) - 1);
print "$s);\n";
print "operator_id = new Array(";
$s = "";
foreach($operators as $q)
{
$s .= "'{$q['operator_id']}',";
}
$s = substr($s,0,strlen($s) - 1);
print "$s);\n";
?>
var QidOn = 0;
var VidOn = 0;
function checkQid(q)
{
for (y in operator_id)
{
v = operator_id[y];
cb = document.getElementById('cb_' + q + "_" + v);
if (QidOn == 0)
cb.checked = 'checked';
else
cb.checked = '';
}
if (QidOn == 0)
QidOn = 1;
else
QidOn = 0;
}
function checkVid(v)
{
for (y in outcome_type_id)
{
q = outcome_type_id[y];
cb = document.getElementById('cb_' + q + "_" + v);
if (VidOn == 0)
cb.checked = 'checked';
else
cb.checked = '';
}
if (VidOn == 0)
VidOn = 1;
else
VidOn = 0;
}
</script>
</head>
<body>
<?
print "<form action=\"\" method=\"post\"><table>";
print "<tr><th></th>";
foreach($outcome_types as $q)
{
print "<th><a href=\"javascript:checkQid({$q['outcome_type_id']})\">{$q['description']}</a></th>";
}
print "</tr>";
$ct = 1;
foreach($operators as $v)
{
print "<tr class='";
if ($ct == 1) {$ct = 0; print "even";} else {$ct = 1; print "odd";}
print "'>";
print "<th><a href=\"javascript:checkVid({$v['operator_id']})\">{$v['description']}</a></th>";
foreach($outcome_types as $q)
{
$checked = "";
if (vq($v['operator_id'],$q['outcome_type_id'])) $checked="checked=\"checked\"";
print "<td><input type=\"checkbox\" name=\"cb_{$q['outcome_type_id']}_{$v['operator_id']}\" id=\"cb_{$q['outcome_type_id']}_{$v['operator_id']}\" $checked></input></td>";
}
print "</tr>";
}
print "</table><p><input type=\"submit\" name=\"submit\"/></p></form>";
xhtml_foot();
?>

172
admin/outcomes.php Normal file
View File

@@ -0,0 +1,172 @@
<?php
/**
* Display outcomes by questionnaire
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include_once(dirname(__FILE__).'/../config.inc.php');
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* AAPOR calculation functions
*/
include ("../functions/functions.aapor.php");
/**
* Display functions
*/
include ("../functions/functions.display.php");
/**
* Performance functions
*/
include ("../functions/functions.performance.php");
/**
* Operator functions
*/
include ("../functions/functions.operator.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
$operator_id = get_operator_id();
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
xhtml_head(T_("Questionnaire Outcomes"),true,array("../css/table.css"),array("../js/window.js"));
print "<h3>" . T_("Select a questionnaire from the list below") . "</h3>";
display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id != false)
{
print "<h1>" . T_("Outcomes") . "</h1>";
print "<p>" . T_("Sample status") . "</p>";
$sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . T_("Drawn from sample") . "' ELSE '" . T_("Remain in sample") . "' END as drawn,
count(*) as count
FROM sample as s
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id)
LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)
GROUP BY (c.sample_id is not null)";
xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")));
$atime = get_average_time_questionnaire(10,$questionnaire_id);
$mins = intval($atime / 60);
$secs = $atime % 60;
print "<p>" . T_("Average time on a completed questionnaire") . ": $mins " . T_("Min") . " $secs " . T_("Secs") . "</p>";
$sql = "SELECT o.calc, count( c.case_id )
FROM `case` AS c, `outcome` AS o
WHERE c.questionnaire_id = '$questionnaire_id'
AND c.current_outcome_id = o.outcome_id
GROUP BY o.calc";
$a = $db->GetAssoc($sql);
$a = aapor_clean($a);
print "<table><tr><th>" . T_("Outcome") . "</th><th>" . T_("Rate") . "</th></tr>";
print "<tr><td>" . T_("Response Rate 1") . "</td><td>" . round(aapor_rr1($a),2) . "</td></tr>";
print "<tr><td>" . T_("Refusal Rate 1") . "</td><td>" . round(aapor_ref1($a),2) . "</td></tr>";
print "<tr><td>" . T_("Cooperation Rate 1") . "</td><td>" . round(aapor_coop1($a),2) . "</td></tr>";
print "<tr><td>" . T_("Contact Rate 1") . "</td><td>" . round(aapor_con1($a),2) . "</td></tr>";
print "</table>";
$sql = "SELECT o.description as des, o.outcome_id, count( c.case_id ) as count
FROM `case` AS c, `outcome` AS o
WHERE c.questionnaire_id = '$questionnaire_id'
AND c.current_outcome_id = o.outcome_id
GROUP BY o.outcome_id";
$rs = $db->GetAll($sql);
if (!empty($rs))
xhtml_table($rs,array("des","count"),array(T_("Outcome"),T_("Count")),"tclass",array("des" => "Complete"));
else
print "<p>" . T_("No outcomes recorded for this questionnaire") . "</p>";
//display a list of shifts with completions and a link to either add a report or view reports
print "<h2>" . T_("Shifts") . "</h2>";
$sql = "SELECT s.shift_id, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."')) as description,
CASE WHEN sr.shift_id IS NULL THEN CONCAT('<a href=\'shiftreport.php?questionnaire_id=$questionnaire_id&amp;shift_id=', s.shift_id, '&amp;createnewreport=yes\'>" . T_("No shift reports: Add report") . "</a>') ELSE CONCAT('<a href=\'shiftreport.php?questionnaire_id=$questionnaire_id&amp;shift_id=', s.shift_id, '\'>" . T_("View shift reports") . "</a>') END AS link, c.completions as completions, CONCAT('<a href=\'operatorperformance.php?questionnaire_id=$questionnaire_id&amp;shift_id=', s.shift_id, '\'>" . T_("View operator performance") . "</a>') as operform
FROM `shift` as s
JOIN operator as o on (o.operator_id = '$operator_id')
LEFT JOIN shift_report as sr on (sr.shift_id = s.shift_id)
LEFT JOIN ( SELECT count(*) as completions,sh.shift_id
FROM `call` as a, `case` as b, shift as sh
WHERE a.outcome_id = '10'
AND a.case_id = b.case_id
AND b.questionnaire_id = '$questionnaire_id'
AND sh.start <= a.start
AND sh.end >= a.start
GROUP BY sh.shift_id) as c on (s.shift_id = c.shift_id)
WHERE s.questionnaire_id = '$questionnaire_id'
GROUP BY shift_id
ORDER BY s.start ASC";
$r = $db->GetAll($sql);
if (empty($r))
print "<p>" . T_("No shifts defined for this questionnaire") . "</p>";
else
xhtml_table($r,array("description","completions","link","operform"),array(T_("Shift"),T_("Completions"),T_("Shift report"),T_("Operator performance")),"tclass");
}
xhtml_foot();
?>

View File

@@ -0,0 +1,172 @@
<?
/**
* Select and set questions to pre fill in the questionnaire
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']))
{
//need to add prefill to questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$value = $db->quote($_GET['value']);
$sgqa = $db->quote($_GET['sgqa']);
$sql = "INSERT INTO questionnaire_prefill(questionnaire_id,lime_sgqa,value)
VALUES('$questionnaire_id',$sgqa,$value)";
$db->Execute($sql);
}
if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id']))
{
//need to remove prefill from questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$questionnaire_prefill_id = bigintval($_GET['questionnaire_prefill_id']);
$sql = "DELETE FROM questionnaire_prefill
WHERE questionnaire_prefill_id = '$questionnaire_prefill_id'";
$db->Execute($sql);
}
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,false,array("../js/window.js"));
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM questionnaire";
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");
if ($questionnaire_id != false)
{
print "<h1>" . T_("Current pre fills (click to delete)") . "</h1>";
$sql = "SELECT questionnaire_prefill_id,lime_sgqa,value
FROM questionnaire_prefill
WHERE questionnaire_id = '$questionnaire_id'";
$r = $db->GetAll($sql);
if (empty($r))
{
print "<p>" . T_("Currently no pre fills") . "</p>";
}
else
{
foreach($r as $v)
{
print "<div><a href='?questionnaire_id=$questionnaire_id&amp;questionnaire_prefill_id={$v['questionnaire_prefill_id']}'>{$v['lime_sgqa']}: {$v['value']}</a></div>";
}
}
print "<h1>" . T_("Select a question to pre fill") . "</h1>";
$sql = "SELECT lime_sid
FROM questionnaire
WHERE questionnaire_id = '$questionnaire_id'";
$r = $db->GetRow($sql);
$lime_sid = $r['lime_sid'];
$sgqa = false;
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
$sql = "SELECT CONCAT( q.sid, 'X', q.gid, 'X', q.qid, IFNULL( a.code, '' ) ) AS value, CONCAT(q.question, ': ', IFNULL(a.answer,'')) as description, CASE WHEN CONCAT( q.sid, 'X', q.gid, 'X', q.qid, IFNULL( a.code, '' ) ) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM `" . LIME_PREFIX . "questions` AS q
LEFT JOIN `" . LIME_PREFIX . "answers` AS a ON ( a.qid = q.qid )
WHERE q.sid = '$lime_sid'";
display_chooser($ldb->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id");
if ($sgqa != false)
{
print "<h1>" . T_("Enter a value to pre fill this question with:") . "</h1>";
print "<p>";
print T_("Possible uses:");
print "</p><ul>";
print "<li>" . T_("{Respondent:firstName} First name of the respondent") . "</li>";
print "<li>" . T_("{Respondent:lastName} Last name of the respondent") . "</li>";
print "<li>" . T_("{Sample:var} A record from the sample where the column name is 'var'") . "</li>";
print "</ul>";
?>
<form action="" method="get">
<p>
<label for="value"><? echo T_("The value to pre fill"); ?> </label><input type="text" name="value" id="value"/> <br/>
<input type="hidden" name="questionnaire_id" value="<? print($questionnaire_id); ?>"/>
<input type="hidden" name="sgqa" value="<? print($sgqa); ?>"/>
<input type="submit" name="add_prefill" value="Add pre fill"/></p>
</form>
<?
}
}
xhtml_foot();
?>

165
admin/samplesearch.php Normal file
View File

@@ -0,0 +1,165 @@
<?
/**
* Select and search within a sample to see what case(s) is/are assigned to a sample record
* and if so to look at them, otherwise give the option to remove a sample record
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
if (isset($_GET['sample_id']))
{
//need to remove this sample record from the sample
$sample_id = bigintval($_GET['sample_id']);
$db->StartTrans();
$sql = "DELETE FROM sample_var
WHERE sample_id = '$sample_id'";
$db->Execute($sql);
$sql = "DELETE FROM sample
WHERE sample_id = '$sample_id'";
$db->Execute($sql);
$db->CompleteTrans();
}
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
xhtml_head(T_("Search sample"),true,array("../css/table.css"),array("../js/window.js"));
print "<h1>" . T_("Select a sample from the list below") . "</h1>";
$sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM sample_import";
$r = $db->GetAll($sql);
if(!empty($r))
display_chooser($r,"sample_import_id","sample_import_id");
if ($sample_import_id != false)
{
if (isset($_GET['search']))
{
$search = $db->qstr($_GET['search']);
$sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN CONCAT('<a href=\'?sample_import_id=$sample_import_id&amp;sample_id=', sv.sample_id , '\'>" . T_("No cases yet assigned: Delete this sample record") . "</a>') ELSE CONCAT('<a href=\'supervisor.php?case_id=', c.case_id , '\'>" . T_("Assigned to questionnaire: ") . "', q.description, '</a>') END as link
FROM sample_var AS sv
JOIN (sample as s) ON (s.import_id = '$sample_import_id' and sv.sample_id = s.sample_id)
LEFT JOIN (`case` AS c, questionnaire AS q) ON ( c.sample_id = sv.sample_id AND q.questionnaire_id = c.questionnaire_id )
WHERE sv.val LIKE $search";
$r = $db->GetAll($sql);
if (empty($r))
print "<p>" . T_("No records in this sample match this search criteria") . "</p>";
else
{
//add sample information to results
$sql = "SELECT var
FROM sample_var
WHERE sample_id = {$r[0]['sample_id']}";
$rs = $db->GetAll($sql);
$fnames = array("sample_id");
$fdesc = array(T_("Sample id"));
foreach($rs as $rsw)
{
$fnames[] = $rsw['var'];
$fdesc[] = $rsw['var'];
}
$fnames[] = "link";
$fdesc[] = T_("Link");
foreach($r as &$rw)
{
$sql = "SELECT var,val
FROM sample_var
WHERE sample_id = {$rw['sample_id']}";
$rs = $db->GetAll($sql);
foreach($rs as $rsw)
$rw[$rsw['var']] = $rsw['val'];
}
xhtml_table($r,$fnames,$fdesc);
}
}
print "<h1>" . T_("Search within this sample") . "</h1>";
print "<p>" . T_("Use the % character as a wildcard") ."</p>";
?>
<form action="" method="get">
<p>
<label for="search"><? echo T_("Search for:"); ?></label><input type="text" name="search" id="search"/><br/>
<input type="hidden" name="sample_import_id" value="<? print($sample_import_id); ?>"/>
<input type="submit" name="searchsub" value="<? echo T_("Start search"); ?>"/>
</p>
</form>
<?
}
xhtml_foot();
?>

177
admin/shiftreport.php Normal file
View File

@@ -0,0 +1,177 @@
<?php
/**
* List and edit reports on shifts
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include_once(dirname(__FILE__).'/../config.inc.php');
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Operator functions
*/
include("../functions/functions.operator.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
xhtml_head(T_("Shift reports"),true,array("../css/table.css"),array("../js/window.js"));
$operator_id = get_operator_id();
print "<h3>" . T_("Please select a questionnaire") . "</h3>";
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
display_questionnaire_chooser($questionnaire_id);
if ($questionnaire_id)
{
print "<h3>" . T_("Please select a shift") . "</h3>";
$shift_id = false;
if (isset($_GET['shift_id'])) $shift_id = bigintval($_GET['shift_id']);
//get shifts for this questionnaire in operator time
$sql = "SELECT s.shift_id as value, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT ."')) as description,
CASE WHEN s.shift_id = '$shift_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM `shift` as s, operator as o
WHERE s.questionnaire_id = '$questionnaire_id'
AND o.operator_id = '$operator_id'
ORDER BY s.start ASC";
$r = $db->GetAll($sql);
if (!empty($r))
display_chooser($r,"shift","shift_id",true,"questionnaire_id=$questionnaire_id");
if ($shift_id)
{
print "<h3>" . T_("Reports for this shift") . "</h3>";
//list current reports with a link to edit
$sql = "SELECT s.report,o.firstName,DATE_FORMAT(CONVERT_TZ(s.datetime,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."') as d,
CONCAT('<a href=\'?questionnaire_id=$questionnaire_id&amp;shift_id=$shift_id&amp;shift_report_id=', s.shift_report_id, '\'>". T_("Edit") . "</a>') as link
FROM shift_report as s, operator as o
WHERE s.operator_id = o.operator_id
AND s.shift_id = '$shift_id'";
$r = $db->GetAll($sql);
if (!empty($r))
xhtml_table($r,array("firstName", "d", "report","link"),array(T_("Operator"),T_("Date"),T_("Report"),T_("Edit")),"tclass");
//link to create a new report
print "<p><a href='?questionnaire_id=$questionnaire_id&amp;shift_id=$shift_id&amp;createnewreport=yes'>" . T_("Create new report for this shift") . "</a></p>";
if (isset($_GET['createnewreport']))
{
//create a new report
print "<h3>" . T_("Enter report for this shift") . "</h3>";
print "<form action='?' method='get'><p><textarea name='report' id='report' rows='15' cols='80'></textarea></p>";
print "<p><input type='hidden' name='questionnaire_id' id='questionnaire_id' value='$questionnaire_id'/>";
print "<input type='hidden' name='shift_id' id='shift_id' value='$shift_id'/>";
print "<input type='submit' name='submit' id='submit' value='" . T_("Add report") . "'/>";
print "</p></form>";
}
else if (isset($_GET['report']))
{
//add report to database
$report = $db->qstr($_GET['report']);
$sql = "INSERT INTO shift_report (shift_id,operator_id,datetime,report,shift_report_id)
VALUES ('$shift_id','$operator_id',CONVERT_TZ(NOW(),'System','UTC'),$report,NULL)";
$db->Execute($sql);
}
else if (isset($_GET['shift_report_id']))
{
$shift_report_id = bigintval($_GET['shift_report_id']);
if (isset($_GET['ereport']))
{
//edit report
$report = $db->qstr($_GET['ereport']);
$sql = "UPDATE shift_report
SET operator_id = '$operator_id', datetime = CONVERT_TZ(NOW(),'System','UTC'), report = $report
WHERE shift_report_id = '$shift_report_id'";
$db->Execute($sql);
}
$sql = "SELECT report
FROM shift_report
WHERE shift_report_id = '$shift_report_id'";
$r = $db->GetRow($sql);
if (empty($r))
{
print "<h3>" . T_("This report does not exist in the database") . "</h3>";
}
else
{
//edit report
print "<h3>" . T_("Edit report for this shift") . "</h3>";
print "<form action='?' method='get'><p><textarea name='ereport' id='ereport' rows='15' cols='80'>{$r['report']}</textarea></p>";
print "<p><input type='hidden' name='questionnaire_id' id='questionnaire_id' value='$questionnaire_id'/>";
print "<input type='hidden' name='shift_id' id='shift_id' value='$shift_id'/>";
print "<input type='hidden' name='shift_report_id' id='shift_report_id' value='$shift_report_id'/>";
print "<input type='submit' name='submit' id='submit' value='" . T_("Modify report") . "'/>";
print "</p></form>";
}
}
}
}
xhtml_foot();
?>

234
admin/supervisor.php Normal file
View File

@@ -0,0 +1,234 @@
<?
/**
* View cases referred to the supervisor and add notes/assign outcomes
*
*
* 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@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @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");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Operator functions
*/
include("../functions/functions.operator.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
$operator_id = get_operator_id();
$case_id = false;
if (isset($_GET['case_id'])) $case_id = bigintval($_GET['case_id']);
xhtml_head(T_("Supervisor functions"),true,array("../css/table.css"),array("../js/window.js"));
print "<h1>" . T_("Enter a case id or select a case from the list below:") . "</h1>";
$sql = "SELECT c.case_id as value, c.case_id as description, CASE WHEN c.case_id = '$case_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM `case` as c, `outcome` as o
WHERE c.current_outcome_id = o.outcome_id
AND o.outcome_type_id = 2";
$rs = $db->GetAll($sql);
if (!empty($rs))
{
print "<div><label for=\"case\">". T_("Select case from list of cases referred to the supervisor:") . " </label>";
display_chooser($rs,"case","case_id");
print "</div>";
}
?>
<form action="" method="get">
<p>
<label for="case_id"><? echo T_("Case id:"); ?> </label><input type="text" name="case_id" id="case_id" value="<? echo $case_id; ?>"/>
<input type="submit" name="case_form" value="<? echo T_("Select case"); ?>"/></p>
</form>
<?
if (isset($_GET['call_id']))
{
$call_id = bigintval($_GET['call_id']);
if (isset($_GET['set_outcome_id']))
{
$outcome_id = bigintval($_GET['set_outcome_id']);
$sql = "UPDATE `call`
SET outcome_id = '$outcome_id'
WHERE call_id = '$call_id'";
$db->Execute($sql);
}
else
{
print "<h3>" . T_("Set an outcome for this call") . "</h3>";
?>
<form method="get" action="?">
<?
$sql = "SELECT o.outcome_id as value,description, CASE WHEN o.outcome_id = c.outcome_id THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM outcome as o, `call` as c
WHERE c.call_id = '$call_id'";
display_chooser($db->GetAll($sql), "set_outcome_id", "set_outcome_id",true,false,false);
?>
<p><input type="hidden" name="call_id" value="<? echo $call_id;?>"/><input type="hidden" name="case_id" value="<? echo $case_id;?>"/><input class="submitclass" type="submit" name="submit" value="<? echo T_("Set outcome"); ?>"/></p>
</form>
<?
}
}
if ($case_id != false)
{
if (isset($_GET['note']))
{
$note = $db->qstr($_GET['note']);
$sql = "INSERT INTO `case_note` (case_note_id,case_id,operator_id,note,datetime)
VALUES (NULL,'$case_id','$operator_id',$note,CONVERT_TZ(NOW(),'System','UTC'))";
$db->Execute($sql);
}
if (isset($_GET['outcome_id']))
{
$outcome_id = bigintval($_GET['outcome_id']);
$sql = "UPDATE `case`
SET current_outcome_id = $outcome_id
WHERE case_id = '$case_id'";
$db->Execute($sql);
}
$sql = "SELECT o.description,o.outcome_id, q.description as qd, si.description as sd
FROM `case` as c, `outcome` as o, questionnaire as q, sample as s, sample_import as si
WHERE c.case_id = '$case_id'
AND q.questionnaire_id = c.questionnaire_id
AND s.sample_id = c.sample_id
AND si.sample_import_id = s.import_id
AND c.current_outcome_id = o.outcome_id";
$rs = $db->GetRow($sql);
if (!empty($rs))
{
print "<h1>" . T_("Project") . ": {$rs['qd']}</h1>";
print "<h1>" . T_("Sample") . ": {$rs['sd']}</h1>";
print "<h2>". T_("Current outcome:") ." {$rs['description']}</h2>";
$current_outcome_id = $rs['outcome_id'];
//view calls and outcomes
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'".DATE_TIME_FORMAT."') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, op.firstName, op.lastName, o.description as des, CONCAT('<a href=\'?case_id=$case_id&amp;call_id=', c.call_id, '\'>". T_("Edit") . "</a>') as link, cp.phone as phone
FROM `call` as c
JOIN (operator as op, outcome as o, respondent as r, contact_phone as cp) on (c.operator_id = op.operator_id and c.outcome_id = o.outcome_id and r.respondent_id = c.respondent_id and cp.contact_phone_id = c.contact_phone_id)
WHERE c.case_id = '$case_id'
ORDER BY c.start DESC";
$rs = $db->GetAll($sql);
print "<h3>" . T_("Call list")."</h3>";
if (empty($rs))
print "<p>" . T_("No calls made") . "</p>";
else
xhtml_table($rs,array("start","des","phone","link","firstName"),array(T_("Date/Time"),T_("Outcome"),T_("Phone number"),T_("Change outcome"),T_("Operator")));
//view notes
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.datetime,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as time, op.firstName, op.lastName, c.note as note
FROM `case_note` as c
JOIN (operator as op) on (c.operator_id = op.operator_id)
WHERE c.case_id = '$case_id'
ORDER BY c.datetime DESC";
$rs = $db->GetAll($sql);
print "<h3>" . T_("Case notes")."</h3>";
if (empty($rs))
print "<p>" . T_("No notes") . "</p>";
else
xhtml_table($rs,array("time","firstName","note"),array(T_("Date/Time"),T_("Operator"),T_("Note")));
//add a note
?>
<form method="get" action="?">
<p>
<input type="hidden" name="case_id" value="<? echo $case_id;?>"/><input type="text" class="textclass" name="note" id="note"/><input class="submitclass" type="submit" name="submit" value="<? echo T_("Add note"); ?>"/>
</p>
</form>
<?
//set an outcome
print "<h3>" . T_("Set a case outcome") . "</h3>";
?>
<form method="get" action="?">
<?
$sql = "SELECT outcome_id as value,description, CASE WHEN outcome_id = '$current_outcome_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM outcome";
display_chooser($db->GetAll($sql), "outcome_id", "outcome_id",true,false,false);
?>
<p><input type="hidden" name="case_id" value="<? echo $case_id;?>"/><input class="submitclass" type="submit" name="submit" value="<? echo T_("Set outcome"); ?>"/></p>
</form>
<?
}
else
{
print "<h2>" . T_("Case does not exist") . "</h2>";
}
}
xhtml_foot();
?>