Hello,
I have created a one-to-many relationship between the parent module cstm_Clienti
and the cstm_ClientiProdotti
module, so the cstm_Clienti
module displays a subpanel for cstm_ClientiProdotti
.
Additionally, the cstm_ClientiProdotti
module has a many-to-one relationship with the cstm_Prodotti
module and includes a quantity
field. Currently, I can select a product in the subpanel and edit the record to add quantities.
However, I would like to display additional fields from the cstm_Prodotti
module (besides just the product name) as columns in the subpanel.
I’ve edit the file cstm_clientiprodotti_cstm_clienti_cstm_Clienti.php
suitecrm/public/legacy/custom/Extension/modules/cstm_Clienti/Ext/Layoutdefs/
<?php
$layout_defs["cstm_Clienti"]["subpanel_setup"]['cstm_clientiprodotti_cstm_clienti'] = array(
'order' => 100,
'module' => 'cstm_ClientiProdotti',
'subpanel_name' => 'default',
'title_key' => 'LBL_CSTM_CLIENTIPRODOTTI_CSTM_CLIENTI_FROM_CSTM_CLIENTIPRODOTTI_TITLE',
'get_subpanel_data' => 'function:getRelatedCallsQueryData',
'function_parameters' => array(
'import_function_file' => 'custom/modules/cstm_Clienti/getCallsSubpanelData.php',
),
'top_buttons' => array(
array('widget_class' => 'SubPanelTopButtonQuickCreate'),
array('widget_class' => 'SubPanelTopSelectButton', 'mode' => 'MultiSelect'),
),
'list_fields' => array(
'name' => array(
'vname' => 'LBL_NAME',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '15%',
),
'brand' => array(
'vname' => 'LBL_BRAND',
'type' => 'varchar',
'width' => '10%',
'source' => 'non-db',
),
'category' => array(
'vname' => 'LBL_CATEGORY',
'type' => 'varchar',
'width' => '10%',
'source' => 'non-db',
),
'quantity' => array(
'vname' => 'LBL_QUANTITY',
'type' => 'int',
'width' => '10%',
),
),
);
To fetch data for the subpanel, I implemented the function getRelatedCallsQueryData
:
<?php
function getRelatedCallsQueryData($params){
$bean = $GLOBALS['app']->controller->bean;
$query = " SELECT id, name, brand, category, quantity, distributore FROM subpanelClientiProdotti WHERE subpanelClientiProdotti.id_cliente = '{$bean->id}'";
return $query;
}
Here, subpanelClientiProdotti
is a database view that performs a more complex query to aggregate all the necessary data. I have tested the query, and it works correctly.
However, after running Repair and Rebuild, the additional fields (brand
and category
) are still not displayed in the subpanel.