diff --git a/oss/vtiger/trunk/modules/Home/HomeAjax.php b/oss/vtiger/trunk/modules/Home/HomeAjax.php
new file mode 100644
index 00000000..27b1041d
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/HomeAjax.php
@@ -0,0 +1,14 @@
+
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Home/HomeBlock.php b/oss/vtiger/trunk/modules/Home/HomeBlock.php
new file mode 100644
index 00000000..10d171a2
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/HomeBlock.php
@@ -0,0 +1,70 @@
+assign("MOD",$mod_strings);
+$smarty->assign("APP",$app_strings);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH",$image_path);
+
+if(!empty($_REQUEST['homestuffid'])){
+ $stuffid = $_REQUEST['homestuffid'];
+}
+if(!empty($_REQUEST['blockstufftype'])){
+ $stufftype = $_REQUEST['blockstufftype'];
+}
+
+if($stufftype=='Tag Cloud'){
+ $freetag = new freetag();
+ $smarty->assign("ALL_TAG",$freetag->get_tag_cloud_html("",$current_user->id));
+ $smarty->display("Home/TagCloud.tpl");
+}elseif($stufftype == 'Notebook'){
+ $contents = $homeObj->getNoteBookContents($stuffid);
+ $smarty->assign("NOTEBOOK_CONTENTS",$contents);
+ $smarty->assign("NOTEBOOKID", $stuffid);
+ $smarty->display("Home/notebook.tpl");
+}elseif($stufftype == 'URL'){
+ $url = $homeObj->getWidgetURL($stuffid);
+ if(strpos($url, "://") === false){
+ $url = "http://".trim($url);
+ }
+ $smarty->assign("URL",$url);
+ $smarty->assign("WIDGETID", $stuffid);
+ $smarty->display("Home/HomeWidgetURL.tpl");
+}else{
+ $homestuff_values=$homeObj->getHomePageStuff($stuffid,$stufftype);
+ if($stufftype=="DashBoard"){
+ $homeObj->getDashDetails($stuffid,'type');
+ $dashdet=$homeObj->dashdetails;
+ }
+}
+
+$smarty->assign("DASHDETAILS",$dashdet);
+$smarty->assign("HOME_STUFFTYPE",$stufftype);
+$smarty->assign("HOME_STUFFID",$stuffid);
+$smarty->assign("HOME_STUFF",$homestuff_values);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+
+$smarty->display("Home/HomeBlock.tpl");
+?>
diff --git a/oss/vtiger/trunk/modules/Home/HomeNews.php b/oss/vtiger/trunk/modules/Home/HomeNews.php
new file mode 100644
index 00000000..adac778c
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/HomeNews.php
@@ -0,0 +1,32 @@
+vt_dofetch('http://www.vtiger.com/products/crm/newsfeed.php', $ftimeout);
+$items = $fparser->get_items();
+$NEWSLIST = Array();
+foreach($items as $item) {
+ $NEWSLIST[] = $item;
+}
+
+require_once('Smarty_setup.php');
+$smarty = new vtigerCRM_Smarty;
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", "themes/$theme/images/");
+$smarty->assign('NEWSLIST', $NEWSLIST);
+$smarty->display("HomeNews.tpl");
+?>
+
diff --git a/oss/vtiger/trunk/modules/Home/HomeUtils.php b/oss/vtiger/trunk/modules/Home/HomeUtils.php
new file mode 100644
index 00000000..2cfaeec3
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/HomeUtils.php
@@ -0,0 +1,208 @@
+query($list_query);
+ $noofrecords = $adb->num_rows($res);
+ if($calCnt == 'calculateCnt'){
+ return $noofrecords;
+ }
+
+ $open_activity_list = array();
+ if ($noofrecords>0){
+ for($i=0;$i<$noofrecords;$i++){
+ $open_activity_list[] = array('name' => $adb->query_result($res,$i,'subject'),
+ 'id' => $adb->query_result($res,$i,'activityid'),
+ 'type' => $adb->query_result($res,$i,'activitytype'),
+ 'module' => $adb->query_result($res,$i,'setype'),
+ 'date_start' => getDisplayDate($adb->query_result($res,$i,'date_start')),
+ 'due_date' => getDisplayDate($adb->query_result($res,$i,'due_date')),
+ 'recurringdate' => getDisplayDate($adb->query_result($res,$i,'recurringdate')),
+ 'priority' => $adb->query_result($res,$i,'priority'),
+ );
+ }
+ }
+ $values = getActivityEntries($open_activity_list);
+ $values['ModuleName'] = 'Calendar';
+ $values['search_qry'] = "&action=ListView&from_homepage=upcoming_activities";
+
+ return $values;
+}
+
+/**
+ * this function returns the activity entries in array format
+ * it takes in an array containing activity details as a parameter
+ * @param array $open_activity_list - the array containing activity details
+ * return array $values - activities record in array format
+ */
+function getActivityEntries($open_activity_list){
+ global $current_language, $app_strings;
+ $current_module_strings = return_module_language($current_language, 'Calendar');
+ if(!empty($open_activity_list)){
+ $header=array();
+ $header[] =$current_module_strings['LBL_LIST_SUBJECT'];
+ $header[] =$current_module_strings['Type'];
+
+ $entries = array();
+ foreach($open_activity_list as $event){
+ $recur_date=preg_replace('/--/','',$event['recurringdate']);
+ if($recur_date!=""){
+ $event['date_start']=$event['recurringdate'];
+ }
+ $font_color_high = "color:#00DD00;";
+ $font_color_medium = "color:#DD00DD;";
+
+ switch ($event['priority']){
+ case 'High':
+ $font_color=$font_color_high;
+ break;
+ case 'Medium':
+ $font_color=$font_color_medium;
+ break;
+ default:
+ $font_color='';
+ }
+
+ if($event['type'] != 'Task' && $event['type'] != 'Emails' && $event['type'] != ''){
+ $activity_type = 'Events';
+ }else{
+ $activity_type = 'Task';
+ }
+
+ $entries[$event['id']] = array(
+ '0' => ''.$event["name"].'',
+ '1' => $event["type"],
+ );
+ }
+ $values = array('noofactivities'=>count($open_activity_list),'Header'=>$header,'Entries'=>$entries);
+ }else{
+ $values = array('noofactivities'=>count($open_activity_list), 'Entries'=>
+ '
'.$app_strings['LBL_NO_DATA'].'
');
+ }
+ return $values;
+}
+
+
+/**
+ * function to get pending activities for today
+ * @param integer $maxval - the maximum number of records to display
+ * @param integer $calCnt - returns the count query if this is set
+ * return array $values - activities record in array format
+ */
+function homepage_getPendingActivities($maxval,$calCnt){
+ require_once("data/Tracker.php");
+ require_once("include/utils/utils.php");
+ require_once('include/utils/CommonUtils.php');
+
+ global $adb;
+ global $current_user;
+
+ $today = date("Y-m-d", time());
+ $pending_condition = " AND (due_date = '$today' OR vtiger_recurringevents.recurringdate = '$today')";
+
+ $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.".
+ "setype, vtiger_recurringevents.recurringdate, vtiger_activity.* from vtiger_activity ".
+ "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT ".
+ "JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join ".
+ "vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid".
+ $list_query .= getNonAdminAccessControlQuery('Calendar',$current_user);
+ $list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype not in ".
+ "('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ".
+ "('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR vtiger_activity.".
+ "eventstatus not in ('Held','Not Held')) ".$pending_condition;
+
+ $list_query.= " GROUP BY vtiger_activity.activityid";
+ $list_query.= " ORDER BY date_start,time_start ASC";
+ $list_query.= " limit $maxval";
+
+ $res = $adb->query($list_query);
+ $noofrecords = $adb->num_rows($res);
+ if($calCnt == 'calculateCnt'){
+ return $noofrecords;
+ }
+
+ $open_activity_list = array();
+ $noofrows = $adb->num_rows($res);
+ if (count($res)>0){
+ for($i=0;$i<$noofrows;$i++){
+ $open_activity_list[] = array('name' => $adb->query_result($res,$i,'subject'),
+ 'id' => $adb->query_result($res,$i,'activityid'),
+ 'type' => $adb->query_result($res,$i,'activitytype'),
+ 'module' => $adb->query_result($res,$i,'setype'),
+ 'date_start' => getDisplayDate($adb->query_result($res,$i,'date_start')),
+ 'due_date' => getDisplayDate($adb->query_result($res,$i,'due_date')),
+ 'recurringdate' => getDisplayDate($adb->query_result($res,$i,'recurringdate')),
+ 'priority' => $adb->query_result($res,$i,'priority'),
+ );
+ }
+ }
+
+ $values = getActivityEntries($open_activity_list);
+ $values['ModuleName'] = 'Calendar';
+ $values['search_qry'] = "&action=ListView&from_homepage=pending_activities";
+
+ return $values;
+}
+
+
+/**
+ * this function returns the number of columns in the home page for the current user.
+ * if nothing is found in the database it returns 4 by default
+ * return integer $data - the number of columns
+ */
+function getNumberOfColumns(){
+ global $current_user, $adb;
+
+ $sql = "select * from vtiger_home_layout where userid=?";
+ $result = $adb->pquery($sql, array($current_user->id));
+
+ if($adb->num_rows($result)>0){
+ $data = $adb->query_result($result,0,"layout");
+ }else{
+ $data = 4; //default is 4 column layout for now
+ }
+ return $data;
+}
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Home/HomeWidgetBlockList.php b/oss/vtiger/trunk/modules/Home/HomeWidgetBlockList.php
new file mode 100644
index 00000000..970daca7
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/HomeWidgetBlockList.php
@@ -0,0 +1,77 @@
+assign("MOD",$mod_strings);
+$smarty->assign("APP",$app_strings);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH",$image_path);
+
+foreach ($widgetInfoList as $widgetInfo) {
+ $widgetType = $widgetInfo['widgetType'];
+ $widgetId = $widgetInfo['widgetId'];
+ if($widgetType=='Tag Cloud'){
+ $freetag = new freetag();
+ $smarty->assign("ALL_TAG",$freetag->get_tag_cloud_html("",$current_user->id));
+ $html = $smarty->fetch("Home/TagCloud.tpl");
+ }elseif($widgetType == 'Notebook'){
+ $contents = $homeObj->getNoteBookContents($widgetId);
+ $smarty->assign("NOTEBOOK_CONTENTS",$contents);
+ $smarty->assign("NOTEBOOKID", $widgetId);
+ $html = $smarty->fetch("Home/notebook.tpl");
+ }elseif($widgetType == 'URL'){
+ $url = $homeObj->getWidgetURL($widgetId);
+ if(strpos($url, "://") === false){
+ $url = "http://".trim($url);
+ }
+ $smarty->assign("URL",$url);
+ $smarty->assign("WIDGETID", $widgetId);
+ $html = $smarty->fetch("Home/HomeWidgetURL.tpl");
+ }else{
+ $homestuff_values=$homeObj->getHomePageStuff($widgetId,$widgetType);
+ $html = '';
+ if($widgetType == "DashBoard"){
+ $homeObj->getDashDetails($widgetId,'type');
+ $dashdet=$homeObj->dashdetails;
+ $smarty->assign("DASHDETAILS",$dashdet);
+ }
+ }
+ $smarty->assign("HOME_STUFFTYPE",$widgetType);
+ $smarty->assign("HOME_STUFFID",$widgetId);
+ $smarty->assign("HOME_STUFF",$homestuff_values);
+ $smarty->assign("THEME", $theme);
+ $smarty->assign("IMAGE_PATH", $image_path);
+
+ $html .= $smarty->fetch("Home/HomeBlock.tpl");
+ $widgetHTML[$widgetId] = $html;
+}
+echo Zend_JSON::encode($widgetHTML);
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Home/Homestuff.js b/oss/vtiger/trunk/modules/Home/Homestuff.js
new file mode 100644
index 00000000..1c12d051
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/Homestuff.js
@@ -0,0 +1,706 @@
+/*+********************************************************************************
+ * The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is: vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ *
+ *******************************************************************************/
+
+/**
+ * this function is used to show hide the columns in the add widget div based on the option selected
+ * @param string typeName - the selected option
+ */
+function chooseType(typeName){
+ $('vtbusy_info').style.display="inline";
+ $('stufftype_id').value=typeName;
+
+ var typeLabel = typeName;
+ if(alert_arr[typeName] != null && alert_arr[typeName] != "" && alert_arr[typeName] != 'undefined'){
+ typeLabel = alert_arr[typeName];
+ }
+ $('divHeader').innerHTML=""+alert_arr.LBL_ADD+typeLabel+"";
+ if(typeName=='Module'){
+ $('moduleNameRow').style.display="block";
+ $('moduleFilterRow').style.display="block";
+ $('modulePrimeRow').style.display="block";
+ $('showrow').style.display="block";
+ $('rssRow').style.display="none";
+ $('dashNameRow').style.display="none";
+ $('dashTypeRow').style.display="none";
+ $('StuffTitleId').style.display="block";
+ //$('homeURLField').style.display = "none";
+ }else if(typeName=='DashBoard'){
+ $('moduleNameRow').style.display="none";
+ $('moduleFilterRow').style.display="none";
+ $('modulePrimeRow').style.display="none";
+ $('rssRow').style.display="none";
+ $('showrow').style.display="none";
+ $('dashNameRow').style.display="block";
+ $('dashTypeRow').style.display="block";
+ $('StuffTitleId').style.display="block";
+ //$('homeURLField').style.display = "none";
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomestuffAjax&dash=dashboard',
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ $('selDashName').innerHTML=response.responseText;
+ show('addWidgetsDiv');
+ placeAtCenter($('addWidgetsDiv'));
+ $('vtbusy_info').style.display="none";
+ }
+ }
+ );
+ }else if(typeName=='RSS'){
+ $('moduleNameRow').style.display="none";
+ $('moduleFilterRow').style.display="none";
+ $('modulePrimeRow').style.display="none";
+ $('showrow').style.display="block";
+ $('rssRow').style.display="block";
+ $('dashNameRow').style.display="none";
+ $('dashTypeRow').style.display="none";
+ $('StuffTitleId').style.display="block";
+ $('vtbusy_info').style.display="none";
+ //$('homeURLField').style.display = "none";
+ }else if(typeName=='Default'){
+ $('moduleNameRow').style.display="none";
+ $('moduleFilterRow').style.display="none";
+ $('modulePrimeRow').style.display="none";
+ $('showrow').style.display="none";
+ $('rssRow').style.display="none";
+ $('dashNameRow').style.display="none";
+ $('dashTypeRow').style.display="none";
+ $('StuffTitleId').style.display="none";
+ $('url_id').style.display = "none";
+ }else if(typeName == 'Notebook'){
+ $('moduleNameRow').style.display="none";
+ $('moduleFilterRow').style.display="none";
+ $('modulePrimeRow').style.display="none";
+ $('showrow').style.display="none";
+ $('rssRow').style.display="none";
+ $('dashNameRow').style.display="none";
+ $('dashTypeRow').style.display="none";
+ $('StuffTitleId').style.display="block";
+ $('vtbusy_info').style.display="none";
+ //$('homeURLField').style.display = "none";
+ }
+ /*else if(typeName == 'URL'){
+ $('moduleNameRow').style.display="none";
+ $('moduleFilterRow').style.display="none";
+ $('modulePrimeRow').style.display="none";
+ $('showrow').style.display="none";
+ $('rssRow').style.display="none";
+ $('dashNameRow').style.display="none";
+ $('dashTypeRow').style.display="none";
+ $('StuffTitleId').style.display="block";
+ $('vtbusy_info').style.display="none";
+ //$('homeURLField').style.display = "block";
+ }*/
+}
+
+/**
+ * this function is used to set the filter list when the module name is changed
+ * @param string modName - the modula name for which you want the filter list
+ */
+function setFilter(modName){
+ var modval=modName.value;
+ document.getElementById('savebtn').disabled = true;
+ if(modval!=""){
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomestuffAjax&modname='+modval,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ $('selModFilter_id').innerHTML=response.responseText;
+ setPrimaryFld(document.getElementById('selFilterid'));
+ show('addWidgetsDiv');
+ placeAtCenter($('addWidgetsDiv'));
+ }
+ }
+ );
+ }
+}
+
+/**
+ * this function is used to set the field list when the module name is changed
+ * @param string modName - the modula name for which you want the field list
+ */
+function setPrimaryFld(Primeval){
+ primecvid=Primeval.value;
+ var fldmodule = $('selmodule_id').options[$('selmodule_id').selectedIndex].value;
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomestuffAjax&primecvid='+primecvid+'&fieldmodname='+fldmodule,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ $('selModPrime_id').innerHTML=response.responseText;
+ $('selPrimeFldid').selectedIndex = 0;
+ $('vtbusy_info').style.display="none";
+ document.getElementById('savebtn').disabled = false;
+ }
+ }
+ );
+}
+
+/**
+ * this function displays the div for selecting the number of rows in a widget
+ * @param string sid - the id of the widget for which the div is being displayed
+ */
+function showEditrow(sid){
+ $('editRowmodrss_'+sid).className="show_tab";
+}
+
+/**
+ * this function is used to hide the div for selecting the number of rows in a widget
+ * @param string editRow - the id of the div
+ */
+function cancelEntries(editRow){
+ $(editRow).className="hide_tab";
+}
+
+/**
+ * this function is used to save the maximum entries that a widget can display
+ * @param string selMaxName - the widget name
+ */
+function saveEntries(selMaxName){
+ sidarr=selMaxName.split("_");
+ sid=sidarr[1];
+ $('refresh_'+sid).innerHTML=$('vtbusy_homeinfo').innerHTML;
+ cancelEntries('editRowmodrss_'+sid)
+ showmax=$(selMaxName).value;
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomestuffAjax&showmaxval='+showmax+'&sid='+sid,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ eval(response.responseText);
+ $('refresh_'+sid).innerHTML='';
+ }
+ }
+ );
+}
+
+/**
+ * this function is used to save the dashboard values
+ */
+function saveEditDash(dashRowId){
+ $('refresh_'+dashRowId).innerHTML=$('vtbusy_homeinfo').innerHTML;
+ cancelEntries('editRowmodrss_'+dashRowId);
+ var dashVal='';
+ var iter=0;
+ for(iter=0;iter<3;iter++){
+ if($('dashradio_'+[iter]).checked)
+ dashVal=$('dashradio_'+[iter]).value;
+ }
+ did=dashRowId;
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomestuffAjax&dashVal='+dashVal+'&did='+did,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ eval(response.responseText);
+ $('refresh_'+did).innerHTML='';
+ }
+ }
+ );
+}
+
+/**
+ * this function is used to delete widgets form the home page
+ * @param string sid - the stuffid of the widget
+ */
+function DelStuff(sid){
+ if(confirm(alert_arr.SURE_TO_DELETE)){
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomestuffAjax&homestuffid='+sid,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ if(response.responseText.indexOf('SUCCESS') > -1){
+ var delchild = $('stuff_'+sid);
+ odeletedChild = $('MainMatrix').removeChild(delchild);
+ $('seqSettings').innerHTML= '| Widget deleted sucessfully. |
';
+ $('seqSettings').style.display = 'block';
+ $('seqSettings').style.display = 'none';
+ placeAtCenter($('seqSettings'));
+ Effect.Appear('seqSettings');
+ setTimeout(hideSeqSettings,3000);
+ }else{
+ alert(alert_arr.ERROR_DELETING_TRY_AGAIN)
+ }
+ }
+ }
+ );
+ }
+}
+
+/**
+ * this function loads the newly added div to the home page
+ * @param string stuffid - the id of the newly created div
+ * @param string stufftype - the stuff type for the new div (for e.g. rss)
+ */
+function loadAddedDiv(stuffid,stufftype){
+ gstuffId = stuffid;
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=NewBlock&stuffid='+stuffid+'&stufftype='+stufftype,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ $('MainMatrix').style.display= 'none';
+ $('MainMatrix').innerHTML = response.responseText + $('MainMatrix').innerHTML;
+ positionDivInAccord('stuff_'+gstuffId,'',stufftype);
+ initHomePage();
+ loadStuff(stuffid,stufftype);
+ $('MainMatrix').style.display='block';
+ }
+ }
+ );
+}
+
+/**
+ * this function is used to reload a widgets' content based on its id and type
+ * @param string stuffid - the widget id
+ * @param string stufftype - the type of the widget
+ */
+function loadStuff(stuffid,stufftype){
+ $('refresh_'+stuffid).innerHTML=$('vtbusy_homeinfo').innerHTML;
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomeBlock&homestuffid='+stuffid+'&blockstufftype='+stufftype,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ $('stuffcont_'+stuffid).innerHTML=response.responseText;
+ if(stufftype=="Module"){
+ if($('more_'+stuffid).value != null && $('more_'+stuffid).value != '')
+ $('a_'+stuffid).href = "index.php?module="+$('more_'+stuffid).value+"&action=ListView&viewname="+$('cvid_'+stuffid).value;
+ }
+ if(stufftype=="Default" && typeof($('a_'+stuffid)) != 'undefined'){
+ if($('more_'+stuffid).value != ''){
+ $('a_'+stuffid).style.display = 'block';
+ var url = "index.php?module="+$('more_'+stuffid).value+"&action=index";
+ if($('search_qry_'+stuffid)!=''){
+ url += $('search_qry_'+stuffid).value;
+ }
+ $('a_'+stuffid).href = url;
+ }else{
+ $('a_'+stuffid).style.display = 'none';
+ }
+ }
+ if(stufftype=="RSS"){
+ $('a_'+stuffid).href = $('more_'+stuffid).value;
+ }
+ if(stufftype=="DashBoard"){
+ $('a_'+stuffid).href = "index.php?module=Dashboard&action=index&type="+$('more_'+stuffid).value;
+ }
+ $('refresh_'+stuffid).innerHTML='';
+ }
+ }
+ );
+}
+
+function loadAllWidgets(widgetInfoList, batchSize){
+ var batchWidgetInfoList = [];
+ var widgetInfo = {};
+ for(var index =0 ; index < widgetInfoList.length;++index) {
+ var widgetId = widgetInfoList[index].widgetId;
+ var widgetType = widgetInfoList[index].widgetType;
+ widgetInfo[widgetId] = widgetType;
+ $('refresh_'+widgetId).innerHTML=$('vtbusy_homeinfo').innerHTML;
+ batchWidgetInfoList.push(widgetInfoList[index]);
+ if((index > 0 && (index+1) % batchSize == 0) || index+1 == widgetInfoList.length) {
+ new Ajax.Request(
+ 'index.php',{
+ queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomeWidgetBlockList&widgetInfoList='
+ + JSON.stringify(batchWidgetInfoList),
+ onComplete: function(response){
+ var responseVal=JSON.parse(response.responseText);
+ for(var widgetId in responseVal) {
+ if(responseVal.hasOwnProperty(widgetId)) {
+ $('stuffcont_'+widgetId).innerHTML = responseVal[widgetId];
+ $('refresh_'+widgetId).innerHTML='';
+ var widgetType = widgetInfo[widgetId];
+ if(widgetType=="Module" && $('more_'+widgetId).value != null &&
+ $('more_'+widgetId).value != '') {
+ $('a_'+widgetId).href = "index.php?module="+
+ $('more_'+widgetId).value+"&action=ListView&viewname="+
+ $('cvid_'+widgetId).value;
+ } else if(widgetType == "Default" && typeof($('a_'+widgetId)) !=
+ 'undefined'){
+ if(typeof $('more_'+widgetId) != 'undefined' &&
+ $('more_'+widgetId).value != ''){
+ $('a_'+widgetId).style.display = 'block';
+ var url = "index.php?module="+$('more_'+widgetId).value+
+ "&action=index";
+ if($('search_qry_'+widgetId)!=''){
+ url += $('search_qry_'+widgetId).value;
+ }
+ $('a_'+widgetId).href = url;
+ }else{
+ $('a_'+widgetId).style.display = 'none';
+ }
+ } else if(widgetType=="RSS"){
+ $('a_'+widgetId).href = $('more_'+widgetId).value;
+ } else if(widgetType=="DashBoard"){
+ $('a_'+widgetId).href = "index.php?module=Dashboard&action="+
+ "index&type="+$('more_'+stuffid).value;
+ }
+ }
+ }
+ }
+ }
+ );
+ batchWidgetInfoList = [];
+ }
+ }
+}
+
+/**
+ * this function validates the form for creating a new widget
+ */
+function frmValidate(){
+ if(trim($('stufftitle_id').value)==""){
+ alert(alert_arr.LBL_ENTER_WINDOW_TITLE);
+ $('stufftitle_id').focus();
+ return false;
+ }
+ if($('stufftype_id').value=="RSS"){
+ if($('txtRss_id').value==""){
+ alert(alert_arr.LBL_ENTER_RSS_URL);
+ $('txtRss_id').focus();
+ return false;
+ }
+ }
+ /*if($('stufftype_id').value=="URL"){
+ if($('url_id').value==""){
+ alert("Please enter URL");
+ $('url_id').focus();
+ return false;
+ }
+ }*/
+ if($('stufftype_id').value=="Module"){
+ var selLen;
+ var fieldval=new Array();
+ var cnt=0;
+ selVal=document.Homestuff.PrimeFld;
+ for(k=0;k2){
+ alert(alert_arr.LBL_SELECT_ONLY_FIELDS);
+ selVal.focus();
+ return false;
+ }else{
+ document.Homestuff.fldname.value=fieldval;
+ }
+ }
+ var stufftype=$('stufftype_id').value;
+ var stufftitle=$('stufftitle_id').value;
+ $('stufftitle_id').value = '';
+ var selFiltername='';
+ var fldname='';
+ var selmodule='';
+ var maxentries='';
+ var txtRss='';
+ var seldashbd='';
+ var seldashtype='';
+ var seldeftype='';
+ //var txtURL = '';
+
+ if(stufftype=="Module"){
+ selFiltername =document.Homestuff.selFiltername[document.Homestuff.selFiltername.selectedIndex].value;
+ fldname = fieldval;
+ selmodule =$('selmodule_id').value;
+ maxentries =$('maxentryid').value;
+ }else if(stufftype=="RSS"){
+ txtRss=$('txtRss_id').value;
+ maxentries =$('maxentryid').value;
+ }/*else if(stufftype=="URL"){
+ txtURL=$('url_id').value;
+ }*/else if(stufftype=="DashBoard"){
+ seldashbd=$('seldashbd_id').value;
+ seldashtype=$('seldashtype_id').value;
+ }else if(stufftype=="Default"){
+ seldeftype=document.Homestuff.seldeftype[document.Homestuff.seldeftype.selectedIndex].value;
+ }
+
+ var url="stufftype="+stufftype+"&stufftitle="+stufftitle+"&selmodule="+selmodule+"&maxentries="+maxentries+"&selFiltername="+selFiltername+"&fldname="+encodeURIComponent(fldname)+"&txtRss="+txtRss+"&seldashbd="+seldashbd+"&seldashtype="+seldashtype+"&seldeftype="+seldeftype;//+'&txtURL='+txtURL;
+ var stuffarr=new Array();
+ $('vtbusy_info').style.display="inline";
+
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=Homestuff&'+url,
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ if(!response.responseText){
+ alert(alert_arr.LBL_ADD_HOME_WIDGET);
+ $('vtbusy_info').style.display="none";
+ $('stufftitle_id').value='';
+ $('txtRss_id').value='';
+ return false;
+ }else{
+ hide('addWidgetsDiv');
+ $('vtbusy_info').style.display="none";
+ $('stufftitle_id').value='';
+ $('txtRss_id').value='';
+ eval(response.responseText);
+ }
+ }
+ }
+ );
+}
+
+/**
+ * this function is used to hide the default widgets
+ * @param string sid - the id of the widget
+ */
+function HideDefault(sid){
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody:'module=Home&action=HomeAjax&file=HomestuffAjax&stuffid='+sid+"&act=hide",
+ onComplete: function(response){
+ var responseVal=response.responseText;
+ if(response.responseText.indexOf('SUCCESS') > -1){
+ var delchild = $('stuff_'+sid);
+ odeletedChild = $('MainMatrix').removeChild(delchild);
+ $('seqSettings').innerHTML= '| '+alert_arr.LBL_WIDGET_HIDDEN+'.'+alert_arr.LBL_RESTORE_FROM_PREFERENCES+'. |
';
+ $('seqSettings').style.display = 'block';
+ $('seqSettings').style.display = 'none';
+ placeAtCenter($('seqSettings'));
+ Effect.Appear('seqSettings');
+ setTimeout(hideSeqSettings,3000);
+ }else{
+ alert(alert_arr.ERR_HIDING + '.'+ alert_arr.MSG_TRY_AGAIN + '.');
+ }
+ }
+ }
+ );
+}
+
+
+/**
+ * this function removes the widget dropdown window
+ */
+function fnRemoveWindow(){
+ var tagName = document.getElementById('addWidgetDropDown').style.display= 'none';
+}
+
+/**
+ * this function displays the widget dropdown window
+ */
+function fnShowWindow(){
+ var tagName = document.getElementById('addWidgetDropDown').style.display= 'block';
+}
+
+/**
+ * this function is used to postion the widgets on home on page resize
+ * @param string targetDiv - the id of the target widget
+ * @param string stufftitle - the title of the target widget
+ * @param string stufftype - the type of the target widget
+ */
+function positionDivInAccord(targetDiv,stufftitle,stufftype){
+ var layout=$('homeLayout').value;
+ var widgetWidth;
+ var dashWidth;
+
+ switch(layout){
+ case '2':
+ widgetWidth = 49;
+ dashWidth = 98.6;
+ break;
+ case '3':
+ widgetWidth = 31;
+ dashWidth = 64;
+ break;
+ case '4':
+ widgetWidth = 24;
+ dashWidth = 48.6;
+ break;
+ default:
+ widgetWidth = 24;
+ dashWidth = 48.6;
+ break;
+ }
+ var mainX = parseInt(document.getElementById("MainMatrix").style.width);
+ if(stufftitle != vtdashboard_defaultDashbaordWidgetTitle && stufftype != "DashBoard"){
+ var dx = mainX * widgetWidth/ 100;
+ }else{
+ var dx = mainX * dashWidth / 100;
+ }
+ document.getElementById(targetDiv).style.width=dx + "%";
+}
+
+/**
+ * this function hides the seqSettings div
+ */
+function hideSeqSettings(){
+ Effect.Fade('seqSettings');
+}
+
+/**
+ * this function fetches the homepage dashboard
+ * @param string stuffid - the id of the dashboard widget
+ */
+function fetch_homeDB(stuffid){
+ $('refresh_'+stuffid).innerHTML=$('vtbusy_homeinfo').innerHTML;
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody: 'module=Dashboard&action=DashboardAjax&file=HomepageDB',
+ onComplete: function(response){
+ $('stuffcont_'+stuffid).style.display = 'none';
+ $('stuffcont_'+stuffid).innerHTML=response.responseText;
+ $('refresh_'+stuffid).innerHTML='';
+ Effect.Appear('stuffcont_'+stuffid);
+ }
+ }
+ );
+}
+
+/**
+ * this function initializes the homepage
+ */
+initHomePage = function(){
+ Sortable.create(
+ "MainMatrix",
+ {
+ constraint:false,tag:'div',overlap:'Horizontal',handle:'headerrow',
+ onUpdate:function(){
+ matrixarr = Sortable.serialize('MainMatrix').split("&");
+ matrixseqarr=new Array();
+ seqarr=new Array();
+ for(x=0;xstufftype=$_REQUEST['stufftype'];
+}
+
+if(!empty($_REQUEST['stufftitle'])){
+ if(strlen($_REQUEST['stufftitle'])>100){
+ $temp_str = substr($_REQUEST['stufftitle'],0,97)."...";
+ $oHomestuff->stufftitle= $temp_str;
+ }else{
+ $oHomestuff->stufftitle=$_REQUEST['stufftitle'];
+ }
+ // Remove HTML/PHP tags from the input
+ if(isset($oHomestuff->stufftitle)) {
+ $oHomestuff->stufftitle = strip_tags($oHomestuff->stufftitle);
+ }
+}
+
+if(!empty($_REQUEST['selmodule'])){
+ $oHomestuff->selmodule=$_REQUEST['selmodule'];
+}
+
+if(!empty($_REQUEST['maxentries'])){
+ $oHomestuff->maxentries=$_REQUEST['maxentries'];
+}
+
+if(!empty($_REQUEST['selFiltername'])){
+ $oHomestuff->selFiltername=$_REQUEST['selFiltername'];
+}
+
+if(!empty($_REQUEST['fldname'])){
+ $oHomestuff->fieldvalue=$_REQUEST['fldname'];
+}
+
+if(!empty($_REQUEST['txtRss'])){
+ $ooRss=new vtigerRSS();
+ if($ooRss->setRSSUrl($_REQUEST['txtRss'])){
+ $oHomestuff->txtRss=$_REQUEST['txtRss'];
+ }else{
+ return false;
+ }
+}
+
+if(!empty($_REQUEST['txtURL'])){
+ $oHomestuff->txtURL = $_REQUEST['txtURL'];
+}
+if(isset($_REQUEST['seldashbd']) && $_REQUEST['seldashbd']!=""){
+ $oHomestuff->seldashbd=$_REQUEST['seldashbd'];
+}
+
+if(isset($_REQUEST['seldashtype']) && $_REQUEST['seldashtype']!=""){
+ $oHomestuff->seldashtype=$_REQUEST['seldashtype'];
+}
+
+if(isset($_REQUEST['seldeftype']) && $_REQUEST['seldeftype']!=""){
+ $seldeftype=$_REQUEST['seldeftype'];
+ $defarr=explode(",",$seldeftype);
+ $oHomestuff->defaultvalue=$defarr[0];
+ $deftitlehash=$defarr[1];
+ $oHomestuff->defaulttitle=str_replace("#"," ",$deftitlehash);
+}
+
+$loaddetail=$oHomestuff->addStuff();
+echo $loaddetail;
+?>
diff --git a/oss/vtiger/trunk/modules/Home/HomestuffAjax.php b/oss/vtiger/trunk/modules/Home/HomestuffAjax.php
new file mode 100644
index 00000000..7f207988
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/HomestuffAjax.php
@@ -0,0 +1,192 @@
+id.'.php');
+
+$modval=trim($_REQUEST['modname']);
+$dash=trim($_REQUEST['dash']);
+if(!empty($modval)){
+ $tabid = getTabId($modval);
+ $ssql = "select vtiger_customview.*, vtiger_users.user_name from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype
+ left join vtiger_users on vtiger_customview.userid = vtiger_users.id ";
+ $ssql .= " where vtiger_tab.tabid=?";
+ $sparams = array($tabid);
+
+ if($is_admin == false){
+ $ssql .= " and (vtiger_customview.status=0 or vtiger_customview.userid = ? or vtiger_customview.status = 3 or vtiger_customview.userid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%'))";
+ array_push($sparams, $current_user->id);
+ }
+ $result = $adb->pquery($ssql, $sparams);
+
+ if($adb->num_rows($result)==0){
+ echo $mod_strings['MSG_NO_FILTERS'];
+ die;
+ }else{
+ $html = '';
+ }
+ echo $html;
+}
+
+if(!empty($dash)){
+ global $current_language;
+ $dashbd_strings = return_module_language($current_language, "Dashboard");
+ $graph_array = array("leadsource" => $dashbd_strings['leadsource'],
+ "leadstatus" => $dashbd_strings['leadstatus'],
+ "leadindustry" => $dashbd_strings['leadindustry'],
+ "salesbyleadsource" => $dashbd_strings['salesbyleadsource'],
+ "salesbyaccount" => $dashbd_strings['salesbyaccount'],
+ "salesbyuser" => $dashbd_strings['salesbyuser'],
+ "salesbyteam" => $dashbd_strings['salesbyteam'],
+ "accountindustry" => $dashbd_strings['accountindustry'],
+ "productcategory" => $dashbd_strings['productcategory'],
+ "productbyqtyinstock" => $dashbd_strings['productbyqtyinstock'],
+ "productbypo" => $dashbd_strings['productbypo'],
+ "productbyquotes" => $dashbd_strings['productbyquotes'],
+ "productbyinvoice" => $dashbd_strings['productbyinvoice'],
+ "sobyaccounts" => $dashbd_strings['sobyaccounts'],
+ "sobystatus" => $dashbd_strings['sobystatus'],
+ "pobystatus" => $dashbd_strings['pobystatus'],
+ "quotesbyaccounts" => $dashbd_strings['quotesbyaccounts'],
+ "quotesbystage" => $dashbd_strings['quotesbystage'],
+ "invoicebyacnts" => $dashbd_strings['invoicebyacnts'],
+ "invoicebystatus" => $dashbd_strings['invoicebystatus'],
+ "ticketsbystatus" => $dashbd_strings['ticketsbystatus'],
+ "ticketsbypriority" => $dashbd_strings['ticketsbypriority'],
+ "ticketsbycategory" => $dashbd_strings['ticketsbycategory'],
+ "ticketsbyuser" => $dashbd_strings['ticketsbyuser'],
+ "ticketsbyteam" => $dashbd_strings['ticketsbyteam'],
+ "ticketsbyproduct"=> $dashbd_strings['ticketsbyproduct'],
+ "contactbycampaign"=> $dashbd_strings['contactbycampaign'],
+ "ticketsbyaccount"=> $dashbd_strings['ticketsbyaccount'],
+ "ticketsbycontact"=> $dashbd_strings['ticketsbycontact'],);
+
+ $html='';
+ echo $html;
+}
+
+if(!empty($_REQUEST['primecvid'])){
+ $cvid=$_REQUEST['primecvid'];
+ $fieldmodule = vtlib_purify($_REQUEST['fieldmodname']);
+ $queryprime="select cvid,columnname from vtiger_cvcolumnlist where columnname not like '%::%' and cvid=?";
+ $result=$adb->pquery($queryprime,array($cvid));
+ global $current_language,$app_strings;
+ $fieldmod_strings = return_module_language($current_language, $fieldmodule);
+ if($adb->num_rows($result)==0){
+ echo $mod_strings['MSG_NO_FIELDS'];
+ die;
+ }else{
+ $html = '';
+ }
+ echo $html;
+}
+
+if(!empty($_REQUEST['showmaxval']) && !empty($_REQUEST['sid'])){
+ $sid=$_REQUEST['sid'];
+ $maxval=$_REQUEST['showmaxval'];
+ global $adb;
+ $query="select stufftype from vtiger_homestuff where stuffid=?";
+ $res=$adb->pquery($query, array($sid));
+ $stufftypename=$adb->query_result($res,0,"stufftype");
+ if($stufftypename=="Module"){
+ $qry="update vtiger_homemodule set maxentries=? where stuffid=?";
+ $result=$adb->pquery($qry, array($maxval, $sid));
+ }else if($stufftypename=="RSS"){
+ $qry="update vtiger_homerss set maxentries=? where stuffid=?";
+ $result=$adb->pquery($qry, array($maxval, $sid));
+ }else if($stufftypename=="Default"){
+ $qry="update vtiger_homedefault set maxentries=? where stuffid=?";
+ $result=$adb->pquery($qry, array($maxval, $sid));
+ }
+ echo "loadStuff(".$sid.",'".$stufftypename."')";
+}
+
+if(!empty($_REQUEST['dashVal'])){
+ $did=$_REQUEST['did'];
+ global $adb;
+ $qry="update vtiger_homedashbd set dashbdtype=? where stuffid=?";
+ $res=$adb->pquery($qry, array($_REQUEST['dashVal'], $did));
+ echo "loadStuff(".$did.",'DashBoard')";
+}
+
+if(!empty($_REQUEST['homestuffid'])){
+ $sid=$_REQUEST['homestuffid'];
+ global $adb;
+ $query="delete from vtiger_homestuff where stuffid=?";
+ $result=$adb->pquery($query, array($sid));
+ echo "SUCCESS";
+}
+
+//Sequencing of blocks starts
+if(!empty($_REQUEST['matrixsequence'])){
+ global $adb;
+ $sequence = explode('_',$_REQUEST['matrixsequence']);
+ for($i=count($sequence)-1, $seq=0;$i>=0;$i--, $seq++){
+ $query = 'update vtiger_homestuff set stuffsequence=? where stuffid=?';
+ $result = $adb->pquery($query, array($seq, $sequence[$i]));
+ }
+ echo "";
+}
+//Sequencing of blocks ends
+
+if(isset($_REQUEST['act']) && $_REQUEST['act'] =="hide"){
+ $stuffid=$_REQUEST['stuffid'];
+ global $adb,$current_user;
+ $qry="update vtiger_homestuff set visible=1 where stuffid=?";
+ $res=$adb->pquery($qry, array($stuffid));
+ echo "SUCCESS";
+}
+
+//saving layout here
+if(!empty($_REQUEST['layout'])){
+ global $adb, $current_user;
+
+ $sql = "delete from vtiger_home_layout where userid=?";
+ $result = $adb->pquery($sql, array($current_user->id));
+
+ $sql = "insert into vtiger_home_layout values (?, ?)";
+ $result = $adb->pquery($sql, array($current_user->id, $_REQUEST['layout']));
+ if(!$result){
+ echo "SUCCESS";
+ }
+}
+//layout save ends here
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Home/LastViewed.php b/oss/vtiger/trunk/modules/Home/LastViewed.php
new file mode 100644
index 00000000..cd2f9a0e
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/LastViewed.php
@@ -0,0 +1,46 @@
+
+
+
+get_recently_viewed($current_user->id);
+
+foreach($history as $row)
+{
+ echo <<< EOQ
+
+ ![{$row['module_name']}]($image_path{$row['module_name']}.gif) |
+ $row[item_summary] |
+
+EOQ;
+}
+?>
+
diff --git a/oss/vtiger/trunk/modules/Home/MainHomeBlock.php b/oss/vtiger/trunk/modules/Home/MainHomeBlock.php
new file mode 100644
index 00000000..6b541f22
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/MainHomeBlock.php
@@ -0,0 +1,30 @@
+assign("MOD",$mod_strings);
+$smarty->assign("APP",$app_strings);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH",$image_path);
+
+//$smarty->assign("HOME_STUFF",$homestuff_values);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->display("Home/MainHomeBlock.tpl");
+
+?>
diff --git a/oss/vtiger/trunk/modules/Home/NewBlock.php b/oss/vtiger/trunk/modules/Home/NewBlock.php
new file mode 100644
index 00000000..3d70d290
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/NewBlock.php
@@ -0,0 +1,44 @@
+assign("MOD",$mod_strings);
+$smarty->assign("APP",$app_strings);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH",$image_path);
+$homeselectedframe = $homeObj->getSelectedStuff($stuffid,$stufftype);
+
+$smarty->assign("tablestuff",$homeselectedframe);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->display("Home/MainHomeBlock.tpl");
+
+?>
diff --git a/oss/vtiger/trunk/modules/Home/SaveNotebookContents.php b/oss/vtiger/trunk/modules/Home/SaveNotebookContents.php
new file mode 100644
index 00000000..bd53ec48
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/SaveNotebookContents.php
@@ -0,0 +1,31 @@
+pquery($sql, array($contents, $current_user->id, $notebookid));
+ return true;
+}
+?>
diff --git a/oss/vtiger/trunk/modules/Home/UnifiedSearch.php b/oss/vtiger/trunk/modules/Home/UnifiedSearch.php
new file mode 100644
index 00000000..30113183
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/UnifiedSearch.php
@@ -0,0 +1,316 @@
+ $object_name){
+ if ($curModule == 'Home' || ($curModule == $module && !empty($_REQUEST['ajax']))) {
+ $focus = CRMEntity::getInstance($module);
+ if(isPermitted($module,"index") == "yes"){
+ $smarty = new vtigerCRM_Smarty;
+
+ require_once("modules/$module/language/".$current_language.".lang.php");
+ global $mod_strings;
+ global $app_strings;
+
+ $smarty->assign("MOD", $mod_strings);
+ $smarty->assign("APP", $app_strings);
+ $smarty->assign("THEME", $theme);
+ $smarty->assign("IMAGE_PATH",$image_path);
+ $smarty->assign("MODULE",$module);
+ $smarty->assign("SEARCH_MODULE",vtlib_purify($_REQUEST['search_module']));
+ $smarty->assign("SINGLE_MOD",$module);
+ $smarty->assign("SEARCH_STRING",vtlib_purify($search_val));
+
+ $listquery = getListQuery($module);
+ $oCustomView = '';
+
+ $oCustomView = new CustomView($module);
+ //Instead of getting current customview id, use cvid of All so that all entities will be found
+ //$viewid = $oCustomView->getViewId($module);
+ $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module));
+ $viewid = $adb->query_result($cv_res,0,'cvid');
+ $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
+
+ $listquery = $oCustomView->getModifiedCvListQuery($viewid,$listquery,$module);
+ if ($module == "Calendar"){
+ if (!isset($oCustomView->list_fields['Close'])){
+ $oCustomView->list_fields['Close']=array ( 'activity' => 'status' );
+ }
+ if (!isset($oCustomView->list_fields_name['Close'])){
+ $oCustomView->list_fields_name['Close']='status';
+ }
+ }
+
+ if($search_module != ''){//This is for Tag search
+ $where = getTagWhere($search_val,$current_user->id);
+ $search_msg = $app_strings['LBL_TAG_SEARCH'];
+ $search_msg .= "".to_html($search_val)."";
+ }else{ //This is for Global search
+ $where = getUnifiedWhere($listquery,$module,$search_val);
+ $search_msg = $app_strings['LBL_SEARCH_RESULTS_FOR'];
+ $search_msg .= "".to_html($search_val)."";
+ }
+
+ if($where != ''){
+ $listquery .= ' and ('.$where.')';
+ }
+
+ if(!(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')) {
+ $count_result = $adb->query($listquery);
+ $noofrows = $adb->num_rows($count_result);
+ } else {
+ $noofrows = vtlib_purify($_REQUEST['recordCount']);
+ }
+ $moduleRecordCount[$module]['count'] = $noofrows;
+
+ global $list_max_entries_per_page;
+ if(!empty($_REQUEST['start'])){
+ $start = $_REQUEST['start'];
+ if($start == 'last'){
+ $count_result = $adb->query( mkCountQuery($listquery));
+ $noofrows = $adb->query_result($count_result,0,"count");
+ if($noofrows > 0){
+ $start = ceil($noofrows/$list_max_entries_per_page);
+ }
+ }
+ if(!is_numeric($start)){
+ $start = 1;
+ } elseif($start < 0){
+ $start = 1;
+ }
+ $start = ceil($start);
+ }else{
+ $start = 1;
+ }
+
+ $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
+ $limitStartRecord = ($navigation_array['start'] - 1) * $list_max_entries_per_page;
+
+ if( $adb->dbType == "pgsql"){
+ $listquery = $listquery. " OFFSET $limitStartRecord LIMIT $list_max_entries_per_page";
+ }else{
+ $listquery = $listquery. " LIMIT $limitStartRecord, $list_max_entries_per_page";
+ }
+ $list_result = $adb->query($listquery);
+
+ $moduleRecordCount[$module]['recordListRangeMessage'] = getRecordRangeMessage($list_result, $limitStartRecord);
+
+ $info_message='&recordcount='.$_REQUEST['recordcount'].'&noofrows='.$_REQUEST['noofrows'].'&message='.$_REQUEST['message'].'&skipped_record_count='.$_REQUEST['skipped_record_count'];
+ $url_string = '&modulename='.$_REQUEST['modulename'].'&nav_module='.$module_name.$info_message;
+ $viewid = '';
+
+ $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,$module,"UnifiedSearch",$viewid);
+ $listview_header = getListViewHeader($focus,$module,"","","","global",$oCustomView);
+ $listview_entries = getListViewEntries($focus,$module,$list_result,$navigation_array,"","","","",$oCustomView);
+
+ //Do not display the Header if there are no entires in listview_entries
+ if(count($listview_entries) > 0){
+ $display_header = 1;
+ }else{
+ $display_header = 0;
+ }
+ $smarty->assign("NAVIGATION", $navigationOutput);
+ $smarty->assign("LISTHEADER", $listview_header);
+ $smarty->assign("LISTENTITY", $listview_entries);
+ $smarty->assign("DISPLAYHEADER", $display_header);
+ $smarty->assign("HEADERCOUNT", count($listview_header));
+ $smarty->assign("ModuleRecordCount", $moduleRecordCount);
+
+ $total_record_count = $total_record_count + $noofrows;
+
+ $smarty->assign("SEARCH_CRITERIA","( $noofrows )".$search_msg);
+ $smarty->assign("MODULES_LIST", $object_array);
+ $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
+
+ if(($i != 0 && empty($_REQUEST['ajax'])) || !(empty($_REQUEST['ajax'])))
+ $smarty->display("UnifiedSearchAjax.tpl");
+ else
+ $smarty->display('UnifiedSearchDisplay.tpl');
+ unset($_SESSION['lvs'][$module]);
+ $i++;
+ }
+ }
+ }
+ //Added to display the Total record count
+ if(empty($_REQUEST['ajax'])) {
+?>
+
+
".$mod_strings['ERR_ONE_CHAR']."";
+}
+
+/**
+ * Function to get the Tags where condition
+ * @param string $search_val -- entered search string value
+ * @param string $current_user_id -- current user id
+ * @return string $where -- where condition with the list of crmids, will like vtiger_crmentity.crmid in (1,3,4,etc.,)
+ */
+function getTagWhere($search_val,$current_user_id){
+ require_once('include/freetag/freetag.class.php');
+
+ $freetag_obj = new freetag();
+ $crmid_array = $freetag_obj->get_objects_with_tag_all($search_val,$current_user_id);
+
+ $where = " vtiger_crmentity.crmid IN (";
+ if(count($crmid_array) > 0){
+ foreach($crmid_array as $index => $crmid){
+ $where .= $crmid.',';
+ }
+ $where = trim($where,',').')';
+ }
+ //If there are no records has the search tag we need to add the condition like crmid is none. If dont add condition at all search will return all the values.
+ // Fix for #5571
+ else {
+ $where .= '0)';
+ }
+ return $where;
+}
+
+
+/**
+ * Function to get the the List of Searchable Modules as a combo list which will be displayed in right corner under the Header
+ * @param string $search_module -- search module, this module result will be shown defaultly
+ */
+function getSearchModulesComboList($search_module){
+ global $object_array;
+ global $app_strings;
+ global $mod_strings;
+
+ ?>
+
+
+
+ | |
+
+
+ |
+
+
+ $object_name1,$module_name2=>$object_name2,$module_name3=>$object_name3,$module_name4=>$object_name4,-----);
+ */
+function getSearchModules($filter = array()){
+ global $adb;
+ // vtlib customization: Ignore disabled modules.
+ //$sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29)';
+ $sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29) and vtiger_tab.presence != 1 and vtiger_field.presence in (0,2)';
+ // END
+ $result = $adb->pquery($sql, array());
+ while($module_result = $adb->fetch_array($result)){
+ $modulename = $module_result['name'];
+ // Do we need to filter the module selection?
+ if(!empty($filter) && is_array($filter) && !in_array($modulename, $filter)) {
+ continue;
+ }
+ // END
+ if($modulename != 'Calendar'){
+ $return_arr[$modulename] = $modulename;
+ }else{
+ $return_arr[$modulename] = 'Activity';
+ }
+ }
+ return $return_arr;
+}
+
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Home/UnifiedSearchModules.php b/oss/vtiger/trunk/modules/Home/UnifiedSearchModules.php
new file mode 100644
index 00000000..5b4ca5ee
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/UnifiedSearchModules.php
@@ -0,0 +1,43 @@
+query($sql);
+while($modulerow = $adb->fetch_array($moduleres)) {
+ if(is_admin($current_user) || isPermitted($modulerow['name'], 'DetailView') == 'yes') {
+ $modulename = $modulerow['name'];
+ $allowed_modules[$modulename] = array(
+ 'label' => getTranslatedString($modulename, $modulename),
+ 'selected' => in_array($modulename, $selected_modules)
+ );
+ }
+}
+ksort($allowed_modules);
+
+require_once('Smarty_setup.php');
+
+$smarty = new vtigerCRM_Smarty();
+$smarty->assign('MOD', $mod_strings);
+$smarty->assign('APP', $app_strings);
+$smarty->assign('THEME', $theme);
+$smarty->assign('IMAGE_PATH', "themes/$theme/images/");
+$smarty->assign('ALLOWED_MODULES', $allowed_modules);
+
+$smarty->display('UnifiedSearchModules.tpl');
+
+?>
\ No newline at end of file
diff --git a/oss/vtiger/trunk/modules/Home/chat.css b/oss/vtiger/trunk/modules/Home/chat.css
new file mode 100644
index 00000000..3c0017ca
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/chat.css
@@ -0,0 +1,232 @@
+/*
+ Copyright 2005 Rolando Gonzalez (rolosworld@gmail.com)
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+/*
+ table.chat // don't set width or height
+ thead.chat
+ tfoot.chat
+ tbody.chat
+ tr.chathea
+ tr.chatfoot
+ tr.chatbody
+ td.chathead
+ td.chathead1
+ td.chathead2
+ td.chatfoot
+ td.chatfoot1
+ td.chatfoot2
+ td.chatbody
+ td.chatbody1 // don't set width or height
+ td.chatbody2
+
+ td.chatbox // don't set width or height or overflow
+ td.chaticon
+ td.chattopic
+ td.chathide
+ td.chatclose
+
+ div.cumsg
+ div.csmsg
+ span.cunick
+*/
+*{
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 8pt;
+}
+
+table.chat,table.pchat{
+ empty-cells:show;
+}
+table.chat{
+ position:absolute;
+}
+thead.chat{
+ cursor:move;
+}
+td.chathead,td.chathead2,td.pchathead,td.pchathead2{
+ width:5px;
+ height:38px;
+ padding:0px 5px 0px 0px;
+}
+td.chathead1,td.pchathead1{
+ background-image:url(imgs/box_T.gif);
+ width:100%;
+}
+td.chathead,td.pchathead{
+ background-image:url(imgs/box_TL.gif);
+}
+td.chathead2,td.pchathead2{
+ background-image:url(imgs/box_TR.gif);
+}
+
+td.chaticon{
+ background-image:url(imgs/2tbarPrivateChat.gif);
+}
+td.chattopic{
+ background-image:url(imgs/2tbarPublicChat.gif);
+ background-repeat:no-repeat;
+ background-position:center left;
+ padding:0px 10px 0px 30px;
+ width:100%;
+}
+
+td.chattopic1{
+ padding:0px 10px 0px 5px;
+ width:100%;
+ text-align:left;
+}
+span.chatTopicNick{ font-weight:900; }
+td.chathide,td.chatclose{
+ cursor:pointer;
+}
+td.chathide{
+ background-image:url(imgs/btn_hide.gif);
+}
+td.chatclose{
+ background-image:url(imgs/btn_close.gif);
+}
+td.chaticon,td.chathide,td.chatclose{
+ height:36px;
+ width:36px;
+ padding:31px 31px 5px 0px;
+ background-repeat:no-repeat;
+ background-position:center center;
+}
+
+td.chatbody,td.chatbody2,td.pchatbody,td.pchatbody2{
+ width:5px;
+ padding:0px 5px 0px 0px;
+}
+td.chatbody,td.pchatbody{
+ background-image:url(imgs/box_ML.gif);
+}
+td.chatbody1,td.pchatbody1{
+ background-image:url(imgs/box_M.gif);
+ padding:5px 5px 5px 5px;
+ vertical-align:top;
+}
+td.chatbody2,td.pchatbody2{
+ background-image:url(imgs/box_MR.gif);
+}
+
+td.chatfoot,td.chatfoot2,td.pchatfoot,td.pchatfoot2{
+ width:5px;
+ height:60px;
+ padding:60px 5px 0px 0px;
+}
+td.chatfoot1,td.pchatfoot1{
+ background-image:url(imgs/bx_B.gif);
+}
+td.chatfoot,td.pchatfoot{
+ background-image:url(imgs/box_BL.gif);
+}
+td.chatfoot2,td.pchatfoot2{
+ background-image:url(imgs/box_BR.gif);
+}
+
+
+
+div.chatbox{
+ background-color: #FFFFFF;
+ border: 1px solid #938F86;
+ color:#000000;
+ vertical-align:top;
+}
+
+/* UList */
+span.cunick{
+ color:green;
+}
+div.cumsg,div.csmsg{
+ color:#0000ff;
+ margin:2px 2px 4px 2px;
+}
+div.csmsg{
+ color:#FF0000;
+}
+
+a.chat{
+ background-image:url(themes/images/user_icon.gif);
+ background-position:center left;
+ background-repeat:no-repeat;
+ color:#000000;
+ text-decoration:none;
+ display:block;
+ width:100px;
+ height:20px;
+ background-color:#FFFFFF;
+ padding:10px 5px 5px 30px;
+ vertical-align:middle;
+}
+a.chat:hover{
+ background-color:#DFD9CD;
+}
+
+span{
+ padding:0px;
+ margin:0px;
+}
+
+/* input */
+form.cinput{
+ display:inline;
+}
+input.cinput{
+ background-color: #FFFFFF;
+ border: 1px solid #938F86;
+ width: 100%;
+ height:20px;
+ font-size:12px;
+ padding:2px 2px 2px 2px;
+ font-weight:bold;
+ color:#333333;
+}
+table.cinput{
+ width:100%;
+}
+tr.cinput{
+
+}
+td.cinput{
+ width:100%;
+}
+td.ckeyb{
+ width:32px;
+ height:29px;
+ padding:29px 32px 5px 5px;
+ background-repeat:no-repeat;
+ background-position:center center;
+}
+td.csubmit{
+ cursor:pointer;
+ background-image:url(imgs/btn_send.gif);
+ width:63px;
+ height:32px;
+ padding:32px 63px 5px 5px;
+ background-repeat:no-repeat;
+ background-position:center center;
+}
+
+
+span.sysb{font-weight:900;}
+.chatuserlist{
+ font-size:14px;
+ text-align:left;
+ color:white;
+ background-color:#898475;
+}
diff --git a/oss/vtiger/trunk/modules/Home/chat.php b/oss/vtiger/trunk/modules/Home/chat.php
new file mode 100644
index 00000000..ae20417f
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/chat.php
@@ -0,0 +1,380 @@
+\n".mysql_error()."
\n".$query);
+ }
+ return $result;
+}
+
+/**** handler *****/
+/**
+ * Chat object
+ */
+class Chat
+{
+ // stores the string to be returned
+ var $json;
+
+ function Chat()
+ {
+ global $adb;
+ $this->json = '';
+
+ // las message id received by user
+ if(!isset($_SESSION["mlid"]))
+ {
+ $res = $adb->pquery("show table status like 'vtiger_chat_msg'", array());
+ $line = $adb->fetch_array($res);
+ if(intval($line['Auto_increment']) == 0)
+ $_SESSION["mlid"] = 0;
+ else
+ $_SESSION["mlid"] = intval($line['Auto_increment']) - 1;
+ }
+
+ // when the las user list was sended.
+ if(!isset($_SESSION["lul"]))
+ {
+ $_SESSION["lul"] = 0;
+ }
+
+ // check if user is active.
+ if(!isset($_SESSION['chat_user']))
+ {
+ $this->setUserNick();
+ }
+ else
+ {
+ $res = $adb->pquery("update vtiger_chat_users set ping=now() where session=?", array(session_id()));
+ if($adb->getAffectedRowCount($res) == 0)
+ {
+ $this->setUserNick();
+ }
+ }
+
+ switch($_POST['submode'])
+ {
+ // request all the json data at once.
+ case 'get_all':
+ global $chat_conf;
+ $this->lastMsgId();
+
+ $this->json = '[%s]';
+ $this->getAllPVChat();
+ $pvchat = $this->json;
+
+ $this->json = '[%s]';
+ $this->getPubChat();
+ $pchat = $this->json;
+
+ $this->json = '';
+ if(time() - $_SESSION["lul"] > $chat_conf['alive_time'])
+ {
+ $_SESSION["lul"] = time();
+ $this->json = '[%s]';
+ $this->getUserList();
+ }
+ $ulist = $this->json;
+
+ $tmp = array();
+ $this->json = '{%s}';
+ if(strlen($ulist) > 0)
+ $tmp[] = '"ulist":'.$ulist;
+
+ if(strlen($pvchat) > 0)
+ $tmp[] = '"pvchat":'.$pvchat;
+
+ if(strlen($pchat) > 0)
+ $tmp[] = '"pchat":'.$pchat;
+
+ $this->json = sprintf($this->json, implode(',',$tmp));
+ break;
+
+ // user is submiting a msg
+ case 'submit':
+ $this->submit($_POST['msg'],intval($_POST['to']));
+ break;
+
+ // user closed a private chat
+ case 'pvclose':
+ $this->pvClose(intval($_POST['to']));
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /**
+ * returns the JSON created
+ */
+ function getAJAX()
+ {
+ return $this->json;
+ }
+
+ /**
+ * Sets the user initial nickname.
+ */
+ function setUserNick()
+ {
+ global $current_user, $adb;
+ $res = $adb->pquery("select id from vtiger_chat_users where session=?", array(session_id()));
+ if($adb->num_rows($res) > 0)
+ {
+ $line = $adb->fetch_array($res);
+ $_SESSION['chat_user'] = $line['id'];
+ return;
+ }
+
+ $res = $adb->pquery("show table status like 'vtiger_chat_users'", array());
+ $line = $adb->fetch_array($res);
+ if(intval($line['Auto_increment']) == 0)
+ $line['Auto_increment'] = 1;
+
+ $_SESSION['chat_user'] = $line['Auto_increment'];
+
+
+ $sql = "insert into vtiger_chat_users(nick,session,ping,ip) values (?,?, now(), ?)";
+ $params = array($current_user->user_name, session_id(), $_SERVER['REMOTE_ADDR']);
+ $res = $adb->pquery($sql, $params);
+ }
+
+ /**
+ * generate the available users list
+ */
+ function getUserList()
+ {
+ global $chat_conf, $adb;
+ $tmp = '';
+ $sql = "delete from vtiger_chat_users where ((unix_timestamp(now())-unix_timestamp(ping))>?)";
+ $params = array($chat_conf['alive_time']);
+ $res = $adb->pquery($sql, $params);
+
+ $res = $adb->pquery("select id,nick from vtiger_chat_users", array());
+ if($adb->num_rows($res)==0)
+ {
+ $this->json = '';
+ return;
+ }
+
+ while($line = $adb->fetch_array($res))
+ {
+ if($line['id'] != $_SESSION['chat_user'])
+ $tmp .= '{"uid":'.$line['id'].',"nick":"'.$line['nick'].'"},';
+ }
+ $tmp = trim($tmp,',');
+ $this->json = sprintf($this->json,$tmp);
+ }
+
+ /**
+ * Sets user last post received.
+ */
+ function lastMsgId()
+ {
+ if(isset($_POST['mlid']) && intval($_POST['mlid']) > $_SESSION["mlid"])
+ $_SESSION["mlid"] = intval($_POST['mlid']);
+ }
+
+ /**
+ * generates the private chat data
+ */
+ function getAllPVChat()
+ {
+ global $chat_conf, $adb;
+ $format = '{"mlid":%s,"chat":%s,"from":"%s","msg":"%s"},';
+ $sql ="select ms.id mid,ms.chat_from mfrom,ms.chat_to mto,pv.id id,us.nick `chat_from`,ms.msg msg from vtiger_chat_users us,vtiger_chat_pvchat pv,vtiger_chat_msg ms where pv.msg=ms.id and us.id=ms.chat_from and ms.id>? and ((ms.chat_from=? and ms.chat_to>0) or (ms.chat_to=? and ms.chat_from>0)) order by ms.born limit 0, " . $chat_conf['msg_limit'];
+ $params = array($_SESSION['mlid'], $_SESSION['chat_user'], $_SESSION['chat_user']);
+ $res = $adb->pquery($sql, $params);
+
+ if($adb->num_rows($res)==0)
+ {
+ $this->json = '';
+ return;
+ }
+
+ $tmp = '';
+ while($line = $adb->fetch_array($res))
+ {
+ if($line['mfrom'] == $_SESSION['chat_user'])
+ $cid = $line['mto'];
+ else
+ $cid = $line['mfrom'];
+
+ $tmp .= sprintf($format,$line['mid'],$cid,$line['chat_from'],addslashes($line['msg']));
+ }
+ $tmp = trim($tmp,',');
+ $this->json = sprintf($this->json,$tmp);
+ }
+
+
+ /**
+ * generates the public chat data
+ * NOTE: this is alpha
+ */
+ function getPubChat()
+ {
+ global $chat_conf, $adb;
+ $format = '{"mlid":%s,"from":"%s","msg":"%s"},';
+ $sql = "select ms.id mid,ms.chat_from mfrom,ms.chat_to mto,p.id id,us.nick `chat_from`,ms.msg msg from vtiger_chat_users us,vtiger_chat_pchat p,vtiger_chat_msg ms where p.msg=ms.id and us.id=ms.chat_from and ms.id>? and ms.chat_to=0 order by ms.born limit 0," . $chat_conf['msg_limit'];
+ $params = array($_SESSION['mlid']);
+ $res = $adb->pquery($sql, $params);
+
+ if($adb->num_rows($res)==0)
+ {
+ $this->json = '';
+ return;
+ }
+
+ $tmp = '';
+ while($line = $adb->fetch_array($res))
+ {
+ $tmp .= sprintf($format,$line['mid'],$line['chat_from'],addslashes($line['msg']));
+ }
+ $tmp = trim($tmp,',');
+ $this->json = sprintf($this->json,$tmp);
+ }
+
+ /**
+ * Check for special commands on message.
+ */
+ function msgParse($msg)
+ {
+ global $adb;
+ if(strlen($msg) == 0) return '';
+ $msg = stripslashes($msg);
+
+ if($msg[0] == '\\')
+ {
+ $today_date = getdate();
+
+ $words = explode(" ",$msg);
+ switch($words[0])
+ {
+ case '\nick':
+ if(isset($words[1]) && strlen($words[1]) > 3)
+ {
+ $res = $adb->pquery("select nick from vtiger_chat_users where id=?", array($_SESSION['chat_user']));
+ $line = $adb->fetch_array($res);
+ $res = $adb->pquery("update vtiger_chat_users set nick=? where id=?", array($words[1], $_SESSION['chat_user']));
+ $msg = '\sys '.$line['nick'].' changed nick to '.$words[1].'';
+ }
+ break;
+
+ case '\help':
+ $msg = '\sys
\\\\nick "nickname" - change nick
\\\\date - date
\\\\time - time
\\\\month - month
\\\\day - weekday';
+ break;
+ case '\date':
+ $msg = '\sys Today is '.date('d-m-Y').'';
+ break;
+ case '\time':
+ $msg = '\sys The Current time is '.$today_date["hours"].':'.$today_date["minutes"].':'.$today_date["hours"].''; break;
+ case '\month':
+ $msg = '\sys '.$today_date["month"].'';
+ break;
+ case '\day':
+ $msg = '\sys '.$today_date["weekday"].'';
+ break;
+ default:
+
+ $msg = '\sys Bad command: '.$words[0];
+ break;
+ }
+ }
+ return $msg;
+ }
+
+ /**
+ * process a submited msg
+ */
+ function submit($msg, $to=0)
+ {
+ global $adb;
+ //UTF-8 support added - ding
+ $msg = utf8RawUrlDecode($msg);
+ $msg = $this->msgParse($msg);
+ $msg = htmlentities($msg);
+ if(strlen($msg) == 0) return;
+
+ //$sql = "insert into vtiger_chat_msg set chat_from=?, chat_to=?, born=now(), msg=?";
+ $sql = "insert into vtiger_chat_msg(chat_from, chat_to, born, msg) values (?,?, now(), ?)";
+ $params = array($_SESSION['chat_user'], $to, $msg);
+ $res = $adb->pquery($sql, $params);
+
+ $chat = "p";
+ if($to != 0)
+ $chat .= "v";
+
+ $res = $adb->pquery("insert into vtiger_chat_".$chat."chat set msg=LAST_INSERT_ID()", array());
+ }
+
+ /**
+ * removes the private conversation msg's because someone closed it
+ */
+ function pvClose($to)
+ {
+ global $adb;
+ $sql = "delete from vtiger_chat_msg where (`chat_from`=? and `chat_to`=?) or (`chat_from`=? and `chat_to`=?)";
+ $params = array($to, $_SESSION['chat_user'], $_SESSION['chat_user'], $to);
+ $res = $adb->pquery($sql, $params);
+ }
+}
+
+/**** caller ****/
+$chat = new Chat();
+echo $chat->getAJAX();
+?>
diff --git a/oss/vtiger/trunk/modules/Home/home_rss.php b/oss/vtiger/trunk/modules/Home/home_rss.php
new file mode 100644
index 00000000..9690e16d
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/home_rss.php
@@ -0,0 +1,128 @@
+\n");
+echo (" \n");
+echo (" \n");
+echo (" vtigerCRM Tickets\n");
+echo (" ".$site_URL."/index.php?module=Home&action=home_rss\n");
+echo (" test\n");
+echo (" \n");
+echo (" ".$current_user->user_name."\n");
+echo (" " . gmdate('D, d M Y H:i:s', time()) . " GMT\n");
+echo (" vtigerCRM\n");
+
+//retrieving notifications******************************
+//<<<<<<<<<<<<<<<< start of owner notify>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+$query = "select vtiger_crmentity.setype,vtiger_crmentity.crmid,vtiger_crmentity.smcreatorid,vtiger_crmentity.modifiedtime from vtiger_crmentity inner join vtiger_ownernotify on vtiger_crmentity.crmid=vtiger_ownernotify.crmid";
+
+$result = $adb->pquery($query, array());
+for($i=0;$i<$adb->num_rows($result);$i++){
+ $mod_notify[$i] = $adb->fetch_array($result);
+ if($mod_notify[$i]['setype']=='Accounts'){
+ $tempquery='select vtiger_accountname from vtiger_account where vtiger_accountid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $account_name=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$account_name['accountname'];
+ }else if($mod_notify[$i]['setype']=='Potentials'){
+ $tempquery='select vtiger_potentialname from vtiger_potential where vtiger_potentialid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $potential_name=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$potential_name['potentialname'];
+ }else if($mod_notify[$i]['setype']=='Contacts'){
+ $tempquery='select lastname from vtiger_contactdetails where contactid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $contact_name=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$contact_name['lastname'];
+ }else if($mod_notify[$i]['setype']=='Leads'){
+ $tempquery='select lastname from vtiger_leaddetails where leadid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $lead_name=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$lead_name['lastname'];
+ }else if($mod_notify[$i]['setype']=='SalesOrder'){
+ $tempquery='select subject from vtiger_salesorder where vtiger_salesorderid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $sales_subject=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$sales_subject['subject'];
+ }else if($mod_notify[$i]['setype']=='Orders'){
+ $tempquery='select subject from vtiger_purchaseorder where vtiger_purchaseorderid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $purchase_subject=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$purchase_subject['subject'];
+ }else if($mod_notify[$i]['setype']=='Products'){
+ $tempquery='select productname from vtiger_products where productid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $product_name=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$product_name['productname'];
+ }else if($mod_notify[$i]['setype']=='Emails'){
+ $tempquery='select subject from vtiger_activity where vtiger_activityid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $email_subject=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$email_subject['subject'];
+ }else if($mod_notify[$i]['setype']=='HelpDesk'){
+ $tempquery='select title from vtiger_troubletickets where ticketid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $HelpDesk_title=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$HelpDesk_title['title'];
+ }else if($mod_notify[$i]['setype']=='Calendar'){
+ $tempquery='select subject from vtiger_activity where vtiger_activityid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $Activity_subject=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$Activity_subject['subject'];
+ }else if($mod_notify[$i]['setype']=='Quotes'){
+ $tempquery='select subject from vtiger_quotes where quoteid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $quote_subject=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$quote_subject['subject'];
+ }else if($mod_notify[$i]['setype']=='Invoice'){
+ $tempquery='select subject from vtiger_invoice where vtiger_invoiceid=?';
+ $tempresult=$adb->pquery($tempquery, array($mod_notify[$i]['crmid']));
+ $invoice_subject=$adb->fetch_array($tempresult);
+ $notify_values[$i]=$invoice_subject['subject'];
+ }
+ //<<<<<<<<<<<<<<<< end of owner notify>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+
+ // Variable reassignment and reformatting for author
+ $author_id = $db->query_result($result,$i,'smcreatorid');
+ $entry_author = getUserName($author_id);
+ $entry_author = htmlspecialchars ($entry_author);
+
+ $entry_link = $site_URL."/index.php?modules=".$mod_notify[$i]['setype']."&action=DetailView&record=".$mod_notify[$i]['crmid'];
+ $entry_link = htmlspecialchars($entry_link);
+ $entry_time = $db->query_result($result,$i,'modifiedtime');
+
+ echo (" - \n");
+ echo (" ".$mod_notify[$i]['setype']."\n");
+ echo (" ".$entry_link."\n");
+ echo (" ".$notify_values[$i]."\n");
+ echo (" ".$entry_author."\n");
+ echo (" ".$entry_time."\n");
+ echo ("
\n");
+}
+echo (" \n");
+echo (" \n");
+?>
diff --git a/oss/vtiger/trunk/modules/Home/index.php b/oss/vtiger/trunk/modules/Home/index.php
new file mode 100644
index 00000000..d57776dd
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/index.php
@@ -0,0 +1,106 @@
+ 29 and tabid <> 16 and tabid <>10) order by name";
+
+// Performance Optimization: Re-written to ignore extension and inactive modules
+$modulenamearr = Array();
+foreach($tabrows as $resultrow) {
+ if($resultrow['isentitytype'] != '0') {
+ // Eliminate: Events, Emails
+ if($resultrow['tabid'] == '16' || $resultrow['tabid'] == '10' || $resultrow['name'] == 'Webmails') {
+ continue;
+ }
+ $modName=$resultrow['name'];
+ if(isPermitted($modName,'DetailView') == 'yes' && vtlib_isModuleActive($modName)){
+ $modulenamearr[$modName]=array($resultrow['tabid'],$modName);
+ }
+ }
+}
+ksort($modulenamearr); // We avoided ORDER BY in Query (vtlib_prefetchModuleActiveInfo)!
+// END
+
+
+//Security Check done for RSS and Dashboards
+$allow_rss='no';
+$allow_dashbd='no';
+if(isPermitted('Rss','DetailView') == 'yes' && vtlib_isModuleActive('Rss')){
+ $allow_rss='yes';
+}
+if(isPermitted('Dashboard','DetailView') == 'yes' && vtlib_isModuleActive('Dashboard')){
+ $allow_dashbd='yes';
+}
+
+$homedetails = $homeObj->getHomePageFrame();
+$maxdiv = sizeof($homedetails)-1;
+$user_name = $current_user->column_fields['user_name'];
+$buttoncheck['Calendar'] = isPermitted('Calendar','index');
+$freetag = new freetag();
+$numberofcols = getNumberOfColumns();
+
+$smarty->assign("CHECK",$buttoncheck);
+if(vtlib_isModuleActive('Calendar')){
+ $smarty->assign("CALENDAR_ACTIVE","yes");
+}
+$smarty->assign("IMAGE_PATH",$image_path);
+$smarty->assign("MODULE",'Home');
+$smarty->assign("CATEGORY",getParenttab('Home'));
+$smarty->assign("CURRENTUSER",$user_name);
+$smarty->assign("ALL_TAG",$freetag->get_tag_cloud_html("",$current_user->id));
+$smarty->assign("MAXLEN",$maxdiv);
+$smarty->assign("ALLOW_RSS",$allow_rss);
+$smarty->assign("ALLOW_DASH",$allow_dashbd);
+$smarty->assign("HOMEFRAME",$homedetails);
+$smarty->assign("MODULE_NAME",$modulenamearr);
+$smarty->assign("MOD",$mod_strings);
+$smarty->assign("APP",$app_strings);
+$smarty->assign("THEME", $theme);
+$smarty->assign("LAYOUT", $numberofcols);
+$widgetBlockSize = PerformancePrefs::getBoolean('HOME_PAGE_WIDGET_GROUP_SIZE', 12);
+$smarty->assign('widgetBlockSize', $widgetBlockSize);
+
+$smarty->display("Home/Homestuff.tpl");
+
+?>
diff --git a/oss/vtiger/trunk/modules/Home/js/ajax.js b/oss/vtiger/trunk/modules/Home/js/ajax.js
new file mode 100644
index 00000000..ae435a9f
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/js/ajax.js
@@ -0,0 +1,92 @@
+/*
+ Copyright 2005 Rolando Gonzalez (rolosworld@gmail.com)
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+function getRequester()
+{
+ try
+ {
+ if(window.XMLHttpRequest)
+ {
+ return new XMLHttpRequest();
+ }
+ else if(window.ActiveXObject)
+ {
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ }
+ catch (e)
+ {
+ alert("You need a browser which supports an XMLHttpRequest Object.\nMozilla build 0.9.5 has this Object and IE5 and above.");
+ }
+};
+
+/*
+onreadystatechange Event handler for an event that fires at every state change
+readyState Object status integer:
+0 = uninitialized
+1 = loading
+2 = loaded
+3 = interactive
+4 = complete
+responseText String version of data returned from server process
+responseXML DOM-compatible document object of data returned from server process
+status Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK"
+statusText String message accompanying the status code
+*/
+function Ajax(cb)
+{
+ var me = this;
+ this.requester = getRequester();
+
+ if(cb)
+ this.callback = cb;
+ else
+ this.callback = function(req)
+ {
+ return eval(req.responseText);
+ };
+
+ this.requester.onreadystatechange = function(){
+ switch(me.requester.readyState)
+ {
+ case 1:
+ case 2:
+ case 3:
+ break;
+ case 4:
+ var response = me.callback(me.requester);
+ break;
+ default:
+ alert("Error");
+ break;
+ }
+ };
+
+ this.state = function()
+ {
+ return me.requester.readyState;
+ };
+
+ this.process = function(url, parameters){
+ me.requester.open("POST", url, true);
+ me.requester.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ me.requester.setRequestHeader("Content-length", parameters.length);
+ //me.requester.setRequestHeader("Connection", "close");
+ me.requester.send(parameters);
+ };
+};
diff --git a/oss/vtiger/trunk/modules/Home/js/chat.js b/oss/vtiger/trunk/modules/Home/js/chat.js
new file mode 100644
index 00000000..b19d1fde
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/js/chat.js
@@ -0,0 +1,476 @@
+/*
+ Copyright 2005 Rolando Gonzalez (rolosworld@gmail.com)
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+var chats = new Array(); // private chats opened
+var users = new Array(); // users list
+var chat_data = null;
+var mlid = 0; //msg last id
+var DEBUG = false;
+var PRIVATES = true;
+var PUBLIC = true;
+
+function getNick(uid)
+{
+ for(var i in users)
+ {
+ if(users[i].uid == uid)
+ return users[i].nick;
+ }
+ return null;
+};
+
+function resetChatsZ()
+{
+ for(var i = 0; i < chats.length; i++)
+ if(chats[i])
+ chats[i].win.table.style.zIndex = chats[i].win.z;
+};
+
+function debug(dib,msg)
+{
+ if(!DEBUG) return;
+ if(document.getElementById(dib))
+ document.getElementById(dib).innerHTML = msg;
+ else
+ alert(msg);
+};
+
+// initialize chat connection.
+function Chat(conf)
+{
+ var me = this;
+ this.pcid = conf["pchatid"]?conf["pchatid"]:null;
+ this.dt = conf["dt"]?conf["dt"]:1000;
+ this.ulid = conf["ulid"]?conf["ulid"]:null;
+ this.w = conf["width"]?conf["width"]:"400px";
+ this.h = conf["height"]?conf["height"]:"300px";
+ this.ulist = null;
+
+ if(this.pcid)
+ {
+ chats[0] = new PubChat(this.dt,this.w,this.h);
+ document.getElementById(this.pcid).appendChild(chats[0].get());
+ }
+
+ // evaluate the returned json
+ this.callback = function(response)
+ {
+ me.ajax = null;
+ try{
+ me.doRefresh(response.responseText);
+ }catch(e){
+ debug("debug","Chat Error: "+response.responseText);
+ clearInterval(me.interv);
+ debug("debug",e.toString());
+ debug("debug",e.filename+":"+e.lineNumber);
+ return;
+ }
+ me.ajax = new Ajax(me.callback);
+ debug("debug",response.responseText);
+ window.status=Date();
+ };
+
+ this.doRefresh = function(response)
+ {
+ if(!me.ulist)
+ me.ulist = new UList(me.dt,me.ulid,me.w,me.h);
+ chat_data = eval("("+response+")");
+ me.ulist.refresh();
+ me.refreshChats();
+ };
+
+ this.ajax = new Ajax(me.callback);
+
+ // start the ajax request for the chat data
+ this.refresh = function()
+ {
+ if(me.ajax.state() == 0)
+ me.ajax.process("index.php?mode=chat&module=Home&action=chat","submode=get_all&mlid="+mlid);
+ };
+ this.interv = setInterval(me.refresh,me.dt);
+
+ this.refreshChats = function()
+ {
+ if(chat_data.pvchat)
+ {
+ cnum = 0;
+ for(var i in chat_data.pvchat)
+ {
+ cnum = chat_data.pvchat[i].chat;
+ if(!chats[cnum])
+ chats[cnum] = new PrivChat(me.dt,cnum,me.w,me.h);
+
+ if(mlid < chat_data.pvchat[i].mlid)
+ mlid = chat_data.pvchat[i].mlid;
+
+ if(chat_data.pvchat[i].msg.substr(0,5) == "\\sys ")
+ {
+ chats[cnum].appendSysMsg(chat_data.pvchat[i].msg.substr(5));
+ }
+ else
+ chats[cnum].appendMsg(chat_data.pvchat[i].from,chat_data.pvchat[i].msg);
+ }
+ chat_data.pvchat = null;
+ }
+
+ if(PUBLIC && chat_data.pchat)
+ {
+ for(var i in chat_data.pchat)
+ {
+ if(mlid < chat_data.pchat[i].mlid)
+ mlid = chat_data.pchat[i].mlid;
+
+ if(!chats[0])
+ continue;
+
+ if(chat_data.pchat[i].msg.substr(0,5) == "\\sys ")
+ {
+ chats[0].appendSysMsg(chat_data.pchat[i].msg.substr(5));
+ }
+ else
+ chats[0].appendMsg(chat_data.pchat[i].from,chat_data.pchat[i].msg);
+ }
+ chat_data.pchat = null;
+ }
+ };
+};
+
+// User list handler
+function UList(dt,ulid,w,h)
+{
+ var me = this;
+ this.w = w;
+ this.h = h;
+ this.dt = dt; // delta time to sleep the requests.
+ this.ulid = ulid; // user list ul tag id.
+ this.interv = null;
+
+ // updates the users list on the html
+ this.refreshList = function()
+ {
+ if(!document.getElementById(me.ulid))
+ {
+ clearInterval(me.interv);
+ return;
+ }
+
+ while(document.getElementById(me.ulid).firstChild)
+ document.getElementById(me.ulid).removeChild(document.getElementById(me.ulid).firstChild);
+
+ if(users)
+ {
+ var li;
+ var a;
+ var user;
+ for(var i in users)
+ {
+ user = users[i];
+ li = document.createElement("span");
+ a = document.createElement("a");
+ a.appendChild(document.createTextNode(user.nick));
+ a.setAttribute("href","#");
+ a.className = "chat";
+ if(PRIVATES)
+ a.onclick = me.newPriv(me.dt,user.uid);
+
+ li.appendChild(a);
+ document.getElementById(me.ulid).appendChild(li);
+ }
+ //var date = new Date();
+ //window.status=date.toString();
+ }
+ };
+
+ // higher order stuff
+ this.newPriv = function(dt,uid)
+ {
+ return function()
+ {
+ if(!chats[uid])
+ {
+ resetChatsZ();
+ chats[uid] = new PrivChat(dt,uid,me.w,me.h);
+ }
+ return false;
+ };
+ };
+
+ // check if theres a new user list
+ this.refresh = function()
+ {
+ //users = null;
+ if(chat_data.ulist)
+ {
+ users = chat_data.ulist;
+ me.refreshList();
+ }
+ chat_data.ulist = null;
+ };
+};
+
+//////////////////////////////////////////////////////////
+// Input handler
+function chatInput(to)
+{
+ var me = this;
+ this.to = to?to:null;
+ this.input = document.createElement("input");
+ this.input.className = "cinput";
+ this.input.setAttribute("type","text");
+ this.input.setAttribute("name","input");
+
+ var table = document.createElement("table");
+ //table.border = "1";
+ var tbody = table.appendChild(document.createElement("tbody"));
+ var tr = tbody.appendChild(document.createElement("tr"));
+ var td = tr.appendChild(document.createElement("td"));
+ var td1 = tr.appendChild(document.createElement("td"));
+ var td2 = tr.appendChild(document.createElement("td"));
+
+ table.className = "cinput";
+ tbody.className = "cinput";
+ tr.className = "cinput";
+ td.className = "ckeyb";
+ td1.className = "cinput";
+ td2.className = "csubmit";
+
+ this.input = td1.appendChild(this.input);
+ td2.onclick = function()
+ {
+ var ajax = new Ajax(me.callback);
+ ajax.process("index.php?mode=chat&module=Home&action=chat","submode=submit&msg="+escapeAll(me.input.value)+(me.to?"&to="+me.to:""));
+
+ me.input.value = "";
+ me.input.focus();
+ return false;
+ };
+
+ this.form = document.createElement("form");
+ this.form.className = "cinput";
+
+ this.form.appendChild(table);
+ this.form.onsubmit = function()
+ {
+ var ajax = new Ajax(me.callback);
+ ajax.process("index.php?mode=chat&module=Home&action=chat","submode=submit&msg="+escapeAll(me.input.value)+(me.to?"&to="+me.to:""));
+ me.input.value = "";
+ me.input.focus();
+ return false;
+ };
+
+ this.setFocus = function()
+ {
+ me.input.focus();
+ };
+
+ // evaluate the returned json
+ this.callback = function(response)
+ {
+ response = response.responseText;
+ try{
+ if(response)
+ debug("debug",response);
+ }catch(e){
+ debug("debug","chatInput Error: "+response);
+ }
+ };
+
+ this.get = function()
+ {
+ return me.form;
+ };
+};
+
+//////////////////////////////////////////////////////////
+// Private chat handler / abre ventana de usurio + usuario
+function PrivChat(dt,to,w,h)
+{
+ var me = this;
+ this.dt = dt; // delta time to sleep the requests.
+ this.to = to; // private chat the other user id
+ this.input = new chatInput(to);
+ this.toNick = getNick(to);
+
+ var conf = new Array();
+ conf["topic"] = "Private chat with "+me.toNick+"";
+ conf["class"] = "chat";
+ conf["width"] = w;
+ conf["height"] = h;
+ conf["drag"] = true;
+
+ this.win = new cssWindow(conf);
+
+ // move z+1..crappy way to send above others
+ this.win.table.onDragStart = function()
+ {
+ resetChatsZ();
+ chats[me.to].win.table.style.zIndex++;
+ };
+
+ this.win.cb = function()
+ {
+ me.ajax = new Ajax(me.callback);
+ me.ajax.process("index.php?mode=chat&module=Home&action=chat","submode=pvclose&to="+me.to);
+ chats[me.to]=null;
+ };
+
+ this.cbox = this.win.setBody(document.createElement("div"));
+ this.cbox.style.width = "100%";
+ this.cbox.style.height = "100%";
+ this.cbox.style.overflow = "auto";
+ this.cbox.className = "chatbox";
+
+ // Draws the top of the window
+ this.getHead = function()
+ {
+ var t = document.createElement("table");
+ t.style.width="100%";t.cellSpacing="0";t.cellPadding="0";
+ var tb = t.appendChild(document.createElement("tbody"));
+ var tr = tb.appendChild(document.createElement("tr"));
+ var td = tr.appendChild(document.createElement("td"));
+ td.className = "chaticon";
+ td = tr.appendChild(document.createElement("td"));
+ td.className = "chattopic1";
+ td.innerHTML = me.win.topic;
+ var hide = tr.appendChild(document.createElement("td"));
+ hide.className = "chathide";
+ hide.onclick = me.win.doHide;
+ var close = tr.appendChild(document.createElement("td"));
+ close.className = "chatclose";
+ close.onclick = me.win.doClose;
+ return t;
+ };
+
+ this.win.setHead(this.getHead());
+ this.win.setFoot(this.input.get());
+
+
+ // updates the chat on the html
+ this.appendMsg = function(from,msg)
+ {
+ var div;
+ var span;
+
+ span = document.createElement("span");
+ span.appendChild(document.createTextNode(from+": "));
+ span.className = "cunick";
+
+ div = document.createElement("div");
+ div.className = "cumsg";
+
+ div.appendChild(span);
+ div.innerHTML+=msg;
+ me.cbox.appendChild(div);
+ me.cbox.scrollTop=me.cbox.scrollHeight;
+ };
+
+ // updates the chat on the html
+ this.appendSysMsg = function(msg)
+ {
+ var div;
+ div = document.createElement("div");
+ div.className = "csmsg";
+ div.innerHTML+=msg;
+ me.cbox.appendChild(div);
+ me.cbox.scrollTop=me.cbox.scrollHeight;
+ };
+
+ this.win.show();
+ this.input.setFocus();
+};
+
+//////////////////////////////////////////////////////////
+// Public chat handler / abre ventana de usurio + usuario
+function PubChat(dt,w,h)
+{
+ var me = this;
+ this.dt = dt; // delta time to sleep the requests.
+ this.to = 0; // public chat the other user id
+ this.input = new chatInput(this.to);
+
+ var conf = new Array();
+ conf["topic"] = "Public Chat";
+ conf["class"] = "pchat";
+ conf["width"] = w;
+ conf["height"] = h;
+ conf["drag"] = false;
+
+ this.win = new cssWindow(conf);
+
+ this.cbox = this.win.setBody(document.createElement("div"));
+ this.cbox.style.width = "100%";
+ this.cbox.style.height = "100%";
+ this.cbox.style.overflow = "auto";
+ this.cbox.className = "chatbox";
+
+ // Draws the top of the window
+ this.getHead = function()
+ {
+ var t = document.createElement("table");
+ t.style.width="100%";t.cellSpacing="0";t.cellPadding="0";
+ var tb = t.appendChild(document.createElement("tbody"));
+ var tr = tb.appendChild(document.createElement("tr"));
+ var td = tr.appendChild(document.createElement("td"));
+ td.className = "chattopic";
+ td.appendChild(document.createTextNode(me.win.topic));
+ var hide = tr.appendChild(document.createElement("td"));
+ hide.className = "chathide";
+ hide.onclick = me.win.doHide;
+
+ return t;
+ };
+
+ this.win.setHead(this.getHead());
+ this.win.setFoot(this.input.get());
+
+ // updates the chat on the html
+ this.appendMsg = function(from,msg)
+ {
+ var div;
+ var span;
+
+ span = document.createElement("span");
+ span.appendChild(document.createTextNode(from+": "));
+ span.className = "cunick";
+
+ div = document.createElement("div");
+ div.className = "cumsg";
+
+ div.appendChild(span);
+ div.innerHTML+=msg;
+ me.cbox.appendChild(div);
+ me.cbox.scrollTop=me.cbox.scrollHeight;
+ };
+
+ // updates the chat on the html
+ this.appendSysMsg = function(msg)
+ {
+ var div;
+ div = document.createElement("div");
+ div.className = "csmsg";
+ div.innerHTML+=msg;
+ me.cbox.appendChild(div);
+ me.cbox.scrollTop=me.cbox.scrollHeight;
+ };
+
+ this.get = function()
+ {
+ me.input.setFocus();
+ return me.win.get();
+ };
+};
diff --git a/oss/vtiger/trunk/modules/Home/js/css-window_p.js b/oss/vtiger/trunk/modules/Home/js/css-window_p.js
new file mode 100644
index 00000000..15fe51ae
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/js/css-window_p.js
@@ -0,0 +1 @@
+eval(function(p,a,c,k,e,d){e=function(c){return(c'New Contact',
+'LBL_FIRST_NAME'=>'First Name:',
+'LBL_LAST_NAME'=>'Last Name:',
+'LBL_LIST_LAST_NAME'=>'Last Name',
+'LBL_ACCOUNT_NAME'=>'Account Name:',
+'LBL_LIST_ACCOUNT_NAME'=>'Account Name',
+'LBL_PHONE'=>'Phone:',
+'LBL_EMAIL_ADDRESS'=>'Email:',
+'LBL_TOTAL'=>'Total : ',
+
+'LBL_MY_HOME'=>'My Home',
+'LBL_MODIFIED_TIME'=>'Modified Time',
+'LBL_LOGIN_ID'=>'ID',
+'LBL_MODIFIED_BY'=>'Modified By',
+'LBL_TYPE'=>'Type',
+
+'LBL_PIPELINE_FORM_TITLE'=>'My Pipeline',
+
+'ERR_ONE_CHAR'=>'Please enter at least one letter or number for your search ...',
+
+'LBL_OPEN_TASKS'=>'My Open Tasks',
+
+'LBL_LEADS_BY_SOURCE'=>'Leads By Source',
+'LBL_LEADS_BY_STATUS'=>'Leads By Status',
+
+'LBL_UPCOMING_EVENTS'=>'Upcoming Activities',
+'LBL_PENDING_EVENTS'=>'Pending Activities',
+'LBL_SINGLE_PENDING_EVENT'=>'Event for Last Ten Days',
+'LBL_MULTIPLE_PENDING_EVENTS'=>'Events for Last Ten Days',
+
+'recordsforuser'=>'Records for',
+
+'Today'=>'Today',
+'This Week'=>'This Week',
+'This Month'=>'This Month',
+'This Year'=>'This Year',
+'Last Week'=>'Last Week',
+'Last 2 Days'=>'Last 2 Days',
+'Last Ten Days'=>'Last Ten Days',
+
+// Added/Updated for vtiger CRM 5.0.4
+'TITLE_AJAX_CSS_POPUP_CHAT'=>'Ajax Css-Popup chat',
+'User List'=>'User List',
+
+// Added after 5.0.4 GA
+
+//ADDED for Home Page Customization
+'LBL_HOME_MODULE' => 'Module',
+'LBL_HOME_RSS' => 'RSS',
+'LBL_HOME_DASHBOARD' => 'Dashboard',
+'LBL_HOME_STUFFTITLE'=>'Window Title',
+'LBL_HOME_SHOW'=>'Show',
+'LBL_HOME_FILTERBY'=>'Filter By',
+'LBL_HOME_Fields'=>'Fields To Show
(select any two)',
+'LBL_HOME_PRESSCTRL'=>'(Press "Ctrl"
for multiple selection)',
+'LBL_HOME_RSSURL'=>'RSS URL',
+'LBL_HOME_DASHBOARD_NAME'=>'DashBoard Name',
+'LBL_HOME_DASHBOARD_TYPE'=>'DashBoard Type',
+'LBL_HOME_HORIZONTAL_BARCHART'=>'Horizontal Bar Chart',
+'LBL_HOME_VERTICAL_BARCHART'=>'Vertical Bar Chart',
+'LBL_HOME_PIE_CHART'=>'Pie Chart',
+'LBL_HOME_ITEMS'=>'item(s)',
+'LBL_MORE'=>'More',
+'LBL_SCROLL'=>'Scroll',
+
+// vtiger CRM News
+'LBL_NEWS_NO'=>'No news',
+
+//added for home page changes
+'LBL_NOTEBOOK'=>'Notebook',
+'LBL_NOTEBOOK_TITLE'=>'Double-click to edit.',
+'LBL_NOTEBOOK_SAVE_TITLE'=>'Click anywhere else on the page to save.',
+
+'LBL_URL'=>'Website',
+'LBL_HOME_LAYOUT'=>'Change layout',
+'LBL_NUMBER_OF_COLUMNS'=>'Number of columns',
+'LBL_TWO_COLUMN'=>'Two Columns',
+'LBL_THREE_COLUMN'=>'Three Columns',
+'LBL_FOUR_COLUMN'=>'Four Columns',
+// END
+
+// Default home page widget's title
+'Top Accounts'=>'Top Accounts',
+'Top Potentials'=>'Top Potentials',
+'Top Quotes'=>'Top Quotes',
+'Top Trouble Tickets'=>'Top Trouble Tickets',
+'Top Invoices'=>'Top Invoices',
+'Top Sales Orders'=>'Top Sales Orders',
+'Top Purchase Orders'=>'Top Purchase Orders',
+'My New Leads'=>'My New Leads',
+'Key Metrics'=>'Key Metrics',
+'My Group Allocation'=>'My Group Allocation',
+'My Recent FAQs'=>'My Recent FAQs',
+'Upcoming Activities'=>'Upcoming Activities',
+'Pending Activities'=>'Pending Activities',
+'Home Page Dashboard'=>'Home Page Dashboard',
+'Tag Cloud'=>'Tag Cloud',
+
+'MSG_NO_FILTERS' => 'No Filters Available',
+'MSG_NO_FIELDS' => 'No Fields Available',
+
+);
+
+?>
diff --git a/oss/vtiger/trunk/modules/Home/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Home/language/zh_cn.lang.php
new file mode 100644
index 00000000..b272887d
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/language/zh_cn.lang.php
@@ -0,0 +1,127 @@
+'新增�系人',
+'LBL_FIRST_NAME'=>'姓�:',
+'LBL_LAST_NAME'=>'姓�:',
+'LBL_LIST_LAST_NAME'=>'姓�:',
+'LBL_ACCOUNT_NAME'=>'客户�称:',
+'LBL_LIST_ACCOUNT_NAME'=>'客户�称',
+'LBL_PHONE'=>'电�:',
+'LBL_EMAIL_ADDRESS'=>'电å�邮件:',
+'LBL_TOTAL'=>'总计:',
+
+'LBL_MY_HOME'=>'我的首页',
+'LBL_MODIFIED_TIME'=>'异动时间',
+'LBL_LOGIN_ID'=>'代�',
+'LBL_MODIFIED_BY'=>'修改者',
+'LBL_TYPE'=>'类型',
+
+'LBL_PIPELINE_FORM_TITLE'=>'我的统计图表',
+
+'ERR_ONE_CHAR'=>'请至少输入1个å—符以上的å�·ç �,以供æ�œå¯» ...',
+
+'LBL_OPEN_TASKS'=>'我的进行ä¸ä»»åŠ¡',
+
+'LBL_LEADS_BY_SOURCE'=>'准客户��',
+'LBL_LEADS_BY_STATUS'=>'准客户状�',
+
+'LBL_UPCOMING_EVENTS'=>'未�事件',
+'LBL_PENDING_EVENTS'=>'暂�事件',
+'LBL_SINGLE_PENDING_EVENT'=>'最近�天事件',
+'LBL_MULTIPLE_PENDING_EVENTS'=>'最近�天事件',
+
+'recordsforuser'=>'资料于',
+
+'Today'=>'今天',
+'This Week'=>'这个星期',
+'This Month'=>'这个月',
+'This Year'=>'今年',
+'Last Week'=>'上星期',
+'Last 2 Days'=>'过去两天',
+'Last Ten Days'=>'过去�天',
+
+// Added/Updated for vtiger CRM 5.0.4
+'TITLE_AJAX_CSS_POPUP_CHAT'=>'员工�天室',
+'User List'=>'使用者列表',
+
+// Added after 5.0.4 GA
+
+//ADDED for Home Page Customization
+'LBL_HOME_MODULE'=>'模�',
+'LBL_HOME_RSS'=>'RSS',
+'LBL_HOME_DASHBOARD'=>'图表',
+'LBL_HOME_STUFFTITLE'=>'窗å�£æ ‡é¢˜',
+'LBL_HOME_SHOW'=>'显示',
+'LBL_HOME_FILTERBY'=>'过滤',
+'LBL_HOME_Fields'=>'è¦�æ˜¾ç¤ºçš„å—æ®µ
(选择任何两个)',
+'LBL_HOME_PRESSCTRL'=>'(如需多个选择请按“ Ctrl � 键)',
+'LBL_HOME_RSSURL'=>'RSS URL',
+'LBL_HOME_DASHBOARD_NAME'=>'图表�称',
+'LBL_HOME_DASHBOARD_TYPE'=>'图表类型',
+'LBL_HOME_HORIZONTAL_BARCHART'=>'横�柱状图',
+'LBL_HOME_VERTICAL_BARCHART'=>'垂直柱状图',
+'LBL_HOME_PIE_CHART'=>'饼图',
+'LBL_HOME_ITEMS'=>'项目',
+'LBL_MORE'=>'更多',
+'LBL_SCROLL'=>'滚动',
+
+// vtiger CRM News
+'LBL_NEWS_NO'=>'没有新闻',
+
+//added for home page changes
+'LBL_NOTEBOOK'=>'笔记本',
+'LBL_NOTEBOOK_TITLE'=>'å�Œå‡»è¿›å…¥ç¼–åŠ çŠ¶æ€�.',
+'LBL_NOTEBOOK_SAVE_TITLE'=>'点击页é�¢å…¶ä»–部分进行ä¿�å˜.',
+
+'LBL_URL'=>'网站',
+'LBL_HOME_LAYOUT'=>'�更版�',
+'LBL_NUMBER_OF_COLUMNS'=>'列数',
+'LBL_TWO_COLUMN'=>'两列',
+'LBL_THREE_COLUMN'=>'三列',
+'LBL_FOUR_COLUMN'=>'四列',
+// END
+
+// Default home page widget's title
+'Top Accounts'=>'最新客户',
+'Top Potentials'=>'最新潜在机会',
+'Top Quotes'=>'最新报价�',
+'Top Trouble Tickets'=>'最新报修记录',
+'Top Invoices'=>'最新�票',
+'Top Sales Orders'=>'最新订�',
+'Top Purchase Orders'=>'最新采è´è®¢å�•',
+'My New Leads'=>'最新潜在客户',
+'Key Metrics'=>'å…³é”®æŒ‡æ ‡',
+'My Group Allocation'=>'我的群组分�',
+'My Recent FAQs'=>'最新常�问题',
+'Upcoming Activities'=>'近期活动',
+'Pending Activities'=>'�将进行的活动',
+'Home Page Dashboard'=>'首页图表',
+'Tag Cloud'=>'å¸¸ç”¨æ ‡ç¾',
+
+'MSG_NO_FILTERS'=>'æ— è¿‡æ»¤å™¨å�¯ç”¨',
+'MSG_NO_FIELDS'=>'æ— å�¯ç”¨å—段',
+
+);
+
+?>
diff --git a/oss/vtiger/trunk/modules/Home/vtchat.php b/oss/vtiger/trunk/modules/Home/vtchat.php
new file mode 100644
index 00000000..21eb3fa1
--- /dev/null
+++ b/oss/vtiger/trunk/modules/Home/vtchat.php
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+
+
+
+
+ |
+ |
+ |
+
+
+
+
+
+ | |
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+