Artem Brat

Displaying fields from the subpanel (Telephone) in the main module (Accounts)

Discussion created by Artem Brat on Jul 13, 2017
Latest reply on Jul 17, 2017 by Artem Brat

Hello.

Sorry for my english.

SugarCRM 6.5.

I created new custom module Telephone.

And created new Subpanel (Subpanel Telephone (sql)), using SQL.  (source: https://community.sugarcrm.com/message/80106)

/custom/Extension/modules/Accounts/Ext/Layoutdefs/telephone_acc_subpanel.php

<?php

$layout_defs['Accounts]['subpanel_setup']['tr_h'] = array (

    'order' => 1,

    'sort_by' => '',

    'sort_order' => 'asc',

    'module' => 'telephone',

    'refresh_page' => 1,

    'subpanel_name' => 'default',

    'get_subpanel_data' => 'function:get_ls_list',

    'add_subpanel_data' => 'parent_id',

    'title_key' => 'LBL_LS_TITLE',

    'function_parameters' => array(

            'import_function_file' => 'custom/modules/telephone/get_ls_list.php',

            'id' => $this->_focus->id,

            'field' => 'parent_id',

            'return_as_array' => 'true',

            'varName' => 'tr_h',

        ),

    'top_buttons' => array (

        0 => array (

            'widget_class' => 'SubPanelTopButtonQuickCreate',

        ),

        1 => array (

            'widget_class' => 'SubPanelTopSelectButton',

            'mode' => 'MultiSelect',

        ),

    ),

);

 

//custom/modules/telephone/get_ls_list.php

<?php

function get_ls_list($params) {

    $args = func_get_args();

    $field = $args[0]['field'];

    $id = $args[0]['id'];

                               $query = "

                               SELECT telephone.* FROM telephone INNER JOIN accounts ON telephone.".$field."=accounts.id

                               WHERE telephone.".$field."='".$id."'

                               ";

        return $query;

    }

Subpanel Telephone in Accounts

How to add (display) phone numbers from the subpanel (Telephone) in the main module (Accounts)? If the phone number is the MAIN_NUMBER_TELEPHONE  and the phone type is WORK_TYPE then in the field  Tel(work) in module Accounts. If the phone number is MAIN_NUMBER_TELEPHONE and the phone type is not WORK_TYPE  then in the field Tel(other) in module Accounts.

Fields from subpanel Telephone in module Accounts

Thanks

Artem.

Outcomes