Custom sub panel (outlook sync)

There is a table in the database which records the state of the outlook sync checkbox for each user. to create a custom subpanel for this table or another similar.

$layout_defs['Contacts']['subpanel_setup']['outlook_sync'] = array( // numeric order position of subpanel by default ( lowest number comes first )
'order' =--> 10,
'sort_by' => 'id',
'sort_order' => 'asc',
'title_key' => 'LBL_OUTLOOK_SYNC',
'subpanel_name' => 'default',
'module' => 'Users',
'get_subpanel_data' => 'function:getSubpanelQueryParts',
'generate_select' => true,
'function_parameters' => array(
'contact_id' => $this->_focus->id,
'import_function_file' => 'custom/application/Ext/Utils/custom_utils.ext.php',
'return_as_array' =>'true'
),
);
$layout_defs["Contacts"]["subpanel_setup"]["outlook_sync"]["top_buttons"];

Then add a file to “custom/application/Ext/Utils/custom_utils.ext.php”

with the following. This will select all from the current module being contacts and join on the contacts_users table and select all contact_id’s which match the contacts
id and show them in the sub panel. This will also only show contact_users records which have not be deleted.

function getSubpanelQueryParts($params)
{
$bean = $GLOBALS['app']->controller->bean;
$return_array['join'] = " INNER JOIN contacts_users cu ON cu.user_id = users.id ";
$return_array['where'] = "WHERE cu.contact_id = '" . $bean->id . "' AND cu.deleted = 0";
return $return_array;
}