<?php

return _get_menu_list();

// helpers
function _get_menu_list() {
    $main_items = [
        'order',
        'product',
        'customer',
        'marketing',
        //'investor_relation',
        'article',
        'job',
        'pcbuilder',
        'payinstall',
        'distributor',
        'report',
        'system',
    ];

    $menu_list = [];
    foreach ($main_items as $item) {
        $item_menu = include_once __DIR__."/menu_item/".$item.".php";

        // skip not enabled
        if(!$item_menu['enable']) continue;

        // skip not enabled children
        $item_menu_children_enabled = array_filter($item_menu['menu'], function ($menu_child) { return $menu_child['enable'];});
        if(!sizeof($item_menu_children_enabled)) continue;

        // reset menu for $item_menu
        $item_menu['menu'] = $item_menu_children_enabled;

        $menu_list[$item] = $item_menu;
    }


    return $menu_list;
}
