* @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");
/**
* Authentication
*/
include ("auth-interviewer.php");
/**
* XHTML functions
*/
include ("functions/functions.xhtml.php");
/**
* Operator functions
*/
include("functions/functions.operator.php");
$operator_id = get_operator_id();
$state = is_on_call($operator_id);
$js = array("js/popup.js");
if (browser_ie())
$js[] = "js/window_ie6.js";
else
$js[] = "js/window.js";
if (AUTO_LOGOUT_MINUTES !== false)
{
$js[] = "include/jquery/jquery-1.4.2.min.js";
$js[] = "js/childnap.js";
}
xhtml_head(T_("Status"),false,array("include/bootstrap/css/bootstrap.min.css","css/status_interface2.css"),$js);
$ca = get_call_attempt($operator_id,false);
if ($ca)
{
$respondent_id = get_respondent_id($ca);
$case_id = get_case_id($operator_id);
$fname = get_respondent_variable("firstName",$respondent_id);
$lname = get_respondent_variable("lastName",$respondent_id);
print "
" . T_("Name") . ": $fname $lname
";
$appointment = is_on_appointment($ca);
$call_id = get_call($operator_id);
$sql = "SELECT o.tryanother, o.require_note
FROM `call` as c, `outcome` as o
WHERE c.call_attempt_id = '$ca'
AND c.outcome_id = o.outcome_id
ORDER BY call_id DESC
LIMIT 1";
$rst = $db->GetRow($sql);
if ((empty($rst) || $rst['tryanother'] == 1)) //dial another number only when available and not ending
{
if (isset($_POST['contactphone']))
{
$pcontact_phone_id = intval($_POST['contactphone']);
//If an outcome already assigned, end the current call and start the enxt one to pcontact_phone_id
//Otherwise bring up the assign outcome window
if (!$call_id) //outcome assigned
{
$call_id = get_call($operator_id,$respondent_id,$pcontact_phone_id,true);
echo "";
}
else
{
//bring up assign outcome window
print "";
}
}
if (!$call_id)
{
$sql = "SELECT c. *
FROM contact_phone AS c
LEFT JOIN (
SELECT contact_phone.contact_phone_id
FROM contact_phone
LEFT JOIN `call` ON ( call.contact_phone_id = contact_phone.contact_phone_id )
LEFT JOIN outcome ON ( call.outcome_id = outcome.outcome_id )
WHERE contact_phone.case_id = '$case_id'
AND outcome.tryagain =0
) AS l ON l.contact_phone_id = c.contact_phone_id
LEFT JOIN
(
SELECT contact_phone_id
FROM `call`
WHERE call_attempt_id = '$ca'
AND outcome_id != 18
) as ca on ca.contact_phone_id = c.contact_phone_id
WHERE c.case_id = '$case_id'
AND l.contact_phone_id IS NULL
AND ca.contact_phone_id IS NULL
order by c.priority ASC";
$numsa = $db->GetRow($sql);
if (!empty($numsa))
{
if ($appointment)
{
//create a call on the appointment number
$sql = "SELECT cp.*
FROM contact_phone as cp, appointment as a
WHERE cp.case_id = '$case_id'
AND a.appointment_id = '$appointment'
AND a.contact_phone_id = cp.contact_phone_id";
$rs = $db->GetRow($sql);
$contact_phone_id = $rs['contact_phone_id'];
}
else
{
$contact_phone_id = $numsa['contact_phone_id'];
}
$call_id = get_call($operator_id,$respondent_id,$contact_phone_id,true);
}
}
if ($appointment)
{
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(a.start,'System', o.Time_zone_name),'%Y-%b-%d %H:%i') as time
FROM appointment as a, operator as o
WHERE o.operator_id = '$operator_id'
AND a.appointment_id = '$appointment'";
$rs = $db->GetRow($sql);
$apdate = $rs['time'];
print "" . T_("Appointment") . ": " . $apdate . "
";
//if (missed_appointment($ca)) print "" . T_("MISSED") . "
";
}
if ($call_id)
{
$sql = "SELECT c.*, CASE WHEN c.contact_phone_id = ccc.contact_phone_id THEN 'checked=\"checked\"' ELSE '' END as checked
FROM contact_phone as c
LEFT JOIN `call` as ccc ON (ccc.call_id = '$call_id')
LEFT JOIN (
SELECT contact_phone.contact_phone_id
FROM contact_phone
LEFT JOIN `call` ON ( call.contact_phone_id = contact_phone.contact_phone_id )
LEFT JOIN outcome ON ( call.outcome_id = outcome.outcome_id )
WHERE contact_phone.case_id = '$case_id'
AND outcome.tryagain =0
) AS l ON l.contact_phone_id = c.contact_phone_id
LEFT JOIN
(
SELECT contact_phone_id
FROM `call`
WHERE call_attempt_id = '$ca'
AND outcome_id != 18
AND outcome_id != 0
) as ca on ca.contact_phone_id = c.contact_phone_id
WHERE c.case_id = '$case_id'
AND l.contact_phone_id IS NULL
AND ca.contact_phone_id IS NULL";
$rs = $db->GetAll($sql);
//Display all available numbers for this case as a list of radio buttons
//By default, the selected radio button should have a "call" started for it
//When then next one clicked, it should bring up call screen if no outcome otherwise start new call
//print "";print "
";
foreach($rs as $r)
{
print "";
}
}
else
print "" . T_("No more numbers to call") . "
";
}
else
print "" . T_("No more numbers to call") . "
";
}
else
print "" . T_("No case") . "
";
xhtml_foot();
?>