<div class="header-menu bg-casa-red sticky-nav d-xl-block d-none padding-0px">
    <div class="container">
        <div class="row">
            <div class="col-lg-3 custom-col-2">
                <div class="header-menu-vertical">
                    <h4 class="menu-title">Departamentos</h4>
                    <?php
                    $menu = '<ul class="menu-content display-none">';
                    $Read->ExeRead(DB_SECAO, "WHERE secao_de='ecommerce'  AND secao_status=1 ORDER BY secao_ordem ASC");
                    if ($Read->getResult()):
                        foreach ($Read->getResult() as $secao):
                            $Read->ExeRead(DB_CATEGORY, "WHERE category_parent=:pa ORDER BY category_title", "pa={$secao['secao_id']}");
                            if (!$Read->getResult()):
                                $menu .= '<li class="menu-item"> <a href="' . SITE . $secao['secao_name'] . '" title="' . $secao['secao_title'] . '">' . $secao['secao_title'] . '</a></li>';
                            else:
                                $menu .= '<li class="menu-item"> <a href="' . SITE . $secao['secao_name'] . '" title="' . $secao['secao_title'] . '" >' . $secao['secao_title'] . ' <i class="ion-ios-arrow-right"></i></a> ';
                                $count = 0;
                                $submenu = '<ul class="sub-menu flex-wrap">';
                                $subsubmenu = '<ul class="sub-menu sub-menu-2"><li><ul class="submenu-item">';
                                foreach ($Read->getResult() as $category):
                                    $Read->ExeRead(DB_CATEGORY, "WHERE category_para=:ca AND category_parent=:pa ORDER BY category_title", "ca={$category['category_id']}&pa={$secao['secao_id']}");
                                    $result_subcategoria = $Read->getResult();
                                    if (!$result_subcategoria):
                                        $subsubmenu .= '<li class="menu-item"> <a href="' . SITE . $secao['secao_name'] . DIRECTORY_SEPARATOR . $category['category_name'] . '" title="' . $category['category_title'] . '">' . $category['category_title'] . '</a></li>';
                                        $submenu .= '<li>  <a href="' . SITE . $secao['secao_name'] . DIRECTORY_SEPARATOR . $category['category_name'] . '" title="' . $category['category_title'] . '"><span> <strong>' . $category['category_title'] . '</strong></span></a>  <ul class="submenu-item">';

                                    else:

                                        $submenu .= '<li>  <a href="' . SITE . $secao['secao_name'] . DIRECTORY_SEPARATOR . $category['category_name'] . '" title="' . $category['category_title'] . '"><span> <strong>' . $category['category_title'] . '</strong></span></a>  <ul class="submenu-item">';
                                        $count2 = 0;
                                        foreach ($result_subcategoria as $subcategory):
                                            $submenu .= ' <li><a href="' . SITE . $secao['secao_name'] . DIRECTORY_SEPARATOR . $subcategory['category_name'] . '" title="' . $subcategory['category_title'] . '">' . $subcategory['category_title'] . '</a></li>';
                                            $count2++;
                                        endforeach;

                                    endif;
                                    $submenu .= '</ul></li>';
                                    $count++;
                                endforeach;
                                $image_secao = ($secao['secao_cover_menu'] ? '<div class="img-secao"><a href="' . SITE . $secao['secao_name'] . '" ><img src="' . Check::CheckPhoto($secao['secao_cover_menu'], DIR_UPLOADS, true) . '" class="img-fluid"/></a></div>' : '');
                                $submenu .= $image_secao . '</ul>';
                                $subsubmenu .= "</ul></li></ul>";
                                $menu .= ($submenu ? $submenu : $subsubmenu);
//                                        var_dump($Read->getResult());
//                                if (!$result_subcategoria):
//                                    $menu .= '<li class="menu-item"><a href="' . SITE . $secao['secao_name'] . DIRECTORY_SEPARATOR . $category['category_name'] . '" title="' . $category['category_title'] . '">' . $category['category_title'] . '</a></li>';
//                                else:
//                                    $menu .= '<ul class="sub-menu flex-wrap">' . $submenu . "</ul></li>";
//                                endif;
                                $menu .= "</li>";
                            endif;
                        endforeach;
                    endif;
                    $menu .= "</ul> ";
                    echo $menu;
                    ?>

                </div>
            </div>
        </div><!-- comment -->
    </div>
</div>
