[Vtigercrm-commits] [vtiger-commits] r7880 - in /branches/VTIGERCRM-5.0.2-MMBRICH: Smarty/templates/Header.tpl include/js/objects/CommSystem.js modules/CommSystem/CommSystem.php modules/CommSystem/CommSystemAjax.php themes/blue/header.php themes/blue/style.css
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Jul 6 20:17:26 EDT 2006
Author: mmbrich
Date: Thu Jul 6 18:17:25 2006
New Revision: 7880
Log:
more comm system stuff
Modified:
branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl
branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php
branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php
branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php
branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl Thu Jul 6 18:17:25 2006
@@ -18,12 +18,13 @@
<style type="text/css">@import url("themes/{$THEME}/style.css");</style>
</head>
<body leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 class=small onLoad="Announcement_rss()">
+ <span id="comm_sys"> </span>
<a name="top"></a>
<!-- header -->
<!-- header-vtiger crm name & RSS -->
<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
<script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
- <script language="javascript" type="text/javascript" src="include/scriptaculous/scriptaculous.js?load=effects,dragdrop"></script>
+ <script language="javascript" type="text/javascript" src="include/scriptaculous/scriptaculous.js?load=effects,dragdrop,builder"></script>
<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
<script language="JavaScript" type="text/javascript" src="include/calculator/calc.js"></script>
<script language="JavaScript" type="text/javascript" src="modules/Calendar/script.js"></script>
@@ -141,6 +142,10 @@
</td>
</tr>
</TABLE>
+
+<span id="CommSliderDiv" class="commSlider">
+{$USERLIST}
+</span>
<div id="calculator_cont" style="position:absolute; z-index:10000" ></div>
{include file="Clock.tpl"}
@@ -423,10 +428,13 @@
/* START COMMUNICATIONS SYSTEM */
function openCommSystem() {
- var CS = new CommSystem("CommSliderDiv");
+ CS.OpenSlider();
}
var VtUser = {}
new VtigerUser();
+addOnloadEvent(function() {
+ CS = new CommSystem("CommSliderDiv");
+});
</SCRIPT>
{/literal}
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js Thu Jul 6 18:17:25 2006
@@ -6,6 +6,7 @@
this.username = VtUser.user_name;
this.sliderElement = element;
this.CheckSession();
+ this.sliderOpen = "false";
this.timer;
},
@@ -22,10 +23,7 @@
{queue: {position: 'end', scope: 'commsys'},
method: 'post',
postBody: 'module=CommSystem&action=CommSystemAjax&command=getPeriodicalInfo',
- onComplete: function(response) {
- alert(response.responseText);
- //this.timer = window.setTimeout('globalCommSystem.CommUpdate()',this.refreshtime);
- },
+ onComplete: this.HandleEvent,
onFailure: function() {
window.ClearTimeout(globalCommSystem.timer);
}
@@ -40,14 +38,34 @@
* class value to change the appearance
*/
OpenSlider: function() {
- Try.these(
- function() {
- new Effect.Appear($(this.sliderElement));
- },
- function() {
- $(this.sliderElement).className = "OpenCommSlider";
- }
- );
+ globalCommSystem = this;
+ if(this.sliderOpen == "false") {
+ Try.these (
+ function() {
+ $(globalCommSystem.sliderElement).className = "commSliderOpen";
+ },
+ function() {
+ $(globalCommSystem.sliderElement).style.width = '180px';
+ },
+ function() {
+ new Effect.Appear($(globalCommSystem.sliderElement));
+ }
+ );
+ this.sliderOpen = "true";
+ } else {
+ Try.these (
+ function() {
+ $(globalCommSystem.sliderElement).className = "commSlider";
+ },
+ function() {
+ new Effect.Fade($(globalCommSystem.sliderElement));
+ },
+ function() {
+ $(globalCommSystem.sliderElement).style.width = '0px';
+ }
+ );
+ this.sliderOpen = "false";
+ }
},
/*
@@ -57,11 +75,8 @@
*/
CheckSession: function() {
try {
- if(this.debug)
- alert("Check Session Start");
-
- window.clearTimeout(this.timer);
- this.CommUpdate();
+ window.clearTimeout(this.timer);
+ this.CommUpdate();
}catch(e){if(this.debug) alert(e);}
},
@@ -75,8 +90,9 @@
'index.php',
{queue: {position: 'end', scope: 'commsys'},
method: 'post',
- postBody: 'module=Users&action=UsersAjax&announce_rss=yes',
+ postBody: 'module=CommSystem&action=CommSystemAjax&command=sendChatMessage&receivers='+otheruser+'&msg='+msg+'msg_type=P2PIM',
onComplete: function(response) {
+ alert(response.responseText);
}
}
);
@@ -87,7 +103,140 @@
* or open a past window that was closed during
* this session
*/
- ShowNewChatMessage: function(otheruser,msg) {
-
+ ShowNewChatMessage: function(msg,header_msg) {
+ Try.these (
+ function() {
+ new Effect.Appear("msgwindow_"+msg.sending_user);
+ },
+ function() {
+ if(msg.msg_type == "P2PIM")
+ var clsname = "chatWindow";
+ else if(msg.msg_type == "GRPCHAT")
+ var clsname = "grpChatWindow";
+
+ var main_table = Builder.node(
+ 'table',
+ {
+ cellpadding:'2',cellspacing:'0',border:'0',className:clsname,
+ id:'msgwindow_'+msg.sending_user
+ }
+ );
+ var top_bar = Builder.node(
+ 'tr',
+ {
+ align:'center',width:'100%',valign:'top'
+ },
+ [ Builder.node(
+ 'td',
+ [ Builder.node(
+ 'span',
+ {
+ className:'chatWindowHeaderLeft'
+ },
+ header_msg+" "
+ )],
+ [ Builder.node(
+ 'span',
+ {
+ className:'chatWindowHeaderRight'
+ },
+ [ Builder.node(
+ 'img',
+ {src:'themes/blue/images/close.gif',
+ onClick: 'new Effect.Fade(\'msgwindow_'+msg.sending_user+'\')'
+ }
+ )]
+ )]
+ )]
+ );
+ main_table.appendChild(top_bar);
+
+ msg.msg_data +="<BR>";
+ var chat_data = Builder.node(
+ 'tr',
+ {
+ valign:'top',align:'center'
+ },
+ [ Builder.node(
+ 'td',
+ {
+ width:'100%',height:'100%',colspan:'2'
+ },
+ [ Builder.node(
+ 'div', {id:'chat_data_'+msg.sending_user,className:'chatWindowDataArea'}
+ )]
+ )]
+ );
+ main_table.appendChild(chat_data);
+
+ var msg_input = Builder.node(
+ 'tr',
+ {
+ valign:'top',align:'center'
+ },
+ [ Builder.node(
+ 'td',
+ {
+ width:'100%',height:'100%',colspan:'2'
+ },
+ [ Builder.node(
+ 'div', {id:'msg_input_'+msg.sending_user},
+ [ Builder.node(
+ 'textarea'
+ )]
+ )]
+ )]
+ );
+ main_table.appendChild(msg_input);
+
+ main_table.style.display = "none";
+ $("comm_sys").appendChild(main_table);
+
+ $("chat_data_"+msg.sending_user).innerHTML += msg.msg_data;
+ $("msg_input_"+msg.sending_user).innerHTML += '<input type="submit" class="button" value="Send">';
+
+ new Effect.Appear(main_table);
+ }
+ );
+ },
+
+ /*
+ * function to parse JSON msg data
+ * and act on alerts or messages
+ * for alerts the system will open a small slider
+ * on the screen to alert the user
+ * for messages (IMs) a window object will be built for the message.
+ */
+ HandleEvent: function(responseData) {
+ //alert(responseData.responseText);
+ if(responseData.responseText.match(/none/))
+ return false;
+ else {
+ var msgs = eval('(' + responseData.responseText + ')');
+ for (var i=0;i<msgs.CommSysMessages.length;i++) {
+ var msgid = msgs.CommSysMessages[i].message.msgid;
+ var msg_type = msgs.CommSysMessages[i].message.msg_type;
+ try {
+ switch(msg_type) {
+ case 'P2PIM':
+ globalCommSystem.ShowNewChatMessage(msgs.CommSysMessages[i].message,"Message from matt");
+ break;
+ case 'GRPIM':
+ alert(msgs.CommSysMessages[i].message.msg_data);
+ break;
+ case 'EMAIL':
+ alert(msgs.CommSysMessages[i].message.recordid);
+ break;
+ case 'INPHONE':
+ alert(msgs.CommSysMessages[i].message.msg_data);
+ break;
+ case 'VOICEMAIL':
+ alert(msgs.CommSysMessages[i].message.msg_data);
+ break;
+ }
+ }catch(e){alert(e);}
+ }
+ }
+ //this.timer = window.setTimeout('globalCommSystem.CommUpdate()',this.refreshtime);
}
}
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php Thu Jul 6 18:17:25 2006
@@ -32,32 +32,32 @@
}
function SendAlert($msg_data,$msg_type,$recordid='0',$sending_user='0',$receivers='0') {
- $nowdate=date();
+ //$nowdate=date();
switch($msg_type) {
case 'GRPIM':
case 'P2PIM':
- if($receivers == 0 || $sending_user == 0) { return false; }
+ if($receivers == 0 || $sending_user == 0) { return "false"; }
$q = "INSERT INTO vtiger_comm_system
(msg_type,sending_user,receivers,msg_data,sentdate)
VALUES
('".$msg_type."','".$sending_user."','".$receivers."','".$msg_data."','".$nowdate."')";
break;
case 'EMAIL':
- if($recordid == 0 || $sending_user == 0) { return false; }
+ if($recordid == 0 || $sending_user == 0) { return "false"; }
$q = "INSERT INTO vtiger_comm_system
(msg_type,sending_user,recordid,sentdate)
VALUES
('".$msg_type."','".$sending_user."','".$recordid."','".$nowdate."')";
break;
case 'BATTACH':
- if($sending_user == 0 || $receivers == 0) { return false; }
+ if($sending_user == 0 || $receivers == 0) { return "false"; }
$q = "INSERT INTO vtiger_comm_system
(msg_type,sending_user,receivers,msg_data,sentdate)
VALUES
('".$msg_type."','".$sending_user."','".$receivers."','".$msg_data."','".$nowdate."')";
break;
case 'RATTACH':
- if($sending_user == 0 || $recordid == 0 || $receivers == 0) { return false; }
+ if($sending_user == 0 || $recordid == 0 || $receivers == 0) { return "false"; }
$q = "INSERT INTO vtiger_comm_system
(msg_type,sending_user,receivers,recordid,sentdate)
VALUES
@@ -71,9 +71,9 @@
break;
if(isset($q) && $q != "") {
//$rs = $this->db->query($q);
- return true;
+ return "true";
} else
- return false;
+ return "false";
}
}
@@ -83,28 +83,35 @@
$p2p = $this->db->query($q);
// This query will get all group/broadcast messages
- $q = "SELECT * FROM vtiger_comm_system WHERE receivers LIKE '%".$userid."%' AND viewed = '0'";
+ $q = "SELECT * FROM vtiger_comm_system WHERE receivers LIKE '%,".$userid.",%' OR receivers LIKE '".$userid.",%' OR receivers LIKE '%,".$userid."' AND viewed = '0'";
$grp = $this->db->query($q);
$ret = array();
// load return array with p2p messages
+ $c=0;
while($row = $this->db->fetch_array($p2p)) {
- $msgid=$row["msgid"];
- $ret[$msgid]["msg_type"] = $row["msg_type"];
- $ret[$msgid]["msg_data"] = $row["msg_data"];
- $ret[$msgid]["recordid"] = $row["recordid"];
- $ret[$msgid]["sending_user"] = $row["sending_user"];
- $ret[$msgid]["sentdate"] = $row["sentdate"];
+ if($row["msgid"] != "" && isset($row["msgid"])) {
+ $ret[$c]["msgid"] = $row["msgid"];
+ $ret[$c]["msg_type"] = $row["msg_type"];
+ $ret[$c]["msg_data"] = $row["msg_data"];
+ $ret[$c]["recordid"] = $row["recordid"];
+ $ret[$c]["sending_user"] = $row["sending_user"];
+ $ret[$c]["sentdate"] = $row["sentdate"];
+ $c++;
+ }
}
// load return array with group messages
while($row = $this->db->fetch_array($grp)) {
- $msgid=$row["msgid"];
- $ret[$msgid]["msg_type"] = $row["msg_type"];
- $ret[$msgid]["msg_data"] = $row["msg_data"];
- $ret[$msgid]["recordid"] = $row["recordid"];
- $ret[$msgid]["sending_user"] = $row["sending_user"];
- $ret[$msgid]["sentdate"] = $row["sentdate"];
+ if($row["msgid"] != "" && isset($row["msgid"])) {
+ $ret[$c]["msgid"] = $row["msgid"];
+ $ret[$c]["msg_type"] = $row["msg_type"];
+ $ret[$c]["msg_data"] = $row["msg_data"];
+ $ret[$c]["recordid"] = $row["recordid"];
+ $ret[$c]["sending_user"] = $row["sending_user"];
+ $ret[$c]["sentdate"] = $row["sentdate"];
+ $c++;
+ }
}
return $ret;
}
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php Thu Jul 6 18:17:25 2006
@@ -30,20 +30,37 @@
require_once("modules/CommSystem/CommSystem.php");
$commSys = new CommSystem();
$msg = $commSys->GetNewAlerts($_SESSION["authenticated_user_id"]);
- /* $ret = '';
- $ret = '{"VtUser":[';
- $ret .= '{"data":';
- $ret .= '{';
- while($row = $adb->fetch_array($rs)) {
- foreach($row as $name=>$value) {
- $ret .= '"'.$name.'":"'.$value.'",';
- }
- }
- $ret .= '}';
- $ret .= '}';
- $ret .= ']}';
- */
- echo print_r($msg);
- //echo $ret;
+ $ret = '';
+ $cnt=count($msg);
+ if($cnt == 0)
+ $ret = "none";
+ else {
+ $ret = '{"CommSysMessages":[';
+ for($i=0;$i<$cnt;$i++) {
+ $ret .= '{"message":';
+ $ret .= '{';
+ $ret .= '"msgid":"'.$msg[$i]["msgid"].'",';
+ $ret .= '"msg_type":"'.$msg[$i]["msg_type"].'",';
+ $ret .= '"recordid":"'.$msg[$i]["recordid"].'",';
+ $ret .= '"sending_user":"'.$msg[$i]["sending_user"].'",';
+ $ret .= '"timestamp":"'.$msg[$i]["sentdate"].'",';
+ $ret .= '"msg_data":"'.$msg[$i]["msg_data"].'"}';
+
+ if(($i+1) == $cnt)
+ $ret .= '}';
+ else
+ $ret .= '},';
+ }
+ $ret .= ']}';
+ }
+ echo $ret;
+}
+if($_REQUEST["command"] == "sendChatMessage") {
+ require_once("modules/CommSystem/CommSystem.php");
+ $commSys = new CommSystem();
+ if($commSys->SendAlert($_REQUEST["msg"],$_REQUEST["msg_type"],$_SESSION["authenticated_user_id"],$_REQUEST["receivers"]) == "false")
+ echo "failed";
+ else
+ echo "success";
}
?>
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/header.php Thu Jul 6 18:17:25 2006
@@ -101,6 +101,15 @@
global $module_menu;
+$q = "select user_name,id from vtiger_users";
+$rs = $adb->query($q);
+$list = "<center><b>CRM Users:</b>";
+while($row=$adb->fetch_array($rs)) {
+ $list .= "<br><a href='javascript:;' onclick='CS.SendChatMessage(\"".$row["id"]."\",\"\");'>".$row["user_name"]."</a>";
+}
+$list .= "</center>";
+
+$smarty->assign("USERLIST",$list);
require_once('data/Tracker.php');
$tracFocus=new Tracker();
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css Thu Jul 6 18:17:25 2006
@@ -2876,4 +2876,52 @@
.trackerList {
border-bottom:1px solid #eeeeee;
}
-
+
+/* Comm System */
+.chatWindow {
+ position: absolute;
+ width: 200px;
+ height: 300px;
+ top: 50px;
+ left: 1px;
+ border: 1px solid gray;
+ background-color: white;
+ z-index:2000000;
+}
+.chatWindowHeaderLeft {
+ width: 75%;
+ height: 25px;
+ float:left
+}
+.chatWindowHeaderRight {
+ width: 22%;
+ height: 25px;
+ float:right
+}
+.chatWindowDataArea {
+ border: 1px solid gray;
+ width: 95%;
+ height: 200px;
+ text-align:left;
+ padding-left:3px;
+}
+.commSlider {
+ position: absolute;
+ width: 180px;
+ height: 300px;
+ top: 50px;
+ right: 1px;
+ border: 1px solid gray;
+ background-color: white;
+ display: none;
+}
+.commSliderOpen {
+ position: absolute;
+ width: 180px;
+ height: 300px;
+ top: 50px;
+ right: 1px;
+ border: 1px solid gray;
+ background-color: white;
+ z-index:1900000;
+}
More information about the vtigercrm-commits
mailing list