AnsweredAssumed Answered

How to have the Leads count show on a custom dashlet?

Question asked by MSS MSS on Nov 21, 2014
Recently I was trying to  create a custom dashlet which give you the cont  of Leads with respect to different lead stage in a selected duration of time.

I
have almost done with the work. Actually I am getting the count at the
back end (Var_dump action of the fields) but Count is not reflecting on the
dashlet view.

please find the below attached files for your reference. and let me know where I am missing the actual stuff.

Looking forward to your reply.





file name: leadcountdashlet.php

require_once('include/Dashlets/DashletGeneric.php');


class MyLeadsCountDashlet extends DashletGeneric {
    function MyLeadsCountDashlet($id, $def = null) {
        global $current_user, $app_strings,$db;
        require('custom/modules/Leads/Dashlets/MyLeadsCountDashlet/MyLeadsCountDashlet.data.php');
       
        parent::DashletGeneric($id, $def);
        
        if(empty($def['title'])) $this->title = translate('LBL_LIST_MY_COUNT_LEADS', 'Leads');
       
        $this->searchFields = $dashletData['MyLeadsCountDashlet']['searchFields'];
        $this->columns = $dashletData['MyLeadsCountDashlet']['columns'];
     
     $this->seedBean = new Lead();
      
      
        }
         function process($lvsParams = array()) {
         global $db;
  
        $query_inprocess="select count(*)  from leads_cstm LEFT JOIN leads on leads_cstm.id_c=leads.id where leads_cstm.status_2_c='In Process'and leads.deleted='0'";
        $query_contact="select count(*)  from leads_cstm LEFT JOIN leads on leads_cstm.id_c=leads.id where leads_cstm.status_2_c='Contact'and leads.deleted='0' ";
        $query_dead="select count(*)  from leads_cstm LEFT JOIN leads on leads_cstm.id_c=leads.id where leads_cstm.status_2_c='Dead'and leads.deleted='0' ";
         $query_new="select count(*)  from leads_cstm LEFT JOIN leads on leads_cstm.id_c=leads.id where leads_cstm.status_2_c='New'and leads.deleted='0'";
       $ans_new=$db->query($query_new);
       $result_new=$db->fetchbyassoc($ans_new);
       $ans_contact=$db->query($query_contact);
       $result_contact=$db->fetchbyassoc($ans_contact);
       $ans_inprocess=$db->query($query_inprocess);
       $result_inprocess=$db->fetchbyassoc($ans_inprocess);
       $ans_dead=$db->query($query_dead);
       $result_dead=$db->fetchbyassoc($ans_dead);
      
       $this->seedBean->field_defs['new_count'] =
          array(
             'name' => 'new_count',
             'vname' => 'New Leads',
             'len' => '8',
             'source' => 'non-db',
             'value'=>$result_new['count(*)'],
          );
       $this->seedBean->field_defs['contact_count'] =
          array(
             'name' => 'contact_count',
             'vname' => 'Contact Leads',
             'len' => '8',
             'source' => 'non-db',
             'value'=>$result_contact['count(*)'],
          );
       $this->seedBean->field_defs['inprocess_count'] =
          array(
             'name' => 'inprocess_count',
             'vname' => 'In Process Leads',
             'len' => '8',
             'source' => 'non-db',
             'value'=>$result_inprocess['count(*)'],
          );
           $this->seedBean->field_defs['dead_count'] =
          array(
             'name' => 'dead_count',
             'vname' => 'Dead Leads',
             'len' => '8',
             'source' => 'non-db',
             'value'=>$result_dead['count(*)'],
          );

        $lvsParams['overrideOrder'] = true;
     
        $lvsParams['sortOrder'] = 'ASC';

        parent::process($lvsParams);
        echo"
";
        var_dump($this->seedBean);
        //exit();
      
      
      
         
    }
}

?>

leadcountdashlet.meta.php
$dashletMeta['MyLeadsCountDashlet'] = array('module'        => 'Leads',
                                       'title'       => translate('LBL_LIST_MY_COUNT_LEADS', 'Leads'),
                                       'description' => 'A customizable view into Leads',
                                       'category'    => 'Module Views');
?>


leadcountdata.php

global $current_user;
$dashletData['MyLeadsCountDashlet']['searchFields'] = array( 'Status' => array(
                        'status_2_c' => '',
                        'default' => '',
                      ),
   );
 
$dashletData['MyLeadsCountDashlet']['columns'] =array(
      
       'new_count' => array('width' => '8',
          'label' => 'New Leads ',
          'default' => true),
       'contact_count' => array('width' => '8',
          'label' => 'Contact Leads',
          'default' => true),
       'inprocess_count' => array('width' => '8',
          'label' => 'In Process Leads',
          'default' => true),
          'dead_count' => array('width' => '8',
          'label' => 'Dead Leads',
          'default' => true),
    );
?>



Outcomes