I’ve created a custom dashlet for the Account’s module, but for some reason I cannot get the columns to apply. Instead, the dashlet displays the account modules’ default dashlet columns.
MissingEINsDashlet.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/Dashlets/DashletGeneric.php');
//require_once('modules/Accounts/Account.php');
class MissingEINsDashlet extends DashletGeneric {
function process() {
global $current_language, $app_list_strings, $image_path, $current_user;
$lvsParams = array(
'custom_select' => '',
'custom_from' => '',
'custom_where' => ' AND ((accounts_cstm.ein_c IS NULL OR accounts_cstm.ein_c="") AND accounts.account_type="Vendor")',
'distinct' => true
);
/**
* Overrides the generic process to include custom logic for email addresses,
* since they are no longer stored in a list view friendly manner.
* (A record may have an undetermined number of email addresses).
*
* @param array $lvsParams
*/
if (isset($this->displayColumns) && array_search('email1', $this->displayColumns) !== false) {
$lvsParams['custom_select'] = ', email_address as email1';
$lvsParams['custom_from'] = ' LEFT JOIN email_addr_bean_rel eabr ON eabr.deleted = 0 AND bean_module = \'Accounts\''
. ' AND eabr.bean_id = accounts.id AND primary_address = 1'
. ' LEFT JOIN email_addresses ea ON ea.deleted = 0 AND ea.id = eabr.email_address_id';
}
if (isset($this->displayColumns) && array_search('parent_name', $this->displayColumns) !== false) {
$lvsParams['custom_select'] = empty($lvsParams['custom_select']) ? ', a1.name as parent_name ' : $lvsParams['custom_select'] . ', a1.name as parent_name ';
$lvsParams['custom_from'] = empty($lvsParams['custom_from']) ? ' LEFT JOIN accounts a1 on a1.id = accounts.parent_id' : $lvsParams['custom_from'] . ' LEFT JOIN accounts a1 on a1.id = accounts.parent_id';
}
parent::process($lvsParams);
}
function MissingEINsDashlet($id, $def = null) {
global $current_user, $app_strings;
require('custom/modules/Home/Dashlets/MissingEINs/MissingEINsDashlet.data.php');
parent::DashletGeneric($id, $def);
//disables myItemsOnly
//$this->showMyItemsOnly = false;
//unchecks myItemsOnly
$this->myItemsOnly = false;
if(empty($def['title'])) $this->title = 'Vendors - Missing EINs';
$this->searchFields = $dashletData['MissingEINsDashlet']['searchFields'];
$this->columns = $dashletData['MissingEINsDashlet']['columns'];
$this->seedBean = new Account();
}
}
?>
MissingEINsDashlet.data.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $current_user;
$dashletData['MissingEINsDashlet']['searchFields'] = array(
'date_entered' => array ('default' => ''),
'date_modified' => array ('default' => ''),
'assigned_user_id' => array ('default' => ''),
'ein' => array('default' => ''),
);
$dashletData['MissingEINsDashlet']['columns'] = array(
'name' =>
array (
'width' => '15%',
'label' => 'LBL_LIST_ACCOUNT_NAME',
'link' => true,
'default' => true,
'name' => 'name',
),
'ein_c' =>
array (
'type' => 'varchar',
'default' => true,
'label' => 'LBL_EIN',
'width' => '10%',
),
'phone_office' =>
array (
'width' => '15%',
'label' => 'LBL_LIST_PHONE',
'default' => true,
'name' => 'phone_office',
),
'phone_fax' =>
array (
'width' => '8%',
'label' => 'LBL_PHONE_FAX',
'name' => 'phone_fax',
'default' => true,
),
'date_modified' =>
array (
'width' => '15%',
'label' => 'LBL_DATE_MODIFIED',
'name' => 'date_modified',
'default' => true,
),
'assigned_user_name' =>
array (
'width' => '8%',
'label' => 'LBL_LIST_ASSIGNED_USER',
'name' => 'assigned_user_name',
'default' => true,
),
);
?>
MissingEINsDashlet.meta.php
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $app_strings;
$dashletMeta['MissingEINsDashlet'] = array('module' => 'Accounts',
'title' => 'Vendors - Missing EINs',
'description' => 'Dashlet containing a list of vendors with no EIN',
'icon' => 'icon_Accounts_32.gif',
'category' => 'Module Views');
?>