[Vtigercrm-commits] [vtiger-commits] r8049 - in /vtigercrm/trunk: Smarty/templates/HomePage.tpl modules/Dashboard/HomepageDB.php modules/Home/index.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Sat Jul 15 03:17:38 EDT 2006


Author: richie
Date: Sat Jul 15 01:17:31 2006
New Revision: 8049

Log:
home page dashboard has been ajaxified

Modified:
    vtigercrm/trunk/Smarty/templates/HomePage.tpl
    vtigercrm/trunk/modules/Dashboard/HomepageDB.php
    vtigercrm/trunk/modules/Home/index.php

Modified: vtigercrm/trunk/Smarty/templates/HomePage.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/HomePage.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/HomePage.tpl Sat Jul 15 01:17:31 2006
@@ -165,12 +165,12 @@
 		{else}
                         <div class="MatrixLayer" style="float:left;width:61%;" id="homepagedb">
                         <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0" class="small">
-			<tr style="cursor:move;height:30px;">
-				<td align="left" style="border-bottom:1px solid #666666;"><b>{$APP.LBL_HOMEPAGE_DASHBOARD}</b></td>
+			<tr style="cursor:move;">
+				<td align="left" style="border-bottom:1px solid #666666;height:32px;"><b>{$APP.LBL_HOMEPAGE_DASHBOARD}</b></td>
 				<td align="right" style="border-bottom:1px solid #666666;"><img src="{$IMAGE_PATH}uparrow.gif" align="absmiddle" /></td>
 		         </tr>
-                         <tr align="left"><td>
-                                {$tabledetail}
+			<tr align="center"><td id="dashborad_cont" colspan="2" style="height:227px;">&nbsp;
+                                
                         </td></tr>
                         </table>
 			</div>
@@ -271,18 +271,38 @@
 		});
 	 
 		//new Sortable.create('MainMatrix','div');
+
+function fetch_homeDB()
+{
+	new Ajax.Request(
+		'index.php',
+		{queue: {position: 'end', scope: 'command'},
+			method: 'post',
+			postBody: 'module=Dashboard&action=DashboardAjax&file=HomepageDB',
+			onComplete: function(response)
+			{
+				$("dashborad_cont").style.display = 'none';
+				$("dashborad_cont").innerHTML=response.responseText;
+				Effect.Appear("dashborad_cont");
+			}
+		}
+	);
+}
 </script>
 {/literal}
 <script>
 function showhide(tab)
 {ldelim}
-//alert(document.getElementById(tab))
 var divid = document.getElementById(tab);
 if(divid.style.display!='none')
 	hide(tab)
 else
 	show(tab)
 {rdelim}
+
+{if $IS_HOMEDASH eq 'true'}
+fetch_homeDB();
+{/if}
 </script>
 
 	

Modified: vtigercrm/trunk/modules/Dashboard/HomepageDB.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/HomepageDB.php (original)
+++ vtigercrm/trunk/modules/Dashboard/HomepageDB.php Sat Jul 15 01:17:31 2006
@@ -1,62 +1,59 @@
-<?php
-/*********************************************************************************
-** 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.
-*
- ********************************************************************************/
-require_once("modules/Dashboard/Entity_charts.php");
-/**
- * Function to get Dashboard in homepage
- * return the graph - $sHTML
- */
-function getHomepageDB()
-{
-	global $current_user,$user_id,$date_start,$end_date,$tmp_dir,$mod_strings;
-	$type='recordsforuser';
-	if(!$is_admin)
-		$homepagedb_query = "select vtiger_crmentity.* from vtiger_crmentity where vtiger_crmentity.smownerid=".$current_user->id." and vtiger_crmentity.setype in ('Accounts','Contacts','Leads','Potentials','Products','Quotes','Invoice','PurchaseOrder','SalesOrder','Activities','HelpDesk','Campaigns')";
-	else	
-		$homepagedb_query = "select vtiger_crmentity.* from vtiger_crmentity where vtiger_crmentity.setype in ('Accounts','Contacts','Leads','Potentials','Products','Quotes','Invoice','PurchaseOrder','SalesOrder','Activities','HelpDesk','Campaigns')";
-	$graph_by="setype";
-	$graph_title=$mod_strings['recordsforuser'].' '.$current_user->user_name;
-	$module="Home";
-	$where="";
-	$query=$homepagedb_query;
-
-	//Giving the Cached image name	
-	$cache_file_name=abs(crc32($user_id))."_".$type."_".crc32($date_start.$end_date).".png";
-        $html_imagename=$graph_by; //Html image name for the graph
-	$graph_details=module_Chart($user_id,$date_start,$end_date,$query,$graph_by,$graph_title,$where,$module,$type);
-	if($graph_details!=0)
-        {
-                $name_val=$graph_details[0];
-                $cnt_val=$graph_details[1];
-                $graph_title=$graph_details[2];
-                $target_val=$graph_details[3];
-                $graph_date=$graph_details[4];
-                $urlstring=$graph_details[5];
-                $cnt_table=$graph_details[6];
-	       	$test_target_val=$graph_details[7];
-
-                $width=425;
-                $height=225;
-                $top=30;
-                $left=140;
-                $bottom=120;
-                $title=$graph_title;
-		$sHTML = render_graph($tmp_dir."vert_".$cache_file_name,$html_imagename."_vert",$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,"vertical");
-		return $sHTML;
-		
-        }
-	else
-	{
-	
-	}
-}
-
-
-?>
+<?php
+/*********************************************************************************
+** 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.
+*
+ ********************************************************************************/
+require_once("modules/Dashboard/Entity_charts.php");
+/**
+ * Function to get Dashboard in homepage
+ * return the graph - $sHTML
+ */
+	global $current_user,$user_id,$date_start,$end_date,$tmp_dir,$mod_strings;
+	$type='recordsforuser';
+	if(!$is_admin)
+		$homepagedb_query = "select vtiger_crmentity.* from vtiger_crmentity where vtiger_crmentity.smownerid=1 and vtiger_crmentity.setype in ('Accounts','Contacts','Leads','Potentials','Products','Quotes','Invoice','PurchaseOrder','SalesOrder','Activities','HelpDesk','Campaigns') and vtiger_crmentity.deleted=0";
+	else	
+		$homepagedb_query = "select vtiger_crmentity.* from vtiger_crmentity where vtiger_crmentity.setype in ('Accounts','Contacts','Leads','Potentials','Products','Quotes','Invoice','PurchaseOrder','SalesOrder','Activities','HelpDesk','Campaigns') and vtiger_crmentity.deleted=0";
+	$graph_by="setype";
+	$graph_title=$mod_strings['recordsforuser'].' '.$current_user->user_name;
+	$module="Home";
+	$where="";
+	$query=$homepagedb_query;
+
+	//Giving the Cached image name	
+	$cache_file_name=abs(crc32($user_id))."_".$type."_".crc32($date_start.$end_date).".png";
+        $html_imagename=$graph_by; //Html image name for the graph
+	$graph_details=module_Chart($user_id,$date_start,$end_date,$query,$graph_by,$graph_title,$where,$module,$type);
+	if($graph_details!=0)
+        {
+                $name_val=$graph_details[0];
+                $cnt_val=$graph_details[1];
+                $graph_title=$graph_details[2];
+                $target_val=$graph_details[3];
+                $graph_date=$graph_details[4];
+                $urlstring=$graph_details[5];
+                $cnt_table=$graph_details[6];
+	       	$test_target_val=$graph_details[7];
+
+                $width=500;
+                $height=225;
+                $top=30;
+                $left=140;
+                $bottom=120;
+                $title=$graph_title;
+		$sHTML = render_graph($tmp_dir."vert_".$cache_file_name,$html_imagename."_vert",$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,"vertical");
+		echo $sHTML;
+		
+        }
+	else
+	{
+		echo $mod_strings[LBL_NO_DATA];	
+	}
+
+
+?>

Modified: vtigercrm/trunk/modules/Home/index.php
==============================================================================
--- vtigercrm/trunk/modules/Home/index.php (original)
+++ vtigercrm/trunk/modules/Home/index.php Sat Jul 15 01:17:31 2006
@@ -139,10 +139,8 @@
 	case 'HDB':
 	if(isPermitted('Dashboard','index') == "yes")
 	{
-		require_once('modules/Dashboard/HomepageDB.php');
-		$dashboard = getHomepageDB();
-		if($dashboard != null)
-			$home_values['Dashboard']=$dashboard;
+		$smarty->assign('IS_HOMEDASH','true');
+		$home_values['Dashboard']="true";
 	}
 	        break;
     }





More information about the vtigercrm-commits mailing list