diff --git a/CHANGELOG b/CHANGELOG index fbcd83d5..d23be6ba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +queXS 1.9.0 - Changes since 1.8.0 + +Database updates: + +ALTER TABLE `operator` ADD `chat_enable` TINYINT( 1 ) NULL DEFAULT '0', +ADD `chat_user` VARCHAR( 255 ) NULL , +ADD `chat_password` VARCHAR( 255 ) NULL ; + queXS 1.8.0 - Changes since 1.7.6 New Feature: Allow for restricting the view of sample variables to operators diff --git a/functions/functions.operator.php b/functions/functions.operator.php index 8b54ddcf..f0776329 100644 --- a/functions/functions.operator.php +++ b/functions/functions.operator.php @@ -91,6 +91,31 @@ function is_using_availability($case_id) return false; } +/** + * Return if chat is enabled for this operator + * + * @param int $operator_id the operator id + * + * @return bool True if enabled, false if not + * @author Adam Zammit + * @since 2013-07-16 + */ +function operator_chat_enabled($operator_id) +{ + global $db; + + $sql = "SELECT chat_enable + FROM `operator` + WHERE operator_id = '$operator_id'"; + + $c = $db->GetOne($sql); + + if ($c == 1) + return true; + + return false; +} + /** * Return if VOIP is enabled on an operator by operator basis * Will always return false if VOIP is globally disabled diff --git a/index.php b/index.php index 07417afd..ad90e38f 100644 --- a/index.php +++ b/index.php @@ -158,6 +158,7 @@ $sc = $db->GetOne($sql); $ca = get_call_attempt($operator_id,true); $appointment = false; $availability = is_using_availability($case_id); +$chat = operator_chat_enabled($operator_id); if ($ca) { if (is_on_appointment($ca)) @@ -271,6 +272,15 @@ xhtml_object($data,"main-content"); + +
"> +

+
+
+ + +
' + sBody + ''; - $('#chattable > tbody > tr').eq(0).after(html); + //display message as new row in message table if it is from the supervisor + if (sBareJid == SUPERVISOR_XMPP) + { + var html = '' + SUPERVISOR_NAME + '' + sBody + ''; + $('#chattable > tbody > tr').eq(0).after(html); + } return true; } @@ -46,20 +53,61 @@ function OnPresenceStanza(stanza) var sShow = $(stanza).find('show').text(); //alert(sFrom + ':' + sType + ':' + sShow + ':' + sBareJid); - // update status on screen - if (sType == null || sType == '') { - sType = 'available'; - } + // update status on screen if it is the supervisors status - switch (sType) { - case 'available': - { - } break; - - case 'unavailable': - { - } break; + if (sBareJid == SUPERVISOR_XMPP) + { + if (sType == null || sType == '') { + sType = 'available'; + } + + switch (sType) { + case 'available': + { + $('#statusunavailable').hide(); + $('#statusavailable').show(); + + } break; + + case 'unavailable': + { + $('#statusavailable').hide(); + $('#statusunavailable').show(); + } break; + } } return true; } + + +function SendChat(chat) +{ + + if (chat != '') + { + if (nConnStatus == Strophe.Status.CONNECTED) + { + var stanza = $msg({ to: SUPERVISOR_XMPP, type: 'chat' }).c('body').t(chat); + conn.send(stanza.tree()); + var html = '' + MY_NAME + '' + chat + ''; + $('#chattable > tbody > tr').eq(0).after(html); + } + } +} + +$(document).ready(function(){ + $('#chatclick').bind('click', function() + { + SendChat($('#chattext').val()); + $('#chattext').val(''); + }); + + $('#chattext').bind('keypress', function(ev) + { + if (ev.keyCode == 13) { + SendChat($('#chattext').val()); + $('#chattext').val(''); + } + }); +}); diff --git a/supervisorchat.php b/supervisorchat.php index 22c97dec..8539a6eb 100644 --- a/supervisorchat.php +++ b/supervisorchat.php @@ -56,16 +56,41 @@ if (AUTO_LOGOUT_MINUTES !== false) xhtml_head(T_("Supervisor chat"),true,array("css/table.css"),$js); $operator_id = get_operator_id(); +$chatenabled = get_setting("chat_enabled"); +if (empty($chatenabled)) + $chatenabled = false; +else + $chatenabled = true; -//javascript to activate connection for this user -print ""; +if ($chatenabled && operator_chat_enabled($operator_id)) +{ + //get BOSH service URL + $bosh_service = get_setting("bosh_service"); + if (empty($bosh_service)) + $bosh_service = "/xmpp-httpbind"; -//table for chat messages -print "
" . T_("From") . "" . T_("Message") . "
"; + //could set this on a shift by shift basis if required + $supervisor_xmpp = get_setting("supervisor_xmpp"); + + //javascript to activate connection for this user + print ""; + + print ""; + print "
" . T_("Supervisor not available") . "
"; + + print "
" . T_("Send") . "
"; + + //table for chat messages + print "
" . T_("From") . "" . T_("Message") . "
"; +} +else + print "

" . T_("Supervisor chat is not enabled") . "

"; xhtml_foot();