[Vtigercrm-commits] [vtiger-commits] r7574 - /vtigercrm/trunk/modules/Dashboard/Entity_charts.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Jun 27 09:08:01 EDT 2006


Author: saraj
Date: Tue Jun 27 07:07:57 2006
New Revision: 7574

Log:
changes made to integrate home page dashboard

Modified:
    vtigercrm/trunk/modules/Dashboard/Entity_charts.php

Modified: vtigercrm/trunk/modules/Dashboard/Entity_charts.php
==============================================================================
--- vtigercrm/trunk/modules/Dashboard/Entity_charts.php (original)
+++ vtigercrm/trunk/modules/Dashboard/Entity_charts.php Tue Jun 27 07:07:57 2006
@@ -14,6 +14,9 @@
 require_once('include/utils/utils.php');
 require_once('include/database/PearDatabase.php');
 require_once('include/utils/CommonUtils.php');
+include("modules/Dashboard/horizontal_bargraph.php");
+//include("modules/Dashboard/vertical_bargraph.php");
+include("modules/Dashboard/pie_graph.php");
 
 //To get the vtiger_account names
 
@@ -279,8 +282,10 @@
 					}
 
 					if($graph_for == "accountid") $graph_for = "account_id";
-					
-					$link_val="index.php?module=".$module."&action=index&search_text=".$name."&search_field=".$graph_for."&searchtype=BasicSearch&query=true&type=entchar";
+					if($module == "Home")
+						$link_val="index.php?module=".$name."&action=index";
+					else
+						$link_val="index.php?module=".$module."&action=index&search_text=".$name."&search_field=".$graph_for."&searchtype=BasicSearch&query=true&type=entchar";
 
 					if($graph_for == "account_id") $graph_for = "accountid";
 
@@ -376,4 +381,184 @@
 	return true;
 }
 
+function get_graph_by_type($graph_by,$graph_title,$module,$where,$query)
+{
+	global $user_id,$date_start,$end_date,$type;
+
+	//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=600;
+		$height=400;
+		$top=30;
+		$left=140;
+		$bottom=120;
+		$title=$graph_title;
+
+		return get_graph($cache_file_name,$html_imagename,$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$graph_date,$urlstring,$test_target_val,$date_start,$end_date);
+	}
+	else
+	{
+		
+	}
+	
+}
+
+/** Returns  the Horizontal,vertical, pie graphs and Accumulated Graphs
+for the details
+* Portions created by vtiger are Copyright (C) vtiger.
+* All Rights Reserved.
+* Contributor(s): ______________________________________..
+*/
+
+
+// Function for get graphs
+function get_graph($cache_file_name,$html_imagename,$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$graph_date,$urlstring,$test_target_val,$date_start,$end_date)
+{
+
+	global $tmp_dir;
+	global $graph_title, $mod_strings;
+	$val=explode(":",$title);
+	$display_title=$val[0];
+
+
+$sHTML .= "<tr>
+	   <td><table width=20%  border=0 cellspacing=0 cellpadding=0 align=left>
+	         <tr>
+	    	   <td rowspan=2 valign=top><span class=dashSerial>1</span></td>
+	           <td nowrap><span class=genHeaderSmall>".$graph_title."</span></td>
+		 </tr>
+		 <tr>
+		   <td nowrap><span class=big>".$mod_strings['LBL_HORZ_BAR_CHART']."</span> </td>
+		 </tr>
+		</table>
+	   </td>
+	</tr>
+	<tr>
+           <td height=200>";
+
+	   $sHTML .= render_graph($tmp_dir."hor_".$cache_file_name,$html_imagename."_hor",$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,"horizontal");
+//Commented by Minnie -- same content displayed in to graphs
+/*$sHTML .= "</td>
+	</tr>
+	<tr>
+	   <td><hr noshade='noshade' size='1' /></td>
+	</tr>";
+
+$sHTML .= "<tr>
+	   <td><table width=20%  border=0 cellspacing=0 cellpadding=0 align=left>
+	   	 <tr>
+		   <td rowspan=2 valign=top><span class=dashSerial>2</span></td>
+		   <td nowrap><span class=genHeaderSmall>".$graph_title."</span></td>
+		 </tr>
+		 <tr>
+		   <td><span class=big>Vertical Bar Chart</span> </td>
+		 </tr>
+	        </table>
+	   </td>
+	</tr>
+	<tr>
+	   <td height=200>";
+
+	   $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");*/
+
+$sHTML .= "</td>
+	</tr>
+	<tr>
+	   <td><hr noshade='noshade' size='1' /></td>
+	</tr>";
+
+$sHTML .= "<tr>
+	   <td><table width=20%  border=0 cellspacing=0 cellpadding=0 align=left>
+           	 <tr>
+	           <td rowspan=2 valign=top><span class=dashSerial>2</span></td>
+	           <td nowrap><span class=genHeaderSmall>".$graph_title."</span></td>
+	         </tr>
+	         <tr>
+	           <td><span class=big>".$mod_strings['LBL_PIE_CHART']."</span> </td>
+	         </tr>
+	        </table>
+	   </td>
+	</tr>
+	<tr>
+	   <td height=200>";
+
+	   $sHTML .= render_graph($tmp_dir."pie_".$cache_file_name,$html_imagename."_pie",$cnt_val,$name_val,$width,$height,40,$right,$top,$bottom,$title,$target_val,"pie");
+
+$sHTML .= "</td>
+	</tr>
+	<tr>
+	   <td><hr noshade='noshade' size='1' /></td>
+	</tr>";
+
+	return $sHTML;
+}
+
+/** Returns graph, if the cached image is present it'll display that image,
+otherwise it will render the graph with the given details
+* Portions created by vtiger are Copyright (C) vtiger.
+* All Rights Reserved.
+* Contributor(s): ______________________________________..
+*/
+
+// Function to get the chached image if exists
+function render_graph($cache_file_name,$html_imagename,$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$graph_type)
+{
+
+	//Checks whether the cached image is present or not
+	if(file_exists($cache_file_name))
+	{
+		unlink($cache_file_name);
+	}
+	if(file_exists($cache_file_name.'.map'))
+	{
+		unlink($cache_file_name.'.map');
+	}
+	if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map'))
+	{
+		//If the Cached image is not present
+		if($graph_type=="horizontal")
+		{
+			return horizontal_graph($cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$cache_file_name,$html_imagename);
+		}
+		else if($graph_type=="vertical")
+		{
+			return vertical_graph($cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$cache_file_name,$html_imagename);
+		}
+		else if($graph_type=="pie")
+		{
+			return pie_chart($cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$cache_file_name,$html_imagename);
+
+		}
+	}
+	else
+	{
+		//Getting the cached image
+		$imgMap_fp = fopen($cache_file_name.'.map', "rb");
+		$imgMap = fread($imgMap_fp, vtiger_filesize($cache_file_name.'.map'));
+		fclose($imgMap_fp);
+		$base_name_cache_file=basename($cache_file_name);
+		$ccc="cache/images/".$base_name_cache_file;
+		$return = "\n$imgMap\n";
+		$return .= "<img src=$ccc ismap usemap=#$html_imagename border='0'>";
+		return $return;
+	}
+}
+
+
 ?>





More information about the vtigercrm-commits mailing list