Wip command center, error merge

This commit is contained in:
Daniel Barbero Martin 2021-06-16 19:37:09 +02:00
parent 81254cf3fb
commit 452d5d0b73
2 changed files with 19 additions and 43 deletions

View File

@ -108,6 +108,8 @@ function add_component_selection($id_network_component_type)
$data[0] = __('Using module component').' '; $data[0] = __('Using module component').' ';
$component_groups = network_components_get_groups($id_network_component_type); $component_groups = network_components_get_groups($id_network_component_type);
hd($component_groups);
$data[1] = '<span id="component_group" class="left">'; $data[1] = '<span id="component_group" class="left">';
$data[1] .= html_print_select( $data[1] .= html_print_select(
$component_groups, $component_groups,

View File

@ -265,6 +265,7 @@ function network_components_get_group($id_network_component_group, $filter=false
*/ */
function network_components_get_groups($id_module_components=0, $localComponent=false) function network_components_get_groups($id_module_components=0, $localComponent=false)
{ {
hd($id_module_components);
// Special vars to keep track of indentation level // Special vars to keep track of indentation level
static $level = 0; static $level = 0;
static $id_parent = 0; static $id_parent = 0;
@ -283,7 +284,7 @@ function network_components_get_groups($id_module_components=0, $localComponent=
} }
$retval = []; $retval = [];
// Magic indentation is here // Magic indentation is here.
$prefix = str_repeat('&nbsp;', ($level * 3)); $prefix = str_repeat('&nbsp;', ($level * 3));
foreach ($groups as $group) { foreach ($groups as $group) {
$level++; $level++;
@ -296,29 +297,18 @@ function network_components_get_groups($id_module_components=0, $localComponent=
$id_parent = $tmp; $id_parent = $tmp;
$level--; $level--;
hd($localComponent);
if ($localComponent) { if ($localComponent) {
if (! empty($childs)) { if (! empty($childs)) {
$retval[$group['id_sg']] = $prefix.$group['name']; $retval[$group['id_sg']] = $prefix.$group['name'];
$retval = ($retval + $childs); $retval = ($retval + $childs);
} else { } else {
switch ($config['dbtype']) { $count = db_get_value_filter(
case 'mysql': 'COUNT(*)',
case 'postgresql': 'tlocal_component',
$count = db_get_value_filter( ['id_network_component_group' => (int) $group['id_sg']]
'COUNT(*)', );
'tlocal_component',
['id_network_component_group' => (int) $group['id_sg']]
);
break;
case 'oracle':
$count = db_get_value_filter(
'count(*)',
'tlocal_component',
['id_network_component_group' => (int) $group['id_sg']]
);
break;
}
if ($count > 0) { if ($count > 0) {
$retval[$group['id_sg']] = $prefix.$group['name']; $retval[$group['id_sg']] = $prefix.$group['name'];
@ -333,30 +323,14 @@ function network_components_get_groups($id_module_components=0, $localComponent=
If components id module is provided, only groups with components If components id module is provided, only groups with components
that belongs to this id module are returned */ that belongs to this id module are returned */
if ($id_module_components) { if ($id_module_components) {
switch ($config['dbtype']) { $count = db_get_value_filter(
case 'mysql': 'COUNT(*)',
case 'postgresql': 'tnetwork_component',
$count = db_get_value_filter( [
'COUNT(*)', 'id_group' => (int) $group['id_sg'],
'tnetwork_component', 'id_modulo' => $id_module_components,
[ ]
'id_group' => (int) $group['id_sg'], );
'id_modulo' => $id_module_components,
]
);
break;
case 'oracle':
$count = db_get_value_filter(
'count(*)',
'tnetwork_component',
[
'id_group' => (int) $group['id_sg'],
'id_modulo' => $id_module_components,
]
);
break;
}
if ($count > 0) { if ($count > 0) {
$retval[$group['id_sg']] = $prefix.$group['name']; $retval[$group['id_sg']] = $prefix.$group['name'];