From 971eb8d584d30442709a8005cd4291bbf9752ee2 Mon Sep 17 00:00:00 2001 From: Adam Zammit Date: Wed, 27 Feb 2013 09:28:00 +1100 Subject: [PATCH] Save call attempt id in to sent when sent and set default call id --- call.php | 14 +++++++++----- email.php | 17 +++-------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/call.php b/call.php index 3f5fb3c9..0ce64cb5 100644 --- a/call.php +++ b/call.php @@ -134,13 +134,17 @@ function display_outcomes($contacted,$ca,$case_id) print "
"; if (!empty($rs)) { - //Get current outcome to set as default - $sql = "SELECT outcome - FROM `call` - WHERE call_attempt_id = $ca - AND `end` IS NULL"; + $lime_sid = get_limesurvey_id(get_operator_id()); + + //Check to see if we have sent an email on this call and set the default outcome + $sql = "SELECT 41 + FROM `case` as c, " . LIME_PREFIX . "tokens_$lime_sid as t + WHERE t.sent = '$ca' + AND c.case_id = $case_id + AND t.token = c.token"; $do = $db->GetOne($sql); + if (isset($_GET['defaultoutcome'])) $do = bigintval($_GET['defaultoutcome']); foreach($rs as $r) { diff --git a/email.php b/email.php index 78f3fe1b..dcda6c21 100644 --- a/email.php +++ b/email.php @@ -73,6 +73,7 @@ if (isset($_POST['firstname'])) { $case_id = get_case_id($operator_id); $lime_sid = get_lime_sid($case_id); + $ca = get_call_attempt($operator_id); $token = get_token($case_id); $email = $db->qstr($_POST['email']); $firstname = $db->qstr($_POST['firstname']); @@ -168,11 +169,9 @@ if (isset($_POST['firstname'])) if ($mail->Send()) { - // Put date into sent - $today = date("Y-m-d H:i:s"); - + // Put call attempt id in to sent $sql = "UPDATE ". LIME_PREFIX . "tokens_{$lime_sid} - SET sent='$today' + SET sent='$ca' WHERE token='$token'"; $db->Execute($sql); @@ -204,16 +203,6 @@ if (isset($_POST['firstname'])) } else if (isset($_POST['submit'])) { - /* - $call_id = get_call($operator_id); - - $sql = "UPDATE `call` as c - SET c.outcome_id = 41 - WHERE c.call_id = $call_id"; - - $db->Execute($sql); - */ - xhtml_head(T_("Email"),true,array("css/call.css"),array($js),"onload='parent.closePopup();'"); } xhtml_foot();