As promised here are some screen shots
The creation of a dashlet is almost the same as specifying the search parameters for the advanced search.
There is a little bit more that need to be specified due to the display options.
AppinuxDashlets\Dashlets\ProjectManagement\Project IssuesDashlet\ProjectIssuesDashlet.data.php
Code:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $current_user;
global $timedate;
$dateformat = $timedate->get_date_format();
/**
* This are the filters that you want to display in the dashlet dialog these names
* must match the corresponding field names in the vardefs.php file
*/
$startDate = date($dateformat, time());
$endDate = date($dateformat,strtotime("+1 months"));
$dashletData['ProjectIssuesDashlet']['searchFields'] = array(
'foundrelease' => array('default' => ''),
'status_filter' => array('default' => ''),
'priority_filter' => array('default' => ''),
'fixedrelease' => array('default' => ''),
'user' => array ('default' => '',),
'project' => array ('default' => '',),
);
/**
* Allows you to affect how the sql is generated
*/
$dashletData['ProjectIssuesDashlet']['sql_options'] = array(
'custom_select' => ' ,users.user_name as user',
'custom_from' => ' inner join users on users.id = pm_issue.assigned_user_id ',
'distinct' => true,
);
/**
* This are the different columns you can choose to display using the dashlet dialog
* the names need to match either:
*
* - a field name from the main modules vardefs.php
* - or a field in our custom vardefs.php located in this directory
*/
$dashletData['ProjectIssuesDashlet']['columns'] = array(
'name' =>
array (
'width' => '40%',
'label' => 'LBL_LIST_NAME',
'link' => true,
'default' => true,
'name' => 'name',
),
'foundrelease' =>
array (
'width' => '10%',
'label' => 'LBL_FOUNDRELEASE',
'default' => true,
'name' => 'foundrelease',
),
'type' =>
array (
'width' => '10%',
'label' => 'LBL_TYPE',
'sortable' => false,
'default' => true,
'name' => 'type',
),
'status' =>
array (
'width' => '10%',
'label' => 'LBL_STATUS',
'sortable' => false,
'default' => true,
'name' => 'status',
),
'user' =>
array (
'width' => '8%',
'label' => 'LBL_LIST_ASSIGNED_USER',
'name' => 'user',
'default' => true,
),
'author' =>
array (
'width' => '10%',
'label' => 'LBL_AUTHOR',
'default' => false,
'name' => 'author',
),
'priority' =>
array (
'width' => '10%',
'label' => 'LBL_PRIORITY',
'sortable' => false,
'default' => false,
'name' => 'priority',
),
'effort' =>
array (
'width' => '10%',
'label' => 'LBL_EFFORT',
'default' => false,
'name' => 'effort',
),
'duration' =>
array (
'width' => '10%',
'label' => 'LBL_DURATION',
'default' => false,
'name' => 'duration',
),
'cost' =>
array (
'width' => '10%',
'label' => 'LBL_COST',
'currency_format' => true,
'default' => false,
),
'fixedrelease' =>
array (
'width' => '10%',
'label' => 'LBL_FIXEDRELEASE',
'default' => false,
'name' => 'fixedrelease',
),
);
?> AppinuxDashlets\Dashlets\ProjectManagement\Project IssuesDashlet\vardefs.php
Code:
<?php
/**
* This is a dummy PHP class designed to hold the values selected base from the custom select instead of modifying the
* original vardef.
*
* Since the built in dashlet generator handles everything for us including the Configure screen we might as well
* try to code around the restrictions using this dummy class both for search filter widgets definitions as well as
* other things
*/
$dictionary['ProjectIssues'] = array(
'table'=>'pm_issue', // main module table
'fields'=>array (
/**
* Each of the fields defined here are used to decide how sugar shows them in the GUI
* 1. either in the display mode of the dashlet - this is only for fields that is not part of the main module's vardef
* 2. or how a field/filter should look in configure mode.
*
* Leave the table clause to the same as you base table for the query.
*/
'name' =>
array (
'vname' => 'LBL_LIST_NAME',
'name' => 'name',
'type' => 'varchar',
'source' => 'db',
),
'foundrelease' =>
array (
'vname' => 'LBL_FOUNDRELEASE',
'name' => 'foundrelease',
'type' => 'varchar',
'source' => 'db',
),
'type' =>
array (
'vname' => 'LBL_TYPE',
'name' => 'type',
'type' => 'varchar',
'source' => 'db',
),
'status' =>
array (
'vname' => 'LBL_STATUS',
'name' => 'status',
'type' => 'varchar',
'source' => 'db',
),
'status_filter' =>
array (
'vname' => 'LBL_STATUS',
'name' => 'status_filter',
'type' => 'dashletenum',
'source' => 'non-db',
'options' => $GLOBALS['app_list_strings']['pm_issueStatus_list'],
'options_sql' => '',
'remove_blank' => false,
'join_sql' => '',
'table_alias' => 'pm_issue',
'db_column' => 'status',
),
'author' =>
array (
'vname' => 'LBL_AUTHOR',
'name' => 'author',
'type' => 'varchar',
'source' => 'db',
),
'priority' =>
array (
'vname' => 'LBL_PRIORITY',
'name' => 'priority',
'type' => 'varchar',
'source' => 'db',
),
'priority_filter' =>
array (
'vname' => 'LBL_PRIORITY',
'name' => 'priority_filter',
'type' => 'dashletenum',
'source' => 'non-db',
'options' => $GLOBALS['app_list_strings']['pm_issuePriority_list'],
'options_sql' => '',
'remove_blank' => false,
'join_sql' => '',
'table_alias' => 'pm_issue',
'db_column' => 'priority',
),
'effort' =>
array (
'vname' => 'LBL_EFFORT',
'name' => 'effort',
'type' => 'varchar',
'source' => 'db',
),
'duration' =>
array (
'vname' => 'LBL_DURATION',
'name' => 'duration',
'type' => 'varchar',
'source' => 'db',
),
'cost' =>
array (
'name' => 'cost',
'vname' => 'LBL_COST',
'type' => 'varchar',
'source' => 'db',
),
'fixedrelease' =>
array (
'vname' => 'LBL_FIXEDRELEASE',
'name' => 'fixedrelease',
'type' => 'varchar',
'source' => 'db',
),
'fixedrelease_filter' =>
array (
'vname' => 'LBL_FIXEDRELEASE',
'name' => 'fixedrelease',
'type' => 'varchar',
'source' => 'non-db',
'options' => '',
'options_sql' => '',
'remove_blank' => false,
'join_sql' => '',
'table_alias' => 'pm_issue',
'db_column' => 'fixedrelease',
),
'project' => array (
'name' => 'project',
'vname' => 'LBL_PROJECT',
'type' => 'dashletenum',
'source' => 'non-db',
'options' => '',
'options_sql' => 'select id as id, name as value from pm_project where deleted = 0',
'remove_blank' => false,
'join_sql' => ' inner join pm_project_pm_product_c on pm_project_pm_product_c.pm_project_pm_product_idb = pm_product.id and pm_project_pm_product_c.deleted = 0
inner join pm_project on pm_project.id = pm_project_pm_product_c.pm_project_pm_project_ida and pm_project.deleted = 0 ',
'table_alias' => 'pm_project',
'db_column' => 'id',
),
'user' => array (
'name' => 'user',
'vname' => 'LBL_LIST_ASSIGNED_USER',
'type' => 'dashletenum',
'source' => 'non-db',
'options' => '',
'options_sql' => 'select id as id, user_name as value from users where deleted = 0',
'remove_blank' => false,
'join_sql' => '',
'table_alias' => 'users',
'db_column' => 'id',
),
),
'relationships'=>array (
),
'optimistic_lock'=>true,
);
require_once('include/SugarObjects/VardefManager.php');
/**
* Sugar defines some stardard DTO classes that contains certain properties that can hold data.
* Since all modules builder generated module inherit from these this is a fast shortcut rather than
* explicitly defining them all here. Unless for some reason you want to override any of the settings,
* then you have to define it here as well.
*/
VardefManager::createVardef('ProjectIssues','ProjectIssues', array('basic','assignable')); This is pretty much the code needed and most of it is copy paste from the different involved modules vardefs.php and most of the solumns can be generated directly using the ;B built in dashlet generator.
Regards
Kenneth Thorman
Bookmarks