} // link to add a new node if (!isset($_REQUEST['action'])) { $tool_content .= action_bar(array(array('title' => $langAdd, 'url' => "{$_SERVER['SCRIPT_NAME']}?action=add", 'icon' => 'fa-plus-circle', 'level' => 'primary-label', 'button-class' => 'btn-success'), array('title' => $langBack, 'url' => "{$_SERVER['SCRIPT_NAME']}", 'icon' => 'fa-reply', 'level' => 'primary-label'))); } else { $tool_content .= action_bar(array(array('title' => $langBack, 'url' => "{$_SERVER['SCRIPT_NAME']}", 'icon' => 'fa-reply', 'level' => 'primary-label'))); } // Display all available nodes if (!isset($_GET['action'])) { // Count available nodes $nodesCount = Database::get()->querySingle("SELECT COUNT(*) as count from hierarchy")->count; $query = "SELECT max(depth) as maxdepth FROM (SELECT COUNT(parent.id) - 1 AS depth\n FROM `hierarchy` AS node, `hierarchy` AS parent\n WHERE node.lft BETWEEN parent.lft AND parent.rgt\n GROUP BY node.id\n ORDER BY node.lft) AS hierarchydepth"; $maxdepth = Database::get()->querySingle($query)->maxdepth; // Construct a table $tool_content .= "\n <table class='table-default'>\n <tr>\n <td colspan='" . ($maxdepth + 4) . "' class='right'>\n {$langManyExist}: <b>{$nodesCount}</b> {$langHierarchyNodes}\n </td>\n </tr>"; $xmldata = str_replace('"', '\\"', $tree->buildTreeDataSource(array('codesuffix' => true, 'defaults' => $user->getDepartmentIds($uid), 'allow_only_defaults' => !$is_admin))); $initopen = $tree->buildJSTreeInitOpen(); $head_content .= <<<hContent <script type="text/javascript"> /* <![CDATA[ */ \$(function() { \$( "#js-tree" ).jstree({ "plugins" : ["xml_data", "themes", "ui", "cookies", "types", "sort", "contextmenu"], "xml_data" : { "data" : "{$xmldata}", "xsl" : "nest" }, "core" : { "animation": 300,