<?php

use Source\Helpers\Check;
?>

<!-- Mobile Header Section Start -->
<div class="mobile-header animated d-xl-none sticky-nav ptb-10px">
    <div class="container">
        <div class="row align-items-center justify-content-between">
            <!-- Header Logo Start -->
            <div class="mobile-left">
                <div class="header-tools justify-content-end">                  
                    <div class="mobile-menu-toggle">
                        <a href="#offcanvas-mobile-menu" class="offcanvas-toggle">
                            <svg viewBox="0 0 800 600">
                            <path d="M300,220 C300,220 520,220 540,220 C740,220 640,540 520,420 C440,340 300,200 300,200" id="top"></path>
                            <path d="M300,320 L540,320" id="middle"></path>
                            <path d="M300,210 C300,210 520,210 540,210 C740,210 640,530 520,410 C440,330 300,190 300,190" id="bottom" transform="translate(480, 320) scale(1, -1) translate(-480, -318) "></path>
                            </svg>
                        </a>
                    </div>
                </div>
            </div>
            <!-- Header Logo End -->
            <!-- Header Logo Start -->
            <div class="mobile-center">
                <div class="header-logo">
                    <a href="<?= SITE ?>"><img class="img-responsive" style="max-width: 200px" src="<?= LOGO_MOBILE ?>" alt="<?= SITENAME ?>" /></a>
                </div>
            </div>
            <!-- Header Logo End -->

            <!-- Header Tools Start -->
            <div class="mobile-right">
                <div class="cart-info d-flex align-self-center">                                    
                    <?php if (LOOJA_MODO == 1): ?>   
                        <a href="#offcanvas-telefone" class="offcanvas-toggle"><i class="icon-phone"></i></a>
                        <a href="#offcanvas-cart" class="bag offcanvas-toggle"><i class="icon-bag"></i><label class="cart-count">0</label></a>
                    <?php else: ?> 
                        <a href="#offcanvas-wishlist" class="heart offcanvas-toggle"><i class="icon-heart"></i><label class="heart-count">0</label></a> 
                        <?php if(CONF_B2B_STATUS && is_auth() || !CONF_B2B_STATUS): ?>
                            <a href="#offcanvas-cart" class="bag offcanvas-toggle"><i class="icon-bag"></i><label class="cart-count">0</label></a>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>   
            </div>
            <!-- Header Tools End -->
        </div>
    </div>

    <!-- Search Category Start -->
    <div class="mobile-search-area d-xl-none mb-10px">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="search-element media-body" itemscope itemtype="https://schema.org/WebSite">
                        <meta itemprop="title" content="Pesquisar produtos <?= SITENAME ?>"/>
                        <link itemprop="url" href="<?= SITE ?>"/>
                        <form class="d-flex" action="#" method="POST" itemprop="potentialAction" itemscope itemtype="https://schema.org/SearchAction">   
                            <meta itemprop="target" content="<?= SITE ?>produtos?s={searchs}"/>
                            <input itemprop="query-input" type="search" autocomplete="off"  placeholder="Pesquisar algum produto, marca ou categoria " name="searchs" />
                            <button type="submit"><i class="icon-magnifier"></i></button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Search Category End -->
</div>


<!-- Search Category End -->
<?php if (1 == 2) { ?>
    <div class="mobile-category-nav d-xl-none mb-15px">
        <div class="container">
            <div class="row">
                <div class="col-md-12">

                    <!--=======  category menu  =======-->
                    <div class="hero-side-category">
                        <!-- Category Toggle Wrap -->
                        <div class="category-toggle-wrap">
                            <!-- Category Toggle -->
                            <button class="category-toggle"><i class="fa fa-bars"></i> Departamentos</button>
                        </div>

                        <!-- Category Menu -->
                        <nav class="category-menu">

                            <?php
                            $menu_mobile = '<ul>';

                            $Read->ExeRead(DB_SECAO, "WHERE secao_de='ecommerce'  AND secao_status=1 ORDER BY secao_ordem ASC");
                            if ($Read->getResult()):
                                $count_item = 1;
                                foreach ($Read->getResult() as $secao):
                                    $hidden = ($count_item > 9 ? "hidden" : '');
                                    $Read->ExeRead(DB_CATEGORY, "WHERE category_parent=:pa ORDER BY category_title", "pa={$secao['secao_id']}");
                                    if (!$Read->getResult()):

                                        $menu_mobile .= '<li class="' . $hidden . '"><a href="' . SITE . $secao['secao_name'] . '" title="' . $secao['secao_title'] . '">' . $secao['secao_title'] . '</a></li>';
                                    else:

                                        $menu_mobile .= '<li class="' . $hidden . ' menu-item-has-children menu-item-has-children-' . $secao['secao_id'] . '" data-id="' . $secao['secao_id'] . '"><a href="#" title="' . $secao['secao_title'] . '">' . $secao['secao_title'] . '<i class="ion-ios-arrow-down"></i></a>';

                                        $count = 0;
                                        $submenu_mobile = '<ul class="category-mega-menu category-mega-menu-' . $secao['secao_id'] . '">';

                                        foreach ($Read->getResult() as $category):

                                            $submenu_mobile .= '<li><a href="' . SITE . $secao['secao_name'] . DIRECTORY_SEPARATOR . $category['category_name'] . '" title="' . $category['category_title'] . '">' . $category['category_title'] . '</a></li>';

                                            $count++;
                                        endforeach;
                                        $submenu_mobile .= $image_secao . '</ul>';

                                        $menu_mobile .= ($submenu_mobile ? $submenu_mobile : $subsubmenu);

                                        $menu_mobile .= "</li>";
                                    endif;
                                    $count_item++;
                                endforeach;
                            endif;
                            $menu_mobile .= "<li> <a href='#' id='more-btn'><i class='ion-ios-plus-empty' aria-hidden='true'></i> Mais Categorias</a> </li>";
                            $menu_mobile .= "</ul>";
                            $menu_mobile;
                            ?>                      
                        </nav>
                    </div>

                    <!--=======  End of category menu =======-->
                </div>
            </div>
        </div>
    </div>
<?php } ?>
<!-- Mobile Header Section End -->
<!-- OffCanvas Wishlist Start -->
<div id="offcanvas-wishlist" class="offcanvas offcanvas-wishlist ">
    <div class="inner">
        <div class="head">
            <span class="title">Lista de Desejos</span>
            <button class="offcanvas-close">×</button>
        </div>
        <div class="body customScroll">
            <ul class="minicart-product-list lista-desejos">


            </ul>
        </div>
        <div class="foot">
            <div class="buttons">
                <a href="<?= BASECLIENTE ?>wishlist" class="btn btn-dark btn-hover-primary mt-30px">Ver toda lista</a>
            </div>
        </div>
    </div>
</div>
<!-- OffCanvas Wishlist End -->
<!-- OffCanvas Wishlist Start -->
<div id="offcanvas-telefone" class="offcanvas offcanvas-wishlist ">
    <div class="inner">
        <div class="head">
            <span class="title">Telefones para contato</span>
            <button class="offcanvas-close">×</button>
        </div>
        <div class="list-group list-group-flush listagem-telefones">
            <?php if (CONF_EMP_TELEFONE_1): ?>
                <small>Telefone 1</small>
                <a href="tel://<?= formatarTel(CONF_EMP_TELEFONE_1) ?>" class="list-group-item"><i class="fa fa-phone"></i> <?= CONF_EMP_TELEFONE_1 ?></a>
            <?php endif; ?>
            <?php if (CONF_EMP_TELEFONE_2): ?>
                <small>Telefone 2</small>
                <a href="tel://<?= formatarTel(CONF_EMP_TELEFONE_2) ?>" class="list-group-item"><i class="fa fa-phone"></i> <?= CONF_EMP_TELEFONE_2 ?></a>
            <?php endif; ?>
            <?php if (CONF_EMP_TELEFONE_3): ?>
                <small>Teleatendimento</small>
                <a href="tel://<?= formatarTel(CONF_EMP_TELEFONE_3) ?>" class="list-group-item"><i class="fa fa-phone"></i> <?= CONF_EMP_TELEFONE_3 ?></a>
            <?php endif; ?>
            <?php if (CONF_EMP_TELEFONE_WHATSAPP): ?>
                <small>Telefone whatsapp</small>
                <a href="https://wa.me/<?= formatarTel(CONF_EMP_TELEFONE_WHATSAPP) ?>" class="list-group-item"><i class="fa fa-whatsapp"></i> <?= CONF_EMP_TELEFONE_WHATSAPP ?></a>
            <?php endif; ?>
        </div>       
    </div>
</div>
<!-- OffCanvas Wishlist End -->

<!-- OffCanvas Cart Start -->
<div id="offcanvas-cart" class="offcanvas offcanvas-cart ">
    <div class="inner">      
        <?php if (LOOJA_MODO == 1): ?>
            <div class="head">
                <span class="title">Lista de Produtos</span>
                <button class="offcanvas-close">×</button>
            </div>
            <div class="body  ">
                <ul class="minicart-product-list lista-whatslist">

                </ul>
            </div>
            <div class="foot">
                <div class="sub-total">
                    <!--<strong>Subtotal : <span class="subtotal-carrinho">R$ 0,00</span></strong>-->
                    <span class="amount total-carrinho">R$ 0,00</span>
                </div>
                <div class="buttons">
                    <a href="" class="btn btn-whatsapp mb-30px whatslist-link-vendedor" target="_blank"><i class="fa fa-whatsapp"></i>  ENVIAR AO VENDEDOR</a>
                    <a href="" class="btn btn-whatsapp current-btn whatslist-link-compartilhar" target="_blank"><i class="fa fa-whatsapp"></i> COMPARTILHAR</a>
                </div>
                <!--<p class="minicart-message">Frete grátis nas compras acima de R$ 400!</p>-->
            </div>
        <?php else: ?>
            <div class="head">
                <span class="title">Meu carrinho</span>
                <button class="offcanvas-close">×</button>
            </div>
            <div class="body  ">
                <ul class="minicart-product-list lista-carrinho">

                </ul>
            </div>
            <div class="foot">
                <div class="sub-total">
                    <div><strong>Subtotal <span class="subtotal-carrinho">R$ 0,00</span></strong></div>
                    <span></span>
                    <div><strong class="desconto-carrinho">Desconto <span class="">R$ 0,00</span></strong></div>
                    <span></span>
                    <div><strong class="frete-carrinho-total">Frete <span class="">R$ 0,00</span></strong></div>
                    <span></span>
                    <div>Total <span class="amount total-carrinho">R$ 0,00</span></div>
                </div>
                <div class="buttons">
                    <a href="<?= SITE ?>carrinho" class="btn btn-dark btn-hover-primary mb-30px">VER CARRINHO</a>
                    <?php if (LOOJA_MODO == 2): ?> 
                        <a href="<?= SITE ?>finalizar-compra-whatsapp" class="btn btn-outline-dark current-btn">Finalizar carrinho</a>                                
                    <?php else: ?> 
                        <a href="<?= SITE ?>in-checkout/payment" class="btn btn-outline-dark current-btn">Finalizar carrinho</a>
                    <?php endif; ?>  
                </div>
                <!--<p class="minicart-message">Frete grátis nas compras acima de R$ 400!</p>-->
            </div>
        <?php endif; ?>


    </div>
</div>
<!-- OffCanvas Cart End -->

<!-- OffCanvas Search Start -->
<div id="offcanvas-mobile-menu" class="offcanvas offcanvas-mobile-menu ">
    <div class="inner customScroll">
        <div class="head">
            <span class="title"><img src='<?= LOGO ?>' class="img-responsive" height="45"></span>
            <button class="offcanvas-close">×</button>
        </div>
        <!--        <div class="offcanvas-menu-search-form">
                    <form action="#" method="POST">
                        <input type="text" name="search" placeholder="Buscar">
                        <button><i class="icon-magnifier"></i></button>
                    </form>
                </div>-->
        <div class="offcanvas-menu">
            <ul>

                <?php
                $menu_mobile = '';

                $Read->ExeRead(DB_SECAO, "WHERE secao_de='ecommerce'  AND secao_status=1 ORDER BY secao_ordem ASC");
                if ($Read->getResult()):
                    $count_item = 1;
                    foreach ($Read->getResult() as $secao):
                        $hidden = ($count_item > 9 ? "hidden" : '');
                        $Read->ExeRead(DB_CATEGORY, "WHERE category_parent=:pa ORDER BY category_title", "pa={$secao['secao_id']}");
                        if (!$Read->getResult()):

                            $menu_mobile .= '<li class="' . $hidden . '"><a href="' . SITE . $secao['secao_name'] . '" title="' . $secao['secao_title'] . '">' . $secao['secao_title'] . '</a></li>';
                        else:

                            $menu_mobile .= '<li class="' . $hidden . '  ' . $secao['secao_id'] . '" data-id="' . $secao['secao_id'] . '"><a href="#" title="' . $secao['secao_title'] . '"><span class="menu-text">' . $secao['secao_title'] . '</span></a>';

                            $count = 0;
                            $submenu_mobile = '<ul class=" sub-menu ' . $secao['secao_id'] . '">';

                            foreach ($Read->getResult() as $category):

                                $submenu_mobile .= '<li><a href="' . SITE . $secao['secao_name'] . DIRECTORY_SEPARATOR . $category['category_name'] . '" title="' . $category['category_title'] . '">' . $category['category_title'] . '</a></li>';

                                $count++;
                            endforeach;
                            $submenu_mobile .= $image_secao . '</ul>';

                            $menu_mobile .= ($submenu_mobile ? $submenu_mobile : $subsubmenu);

                            $menu_mobile .= "</li>";
                        endif;
                        $count_item++;
                    endforeach;
                endif;


                echo $menu_mobile;
                ?>
            </ul> 
            <ul class="footer-menu-mobile"> 
                <?php if (LOOJA_MODO != 1): ?>  
                    <?php if ($USER): ?>  
                        <li><a href="<?= BASECLIENTE . "" ?>" class="user"><i class="icon-edit"></i>  <?= $USER['user_name'] ?></a></li>
                        <li><a href="<?= BASECLIENTE . "compras" ?>"><i class="icon-bag"></i> Minhas compras</a></li>
                        <li><a href="<?= BASECLIENTE . "&logoff=true" ?>"><i class="icon-logout"></i> Sair</a></li>

                    <?php else: ?>
                        <li><a href="<?= BASECLIENTE . "login" ?>"><i class="icon-login"></i> Entre</a> </li>
                        <li><a href="<?= BASECLIENTE . "cadastro" ?>"><i class="icon-login"></i> Cadastre-se</a>    </li>                              
                    <?php endif; ?>
                    <li><a href="<?= BASECLIENTE ?>" title="Minha Conta" alt="Minha conta"><i class="icon-pencil"></i> Minha conta</a></li>
                    <li><a href="<?= BASECLIENTE . "pedidos" ?>" title="Meus pedidos" alt="Meus pedidos"><i class="icon-bag"></i> Meus pedidos</a></li>
                    <li><a href="<?= BASECLIENTE . "wishlist" ?>" title="Meus Favoritos" alt="Meus Favoritos"><i class="icon-heart"></i> Meus favoritos</a></li>
                <?php endif; ?> 
            </ul> 
        </div>

        <div class="offcanvas-social mt-30px">
            <ul>
                <?php if (APP_FACE_AUTHOR): ?>
                    <li>
                        <a href="https://facebook.com/<?= APP_FACE_AUTHOR ?>" title="Página no facebook"><i class="fa fa-facebook"></i></a>
                    </li>
                    <?php
                endif;
                if (APP_TWITTER_CREATOR):
                    ?>
                    <li>
                        <a href="https://twitter.com/<?= APP_TWITTER_CREATOR ?>" title="Página no Twitter"><i class="ion-social-twitter"></i></a>
                    </li> 
                    <?php
                endif;
                if (INSTAGRAM_USER):
                    ?>
                    <li>
                        <a href="https://instagram.com/<?= INSTAGRAM_USER ?>" title="Página no facebook"><i class="fa fa-instagram"></i></a>
                    </li>
                <?php endif; ?>
            </ul>
        </div>
    </div>
</div>
<!-- OffCanvas Search End -->

<div class="offcanvas-overlay"></div>