Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: A more useful Calls Dashlet

  1. #1
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Lightbulb A more useful Calls Dashlet

    I get alot of questions about why the phone number of the party to be called is not on the Calls dashlet, meaning that you have to drill into each record to get the number to call. By default it doesnt even tell you who you want to call, let alone the phone number. All in all, it could be better.

    So lets make it better. First you can easily add the "Related To" field to the dashlet by just clicking on the edit button (the little pencil icon in the top right hand corner) and selecting the 'related to' field from the list on the right and moving it to the list on the left with the arrow. That at least puts the name of the person you are to call in the dashlet. But still no phone number.

    For that we will have to add a little code to the Calls dashlet.

    Edit the file modules/Calls/Dashlets/MyCallsDashlet/MyCallsDashlet.php and find the process() function. It should be around line number 64. Then look down to around line 100 and you should see a line that looks like this
    PHP Code:
    foreach($this->lvs->data['data'] as $rowNum => $row) { 
    This is where the code loops through all the calls that will be displayed in the dashlet. We are going to add some code there. So, right underneath that line put this
    PHP Code:
    global $beanFiles,$beanList,$system_config;
    $parent_id=$this->lvs->data['data'][$rowNum]['PARENT_ID'];
    if(!empty(
    $parent_id)) {
        
    $parent_module=$this->lvs->data['data'][$rowNum]['PARENT_TYPE'];
        
    $bean_name=$beanList[$parent_module];
        
    $bean_file=$beanFiles[$bean_name];
        if(
    file_exists($bean_file)) {
            require_once(
    $bean_file);
            
    $focus_parent=new $bean_name();
            
    $focus_parent->retrieve($parent_id);
            if(isset(
    $focus_parent->phone_office)) {
                
    $phoneNumber=$focus_parent->phone_office;
            } else {
                
    $phoneNumber=$focus_parent->phone_work;
            }
        }
    }
    if(isset(
    $system_config->settings['system_skypeout_on']) && $system_config->settings['system_skypeout_on'] == 1){
        if(!empty(
    $phoneNumber) && skype_formatted($phoneNumber)){
            
    $phoneNumber"<img src=\"http://c.skype.com/i/images/icons/skype_48x48_white.png\" alt=\"Skype\" width=16 height=16><a href=\"callto://{$phoneNumber}\">{$phoneNumber}";
        }
    }

    $new_parent=$this->lvs->data['data'][$rowNum]['PARENT_NAME'];
    $new_parent=$new_parent."<br></a>{$phoneNumber}";
    $this->lvs->data['data'][$rowNum]['PARENT_NAME']=$new_parent
    What that will do is it will go and get the phone number of the related object (might be a Conatact or a Lead or a Account so the code figures that out first) and appends it to the Related to's name. It ends up looking like the image I attached to this note.

    There are probably better ways to do this, and this is NOT upgrade safe so it would have to be redone after every upgrade, but it is quick and easy. You will notice that I did put in code to format the number as a Skype callto:// URL if that is set up for your system. You can eliminate that or just the skype icon if you want.

    Let me know if you have any questions about this mod, improvments to this mod or ideas for other mods. I needs lots of ideas for little tweaks that you would like to see.
    Attached Images Attached Images  
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  2. #2
    TheBishopOfSoho is offline Senior Member
    Join Date
    Mar 2009
    Posts
    35

    Default Re: A more useful Calls Dashlet

    Hi Ken, than ks for this very useful tutorial. I followed this and worked very nice, however not quite how I wanted it to work so I hope Im not overstepping my mark but would like to suggest a couple changes, including making it upgrade safe.

    First of all, as of version 5.2, to make my version Upgrade safe, copy the /modules/calls/dashlets/MyCallsDashlet folder to /custom/modules/calls/dashlets/ (If the calls or dashlets folder dont exist in custom/modules, then mkdir them or just create them). The key to getting your changes upgrade safe is to then edit /custom/modules/calls/dashlets/MyCallsDashlet/MyCallsDashlet.php on line 47 or so to this:
    PHP Code:
    require('custom/modules/Calls/Dashlets/MyCallsDashlet/MyCallsDashlet.data.php'); 
    We will assume that all changes are being made in Custom directory now.
    Anyways, one of the issues I had with your implementation was that if the lead or contacts Parent was an account, the account name would show up with the accounts number, and not nescessarily the name of the lead or contact himself. So I wrote the following code to mimic what you were trying to do, and goes in the same section in the Process function:

    PHP Code:
    //Define the DB object to use        
    global $db;
            
            
            
            foreach(
    $this->lvs->data['data'] as $rowNum => $row) {
                
    /* Code Edit Start */
                /* SQL to get the relevant details we need for the contact in the current call.*/
                
    $LeadsContactsSQL "Select 'Lead' as ContType, leads.id, leads.salutation, leads.first_name, leads.last_name, leads.account_name, coalesce(leads.phone_work, leads.phone_other) as phone
                                        from calls_leads inner join calls on calls_leads.call_id = calls.id Inner join leads on calls_leads.lead_id = leads.id where calls.id = '" 
    $this->lvs->data['data'][$rowNum]['ID'] . "'
                                    union
                                    Select 'Contact' as ContType, contacts.id, contacts.salutation, contacts.first_name, contacts.last_name, 
                                        (Select accounts.name from accounts inner join accounts_contacts on accounts.id = accounts_contacts.account_id where accounts_contacts.contact_id =  '" 
    $this->lvs->data['data'][$rowNum]['ID'] . "') as account_name, coalesce(contacts.phone_work, contacts.phone_other) as phone
                                        from calls_contacts inner join calls on calls_contacts.call_id = calls.id Inner join contacts on calls_contacts.contact_id = contacts.id
                                        where calls.id = '" 
    $this->lvs->data['data'][$rowNum]['ID'] . "'";
                                        
                
                
    $LeadsContactDetails $db->query($LeadsContactsSQL);
                
    $ContactDetailsArr mysqli_fetch_assoc($LeadsContactDetails);
                
                
                
                
    $ContactDetails $ContactDetailsArr['first_name'] . " " $ContactDetailsArr['last_name'] . "</a> (" ;
                if(
    $ContactDetailsArr['account_name'] == ''){
                    If (
    $this->lvs->data['data'][$rowNum]['PARENT_NAME'] == $ContactDetailsArr['first_name'] . " " $ContactDetailsArr['last_name']){
                        
    $ContactDetails $ContactDetails "No Account";
                    }else{
                        
    $ContactDetails $ContactDetails $this->lvs->data['data'][$rowNum]['PARENT_NAME'] ;
                      }
                }else{
                    
    $ContactDetails    $ContactDetails $ContactDetailsArr['account_name'] ;
                }
                
                
    $ContactDetails $ContactDetails ")<br />Ph: " $ContactDetailsArr['phone'];
                
                
                
                
                
                
    $this->lvs->data['data'][$rowNum]['PARENT_NAME'] = $ContactDetails
    :

    Again, this may not be perfect, but Ive been pulling hair on this site for ages trying to get my head around how to customise Sugar, so this is my first attempt. Any and all criticisms welcomed. Particularily I would like to know if there is a better way to get the data I searched for with the adhoc query, seems a bit "hackey" to have to do it like that. Im sure there is a better way.

    S
    Last edited by TheBishopOfSoho; 2009-05-07 at 10:50 AM.

  3. #3
    bcovert is offline Member
    Join Date
    Jul 2009
    Posts
    5

    Default Re: A more useful Calls Dashlet

    kbirll,

    I tried your code but it doesn't work for me. I have Version 5.2.0c (Build 5505). I am not getting any errors, it just isn't showing the phone number. Any thoughts?

  4. #4
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: A more useful Calls Dashlet

    Quote Originally Posted by bcovert View Post
    kbirll,

    I tried your code but it doesn't work for me. I have Version 5.2.0c (Build 5505). I am not getting any errors, it just isn't showing the phone number. Any thoughts?
    Did you do this in the custom directory, if so check your permissions.
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  5. #5
    bcovert is offline Member
    Join Date
    Jul 2009
    Posts
    5

    Default Re: A more useful Calls Dashlet

    I did it in the modules/Calls/Dashlets/MyCallsDashlet folder in the MyCallsDashlet.php file.

  6. #6
    pmasson is offline Junior Member
    Join Date
    Aug 2009
    Posts
    2

    Default Re: A more useful Calls Dashlet

    KBrill,
    Thank you for a very useful improvement to the Calls Dashlet.
    As a new user of Sugar, I am trying to keep an open mind. However, I cannot fathom how someone could produce such a wholly ineffective piece of software as this dashlet.
    While your code does effectively add the phone number, it is still dependent on the user selecting the contact for the 'relates to' field. I find this unbelievably unnecessary when scheduling a call from within the Contact record.
    As a primary function of CRM software, please tell me there is a plan in place to improve this process.
    Respectfully,
    Paul Masson

  7. #7
    salesagility's Avatar
    salesagility is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    2,379

    Default Re: A more useful Calls Dashlet

    Paul

    It is not necessary to use the relates to field when scheduling a call if you use sugarcrm correctly.

    Let's say I'm going to schedule a call to a contact called paul masson

    I goto modules>contacts>search and put masson in as surname

    I click on Paul Masson from the listview

    I get the detailview of paul masson, scroll down to Activities subpanel and click Schedule Call

    In the schedule call dialogue, sugarcrm attempts to automatically associate this call with the account as well as with the contact. I do not touch this though. I schedule time, date, purpose etc and click Save.

    The call is scheduled and it's related to both the contact (automatically) and to the account if it exists (automatically).

    99.5% of all scheduled calls will be like this. The process is good, it's natural and it works.

  8. #8
    pmasson is offline Junior Member
    Join Date
    Aug 2009
    Posts
    2

    Default Re: A more useful Calls Dashlet

    Thank you for the post.
    What you describe sounds intuitive, and is what I would expect Sugar to do. Unfortunately that is not what I am experiencing.
    When scheduling a call, the Relate To has a drop down box for acct, etc., a blank field, and Select/Clear buttons. Upon save, no information is displayed in this field.
    Version 5.2.0h (Build 5744) on Apache/2.0.59 (win32) mod_ssl/2.0.59 OpenSSL/0.9.8a PHP/5.2.1 MySQL Version: 4.1.7
    Paul

  9. #9
    ejansen is offline Sugar Community Member
    Join Date
    Jul 2007
    Posts
    17

    Default Re: A more useful Calls Dashlet

    How can I add the same functionality to the list view for the calls module?

  10. #10
    jpjanze is offline Member
    Join Date
    Aug 2008
    Posts
    6

    Default Re: A more useful Calls Dashlet

    Just wanted to say 'thanks' for this great solution and the easy step by step changes required. Well done!

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Adding contact_phone to Calls dashlet
    By dgoldman in forum Developer Help
    Replies: 3
    Last Post: 2010-08-04, 04:52 PM
  2. error on calls dashlet
    By sidh211 in forum Help
    Replies: 2
    Last Post: 2008-07-12, 06:59 AM
  3. Dashlet w/ outside server making SOAP calls
    By Ryan.Partridge in forum Developer Help
    Replies: 5
    Last Post: 2008-02-08, 09:08 PM
  4. Calls dashlet - sort by date AND time
    By ChocolateLover in forum Help
    Replies: 0
    Last Post: 2007-02-06, 06:33 PM
  5. Strange Calls Dashlet Problem
    By atheimer98 in forum Help
    Replies: 0
    Last Post: 2006-12-05, 10:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •