<!--pt start -->
<div class="panel panel-default">
    <div class="panel-headingnew"> Menu Module Management</div>
    <div class="checkbox_error"></div>
    <div id="faq-1-3" class="panel-collapse collapse in" aria-expanded="false" >
        <div class="box">
            <div class="box-body table-responsive">

            <input type="hidden" id="id">

                <div class="dd" id="nestable">
                    <?php
                    $ref = [];
                    $items = [];


                    foreach ($modulelisting as $data) {

                        $thisRef = &$ref[$data['module_id']];

                        $thisRef['parent'] = $data['parent_id'];
                        $thisRef['label'] = $data['module_name'];
                        $thisRef['link'] = $data['url'];
                        $thisRef['id'] = $data['module_id'];

                        if ($data['parent_id'] == 0) {
                            $items[$data['module_id']] = &$thisRef;
                        } else {
                            $ref[$data['parent_id']]['child'][$data['module_id']] = &$thisRef;
                        }
                    }

                    function get_menu($items, $class = 'dd-list') {

                        $html = "<ol class=\"" . $class . "\" id=\"menu-id\">";

                        foreach ($items as $key => $value) {
                            $html .= '<li class="dd-item dd3-item" data-id="' . $value['id'] . '" >
                    <div class="dd-handle dd3-handle"></div>
                    <div class="dd3-content"><span id="label_show' . $value['id'] . '">' . $value['label'] . '</span>
                        <span class="span-right">/<span id="link_show' . $value['id'] . '">' . $value['link'] . '</span> &nbsp;&nbsp;
                            <a class="edit-button" id="' . $value['id'] . '" label="' . $value['label'] . '" link="' . $value['link'] . '" href="master-module/add-module?id='.$value['id'] . '"><i class="fa fa-pencil"></i></a>
                        </span>
                    </div>';
                            if (array_key_exists('child', $value)) {
                                $html .= get_menu($value['child'], 'child');
                            }
                            $html .= "</li>";
                        }
                        $html .= "</ol>";

                        return $html;
                    }

                    print get_menu($items);
                    ?>
                </div>

            <p></p>
            <input type="hidden" id="nestable-output">

            </div></div></div></div>

  <!--pt End -->
