Bom dia.
Eu to treinando em cima da aplicação de exemplo do Healtcare (scriptcase) e me deparei com um menu dinâmico, que conta com um form para adicionar itens a esse menu. Mas esse menu não está seguindo a ordem certa de nod e pai/mae. As informações não fica na ordem cert. Poderiam me ajudar a entender a construção desse menu, e como adicionar pais e filhos da forma correta? Agradeço.
sc_appmenu_reset(“menu”);
sc_appmenu_create(“menu”);
$sufix = “”;
$my_language = sc_get_language();
if ( $my_language != ‘en_us’ ) { $sufix = “_”.$my_language; }
$sql_a = “SELECT
id,
parent,
description”.$sufix." AS descr,
link,
node_order,
link_params
FROM menu
WHERE is_active = ‘Y’
ORDER BY 2,5";
/********************************************************************************************/
$groupDoctor = ([usr_group_id] == 2) ? “WHERE m.namedoctor = '” . [usr_name] . “’” : “”;
$sql_b = “SELECT node_order AS id,
11 AS parent,
m.namedoctor AS descr,
‘calendar_event’ AS link,
node_order,
m.iddoctor AS link_params
FROM doctors m INNER JOIN speciality e ON
(m.speciality_idspeciality = e.idspeciality)
" . $groupDoctor . "
ORDER BY 2,5”;
sc_lookup(m1,$sql_a);
sc_lookup(m2,$sql_b);
$dsmenu = array_merge({m1}, {m2});
foreach ($dsmenu as $key => $row) {
$parent[$key] = $row[‘1’];
$node_order[$key] = $row[‘4’];
}
array_multisort($parent, SORT_ASC, $node_order, SORT_ASC, $dsmenu);
sc_appmenu_add_item(“menu”, “item_0”, “”, “Dashboard”, “dashboard”, “”, “”, “”, “”);
foreach ($dsmenu as $arr_menu) {
$id_item = "item_".$arr_menu[0];
if(empty($arr_menu[1])){ $id_parent = ''; } else{ $id_parent = "item_".$arr_menu[1]; }
if($arr_menu[5] === NULL){ $param = ""; } else{ $param = $arr_menu[5]; }
$sql2 = "SELECT priv_access FROM sec_groups_apps WHERE group_id = ".[usr_group_id]." AND app_name = '".$arr_menu[3]."'";
sc_lookup(dsgrant,$sql2);
if ( empty($arr_menu[3]) || ({dsgrant[0][0]} == 'Y') ){
if ($arr_menu[3] == 'calendar_event') {
sc_appmenu_add_item("menu", $id_item, $id_parent, $arr_menu[2], $arr_menu[3], var_doctor=$param;usr_login=[usr_login], "", "","_blank");
} elseif ($arr_menu[3] == 'grid_agenda'){
sc_appmenu_add_item("menu", $id_item, $id_parent, $arr_menu[2], $arr_menu[3], var_doctor = [var_doctor], "", "","");
} else{
sc_appmenu_add_item("menu", $id_item, $id_parent, $arr_menu[2], $arr_menu[3], "", "", "","");
}
}
}
// delete Settings folder if not admin
if ([usr_group_id] != 1) {
sc_appmenu_remove_item(“menu”, “item_1”);
}
sc_appmenu_add_item(“menu”, “item_99”, “”, {lang_btns_exit}, “login”, “”, “”, “”, “_parent”);