Page 1 of 4 1234 LastLast
Results 1 to 10 of 40
Like Tree1Likes

Thread: How to create an own chart Dashlet in 5.0.0c

  1. #1
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,678

    Default How to: Create an own chart Dashlet in 5.0.0c in 9 Steps

    As 5.0.0 differs a little from 4.5.1 I want to describe how you can create your own Chart Dashlet from an existing one.
    Let's suppose I want to have a "Weighted Pipeline" Dashlet which shows the weighted pipeline for all users in one chart.

    STEP 1

    Create directories (if not already present)

    ./custom/modules/Charts
    ./custom/modules/Charts/Dashlets

    ./custom/modules/Home
    ./custom/modules/Home/language


    STEP 2

    Copy the whole directory
    ./modules/Charts/Dashlets/MyPipelineBySalesStageDashlet
    to
    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet


    STEP 3

    Rename the files

    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/MyPipelineBySalesStageConfigure.tpl
    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/MyPipelineBySalesStageDashlet.en_us.lang.php
    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/MyPipelineBySalesStageDashlet.meta.php
    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/MyPipelineBySalesStageDashlet.php

    to

    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageConfigure.tpl
    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageDashlet.en_us.lang.php
    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageDashlet.meta.php
    ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageDashlet.php


    STEP 4

    Edit ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageDashlet.en_us.lang.php

    Change

    $dashletStrings['MyPipelineBySalesStageDashlet'] = array('LBL_TITLE' => 'My Pipeline By Sales Stage',
    'LBL_DESCRIPTION' => 'Vertical Bar Chart of My Sales Stage Pipeline',
    'LBL_REFRESH' => 'Refresh Chart');

    to

    $dashletStrings['WgPipelineBySalesStageDashlet'] = array('LBL_TITLE' => 'Weighted Pipeline By Sales Stage',
    'LBL_DESCRIPTION' => 'Vertical Bar Chart of Weighted Sales Stage Pipeline',
    'LBL_REFRESH' => 'Refresh Chart');


    STEP 5

    Edit ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageDashlet.meta.php

    Change

    $dashletMeta['MyPipelineBySalesStageDashlet'] = array('title' => 'LBL_TITLE',
    'description' => 'LBL_TITLE',
    'icon' => 'themes/default/images/icon_Charts_Funnel_32.gif',
    'module' => 'Opportunities',
    'category' => 'Charts');

    to


    $dashletMeta['WgPipelineBySalesStageDashlet'] = array('title' => 'LBL_TITLE',
    'description' => 'LBL_TITLE',
    'icon' => 'themes/default/images/icon_Charts_Funnel_32.gif',
    'module' => 'Opportunities',
    'category' => 'Charts');


    STEP 6

    Edit ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageDashlet.php

    Change
    class MyPipelineBySalesStageDashlet extends Dashlet {
    to
    class WgPipelineBySalesStageDashlet extends Dashlet {

    Change
    function MyPipelineBySalesStageDashlet($id, $options) {
    to
    function WgPipelineBySalesStageDashlet($id, $options) {

    Change
    $this->title = translate('LBL_MY_PIPELINE_FORM_TITLE', 'Home');
    to
    $this->title = translate('LBL_WG_PIPELINE_FORM_TITLE', 'Home');

    Change
    return parent::displayOptions() . $ss->fetch('modules/Charts/Dashlets/MyPipelineBySalesStageDashlet/MyPipelineBySalesStageConfigure.tpl');
    to
    return parent::displayOptions() . $ss->fetch('custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageConfigure.tpl');

    Change
    $this->loadLanguage('MyPipelineBySalesStageDashlet', 'modules/Charts/Dashlets/');
    to
    $this->loadLanguage('WgPipelineBySalesStageDashlet', 'custom/modules/Charts/Dashlets/');

    Change
    $cache_file_name = $current_user->getUserPrivGuid()."_".$theme."_my_pipeline_".$dat eFileNameSafe[0]."_".$dateFileNameSafe[1].".xml";
    to
    $cache_file_name = $current_user->getUserPrivGuid()."_".$theme."_wg_pipeline_".$dateFileNameSafe[0]."_".$dateFileNameSafe[1].".xml";

    Change
    if(is_file($sugar_config['tmp_dir'] . $current_user->getUserPrivGuid()."_".$theme."_my_pipeline_".$dat eFileNameSafe[0]."_".$dateFileNameSafe[1].".xml"))
    unlink($sugar_config['tmp_dir'] . $current_user->getUserPrivGuid()."_".$theme."_my_pipeline_".$dat eFileNameSafe[0]."_".$dateFileNameSafe[1].".xml");
    to
    if(is_file($sugar_config['tmp_dir'] . $current_user->getUserPrivGuid()."_".$theme."_wg_pipeline_".$dateFileNameSafe[0]."_".$dateFileNameSafe[1].".xml"))
    unlink($sugar_config['tmp_dir'] . $current_user->getUserPrivGuid()."_".$theme."_wg_pipeline_".$dateFileNameSafe[0]."_".$dateFileNameSafe[1].".xml");


    STEP 7

    Now we change the logic of the dashlet.

    Edit ./custom/modules/Charts/Dashlets/WgPipelineBySalesStageDashlet/WgPipelineBySalesStageDashlet.php

    Find the SQL statement

    Code:
     $query = " SELECT opportunities.sales_stage,
    users.user_name,
    opportunities.assigned_user_id,
    count( * ) AS opp_count,
    sum(amount_usdollar/1000 * probability/100) AS total
    FROM users,opportunities ";
    As we want to have the weighted sum of all opportunities with no user information we must change it to

    Code:
     $query = " SELECT opportunities.sales_stage,
    count( * ) AS opp_count,
    sum(amount_usdollar/1000 * probability/100) AS total
    FROM users,opportunities ";
    The additional group statement

    // $query .= ",users.user_name,opportunities.assigned_user_ id";

    must be commented out.

    The user-selection in the statement block

    Code:
    /**** 
    //build the where clause for the query that matches $user
    $count = count($user_id);
    $id = array();
    $user_list = get_user_array(false);
    foreach ($user_id as $key) {
    $new_ids[$key] = $user_list[$key];
    }
    if ($count>0) {
    foreach ($new_ids as $the_id=>$the_name) {
    $id[] = "'".$the_id."'";
    }
    $ids = join(",",$id);
    $where .= "opportunities.assigned_user_id IN ($ids) ";
     
    }
    ****/
    must be commented out because we want to see all opportunities not only the own.

    The salesstage selection
    $where .= "AND opportunities.sales_stage IN ($dataxArr) ";
    must be changed to (remove AND)
    $where .= " opportunities.sales_stage IN ($dataxArr) ";

    At last you should remove the user paremter from chart link by commenting it out:

    // $sugarChart->url_params = array( 'assigned_user_id' => $current_user->id );


    STEP 8

    Create an empty file with following content:

    Code:
    <?php
    // Title of Dashlet "Weighted Pipeline:
    $mod_strings['LBL_WG_PIPELINE_FORM_TITLE'] = 'Weighted Pipeline';
    ?>
    and write it to

    ./custom/modules/Home/language/en_us.lang.php

    Now you are ready to test your new Dashlet.


    STEP 9

    Call "admin" - "repair" - "Clear Vardefs Data Cache"
    and
    call "admin" -"repair" - "Rebuild Dashlets"


    READY TO GO

    Have a lot of fun writing your own chart dashlets.

    Harald Kuske
    Last edited by kuske; 2008-08-21 at 09:33 AM.
    sahay143 likes this.

  2. #2
    jlabuelo is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    479

    Default Re: How to create an own chart Dashlet in 5.0.0c

    Great post

    This is exactly what I need now.. will give it a try right now

    Thanks kuske!!!

  3. #3
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,678

    Default Re: How to create an own chart Dashlet in 5.0.0c

    I attached a zip-file with all mentioned files from the HowTo above.
    Attached Files Attached Files

  4. #4
    tbivans's Avatar
    tbivans is offline Sugar Community Member
    Join Date
    Dec 2006
    Location
    Ayden, NC
    Posts
    224

    Default Re: How to create an own chart Dashlet in 5.0.0c

    Kuske,

    Thanks a million! This is exactly the sort of thing that I've been looking for as well. This should be made into a Wiki entry!

    I will attempt this soon!

    Thanks again.

  5. #5
    anita83 is offline Junior Member
    Join Date
    May 2008
    Posts
    4

    Default Re: How to create an own chart Dashlet in 5.0.0c

    Hi Kuske,

    I have version 4.5.0, but I follow those steps.
    Now I don't know where look my dashlet.
    Where can I look it??

    Grettings,
    Anita
    Last edited by anita83; 2008-05-28 at 10:10 PM.

  6. #6
    sanjeev1225's Avatar
    sanjeev1225 is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    83

    Default Re: How to create an own chart Dashlet in 5.0.0c

    Hi kuske

    Thanku very much for giving such wondeful steps for create our own dashlet.It's working great but i can't see the column names and values in the WeigtedPipeLine .I attached the image file what iam getting ,I just extract the zip files and coopy the folder in custom/modules/.and followed the 9 th step.Any suggetions Plz
    Thanks
    Attached Images Attached Images  
    Sanjeev Thummala
    E-Mail :sanjeev_1225@yahoo.com

  7. #7
    sudipdey is offline Junior Member
    Join Date
    May 2008
    Posts
    1

    Cool Re: How to create an own chart Dashlet in 5.0.0c

    i am also fall in trouble in creating new chart dashlet

  8. #8
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,678

    Default Re: How to create an own chart Dashlet in 5.0.0c

    Quote Originally Posted by sanjeev1225
    Hi kuske

    Thanku very much for giving such wondeful steps for create our own dashlet.It's working great but i can't see the column names and values in the WeigtedPipeLine .I attached the image file what iam getting ,I just extract the zip files and coopy the folder in custom/modules/.and followed the 9 th step.Any suggetions Plz
    Thanks
    Which environment do you have?
    What does the logfile say if you set loglevel to DEBUG?
    What says that red text at the top?
    Harald Kuske
    Senior Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com

    PLEASE SWITCH TO
    https://community.sugarcrm.com/, the FORUMS will be closed !


  9. #9
    lcman is offline Member
    Join Date
    Jul 2008
    Posts
    13

    Default Re: How to create an own chart Dashlet in 5.0.0c

    How about in 5.0.0g??
    Operating system type and version: Ubuntu Linux 8.04
    Sugar version: 5.0.0g
    Webserver type and version: Apache 2.2.9
    PHP version: 5.2.6
    MySQL server version: 5.0.51b
    (XAMPP for Linux version: 1.6.7)

  10. #10
    rahulbhandari is offline Member
    Join Date
    Aug 2008
    Posts
    8

    Default Re: How to create an own chart Dashlet in 5.0.0c

    Thanks Alot

Page 1 of 4 1234 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to create new chart?
    By bhavin13 in forum Developer Help
    Replies: 17
    Last Post: 2011-03-04, 03:17 AM
  2. How to create new chart but show cases module
    By taarus in forum Developer Help
    Replies: 8
    Last Post: 2009-03-02, 10:05 AM
  3. Replies: 1
    Last Post: 2008-03-31, 08:33 AM
  4. quick create dashlet
    By gobezu in forum General Discussion
    Replies: 1
    Last Post: 2007-02-20, 09:51 PM
  5. Create new Chart
    By miki7 in forum Developer Help
    Replies: 1
    Last Post: 2006-06-13, 01:03 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
  •