Hello to everyone.
I have a problem with a custom subpanel in a custom module. The subpanel seems to get the data correctly, but there’s an issue. The first time I click the subpanel it doesn’t show any data. It’s not until I reload the page the data shows.
That’s The code I’m using for the layout defs:
$layout_defs['act_Empleados']['subpanel_setup']['act_empleados_act_vacaciones_empleados'] = array(
'order' => 100,
'module' => 'act_vacaciones_empleados',
'subpanel_name' => 'default',
'sort_by' => 'date_entered',
'sort_order' => 'desc',
'title_key' => 'LBL_ACT_EMPLEADOS_ACT_VACACIONES_EMPLEADOS',
'get_subpanel_data' => 'function:getEmployeeHolidays',
'add_subpanel_data' => 'act_vacaciones_empleados_id',
'generate_select' => false,
'top_buttons' => array(),
'function_parameters' => array(
'import_function_file' => 'custom/modules/act_vacaciones_empleados/subpanelFunctions.php',
'employee_id' => $this->_focus->id,
'return_as_array' => 'false'
),
);
I would say that the query is also working well, but I will put the code too, just in case:
function getEmployeeHolidays($params) {
$employeeId = $params['employee_id'];
$query = " SELECT act_vacaciones_empleados.*, DATEDIFF(act_vacaciones_empleados.fecha_fin, act_vacaciones_empleados.fecha_inicio)+1 AS calculated_days FROM act_vacaciones_empleados
WHERE id_empleado = '$employeeId' ";
return $query;
}
That’s what the subpanel looks like when it doesn’t load the data the first time I open it: