<?php error_reporting(0);
include('CRM/functions.php');
?>
 <table width="100%" border="0">
  <tr>
    <td valign="top"> 
	
<?php  include('user-deptlist.php');?>
   <div id='chart_div'></div>
 <?php
 global $db;
 $temp = array();
$temp1 = array();
$tmp2=array();
 $lstatus =array(1=>'Warm','Attempted to Contact','Cold','Contact in Future','Hot','Junk Lead','Lost Lead','Qualified','Not Contacted','Pre Qualified','Active','Techno commercial submitted','Negotiation going on','Proposal submitted','Negotiation done','Proposal to be submitted','Contacted');
  for($i=1;$i<count($lstatus);$i++)
 {
     $strQuery = "select count(*) as TotOutput , COUNT( * )/  ( SELECT COUNT( * ) FROM crm_leads where  deleted_status='N'  and Convert_IntoAccountStatus='N' and lead_status ='".$lstatus[$i]."'  ) AS percentage  from crm_leads where deleted_status='N' and Convert_IntoAccountStatus='N' and lead_status ='".$lstatus[$i]."' ";
	$result =DB_query($strQuery,$db);
	
	 if(DB_num_rows($result)>0)
	{
	     $ors =DB_fetch_array($result);
		 $tmp[] =$lstatus[$i];
		 $tmp1[] = round($ors['percentage'],2).'%';
		 $tmp2[] = 'index.php?route=CRM/View_Leads&modid=12&frmid=309&type='.$lstatus[$i];
	}
 }

  
include "piechart/piechart.class.php";
$radius =200;
$elementnames = $tmp;
$elements = $tmp1;
  $colors = array(  'violet'  ,     'tomato' ,'aqua' ,'aquamarine' ,'azure'  ,'steelblue' ,'bisque' ,'black'     ,'blanchedalmond','blue' ,'blueviolet' ,'brown'      ,'burlywood'  ,'cadetblue'  ,'chartreuse'  ,'chocolate' ,'coral'    ,'cornflowerblue','cornsilk','crimson','cyan'   ,'darkblue'   ,'darkcyan'  ,'darkgoldenrod','darkgray'   ,'darkgreen'  ,'darkkhaki' ,'darkmagenta'   ,'darkolivegreen','darkorange'  ,'darkorchid'  ,'darkred' ,'darksalmon','darkseagreen','darkslateblue','darkslategray','darkturquoise','darkviolet'  ,'deeppink'     ,'deepskyblue'  ,'dimgray'   ,'dodgerblue' ,'firebrick'   ,'floralwhite'  ,'forestgreen' ,'fuchsia' ,'gainsboro'    ,'ghostwhite' ,'gold'     ,'goldenrod'   ,'gray'       ,'green'   ,'greenyellow'   ,'honeydew'  ,'hotpink'    ,'indianred'  ,'indigo'    ,'ivory'    );
     
 $chart=new piechart(
                                        $radius,
                                        $elementnames,
                                        $elements,
                                        $colors
                                        );
$chart->links =$tmp2;
 //array('1.html','2.html','3.html');
$chart->GenerateHtmlCode(1);
?> </td>
    <td valign="top" align="left"> 
  <p style="padding-top:5px; padding-bottom:5px; font-weight:bold; background-color:#999999; color:#000000; margin:0px;">To Do Activity</p>
<table width="100%" border="0">
  <tr>
    <th><strong>To Do </strong></th>
    <th><strong>Related To </strong></th>
    <th><strong>Due Date </strong></th>
    <th><strong>Status</strong></th>
  </tr>
 <?php $i=0;
$curdate=date('Y-m-d');
  	$getlead_event=DB_query("select * from crm_leadtodo where groupid='".$_SESSION['ACGRoleId']."' and lead_type='Task' and tododatetime>='$curdate' and todostatus!='Confirm'",$db);
while($rows=DB_fetch_array($getlead_event))
{
?>  <tr><td><?php echo ++$i; ?></td>
   <td>
   <a href="CrmSearch_LeadEvent" onclick="alertfun();"><?php echo $rows['lead_priority'];?></a></td>
	<td><?php echo $rows['tododatetime'].'&nbsp;'.$rows['todostart_time'];?></td>
	 
	<td><?php echo $rows['todostatus'];?></td>
     <td><?php echo $rows['notification_matter'];?></td>
   </tr>
 <tr>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
 </tr>
 
   <?php } ?>  
   
   <tr>
   <td colspan="6"><b>Event Calender</b> </td>
   </tr>
 <tr>
   <td colspan="6"> <?php include('CRM/CRMEventCalender.php')?>&nbsp;</td>
   </tr>
 </table>  </td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><?php include('piechart/barchart.php')?> </td>
   </tr>
</table>

	


<!-- right div close -->
