<div class="off_canvars_overlay">
</div>
<div class="Offcanvas_menu">
    <div class="container">
        <div class="row">
            <div class="col-12">
                <div class="canvas_open">
                    <span>MENU</span>
                    <a href="javascript:void(0)"><i class="ion-navicon"></i></a>
                </div>
                <div class="Offcanvas_menu_wrapper">
                    <div class="canvas_close">
                        <a href="javascript:void(0)"><i class="ion-android-close"></i></a>
                    </div>
                    <?php
                    $centrar2 = mysqli_query($con, "SELECT * FROM empresa where emp_id='$emp_id' ") or die(mysqli_error($con));
                    $cero2 = mysqli_fetch_array($centrar2);
                    $emp_id = $cero2['emp_id'];
                    $emp_nombre = utf8_encode($cero2['emp_nombre']);
                    ?>
                    <div class="welcome_text">
                        <p>Bienvenidos a <span><?php echo utf8_encode($emp_nombre); ?></span> </p>
                    </div>
                    <div class="top_right">
                        <ul>
                            <?php
                            if (isset($_SESSION['clie_id'])) {
                                $registros = mysqli_query($con, "SELECT * FROM cliente WHERE empresa='$emp_id' and clie_id='" . $_SESSION["clie_id"] . "' ") or die(mysqli_error($con));
                                while ($fila = mysqli_fetch_array($registros)) {
                                    $nombre = $fila['clie_nombre'];
                                }

                                $numero = mysqli_num_rows($registros);
                                if ($numero > 0) { ?>
                                    <li class="top_links"><a href="mi_cuenta.php"><i class="zmdi zmdi-account"></i>&nbsp;<?php echo $nombre; ?> <i class="zmdi zmdi-caret-down"></i></a>
                                        <ul class="dropdown_links">
                                            <li><a href="php_cuenta/cerrar_sesion.php">Cerrar Sesión</a></li>
                                        </ul>
                                    <?php
                                }
                            } else {
                                    ?>
                                    <!--<li class="top_links"><a href="login.php"><i class="zmdi zmdi-account"></i>Iniciar Sesion <i class="zmdi zmdi-caret-down"></i></a>-->
                                    <li class=""> <a data-id="" data-bs-toggle="modal" data-bs-target="#modal_box_sesion"> INICIAR SESION</a></li>
                                <?php
                            }
                                ?>
                                </li>
                        </ul>
                    </div>
                    <div class="search-container">
                        <form action="resultados_buscador.php">
                            <div class="search_box">
                                <input id="buscando" name="buscando" onclick="autocompletar2()" onkeyup="autocompletar2()" autocomplete="off" placeholder="Buscar..." type="text">
                                <ul style="position: absolute; z-index:1000;" id="mylista2">
                                </ul>
                                <button type="submit"><i class="zmdi zmdi-search"></i></button>
                            </div>
                        </form>
                    </div>
                    <div class="col-lg-12">
                        <div class="header_middle_inner">
                            <div class="mini_cart_wrapper action_links">
                                <?php if (isset($_SESSION['clie_id'])) {
                                    $clie_id = $_SESSION['clie_id'];
                                    $casa = mysqli_query($con, "SELECT cotd_art_id FROM cotizacion_detalle_deseo WHERE clie_id='$clie_id'");
                                    $roww1 = mysqli_fetch_array($casa);
                                    // $cotd_art_id = $roww1['cotd_art_id'];
                                    $cotd_art_id = (isset($roww1['cotd_art_id']) && !empty($roww1['cotd_art_id'])) ? $roww1['cotd_art_id'] : NULL;
                                    if ($cotd_art_id <> null) {
                                ?>
                                        <span id="notification_count1">
                                            <?php
                                            $sqll = mysqli_query($con, "SELECT count(cotd_art_id) AS numrows FROM cotizacion_detalle_deseo WHERE clie_id='$clie_id'");
                                            if ($roww = mysqli_fetch_array($sqll)) {
                                                echo  $numrows = $roww['numrows'];
                                            }
                                            ?>
                                        </span><?php
                                            }
                                        } ?>




                                <ul>
                                    <li class="wishlist">
                                        <?php if (isset($_SESSION['clie_id'])) { ?>
                                            <a href="deseos.php">
                                                <i class="fa fa-heart-o" aria-hidden="true"></i>
                                            </a>
                                        <?php } else { ?>
                                            <a data-bs-toggle="modal" data-bs-target="#modal_box_sesion">
                                                <i class="fa fa-heart-o" aria-hidden="true"></i>
                                            </a>
                                        <?php } ?>
                                    </li>
                                </ul>






                            </div>
                            <div class="mini_cart_wrapper action_links" onmouseover="consultar_carrito();">
                                <?php if (isset($_SESSION['carrito'])) {
                                    $carrito_mio = $_SESSION['carrito'];
                                    $total = 0;
                                    $total_cantidades = 0;

                                    for ($i = 0; $i <= count($carrito_mio) - 1; $i++) {
                                        if (isset($carrito_mio[$i])) {
                                            if ($carrito_mio[$i] != NULL) {
                                                $cantidad_agregada = $carrito_mio[$i]['cantidad'];
                                                $total_cantidades += $cantidad_agregada;
                                            }
                                        }
                                        if ($total_cantidades != 0) { ?>
                                            <span id="notification_count2"><?php echo $total_cantidades; ?></span>
                                <?php
                                        }
                                    }
                                }
                                ?>
                                <ul>
                                    <li class="wishlist">
                                        <a href="cart.php">
                                            <i class="fa fa-shopping-cart"></i>
                                        </a>
                                    </li>
                                    <div class="mini_cart">
                                        <div id="mi_carrito"></div>
                                        <div class="mini_cart_footer">
                                            <div class="cart_button">
                                                <a href="cart.php">Ver carrito</a>
                                            </div>
                                        </div>
                                    </div>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div id="menu" class="text-left ">
                        <ul class="offcanvas_main_menu">
                            <li class="menu-item-has-children active">
                                <a href="index.php">Inicio</a>
                            </li>
                            <li class="menu-item-has-children">
                                <a href="tienda.php">Tienda</a>
                            </li>
                            <li class="menu-item-has-children">
                                <a href="mi_cuenta.php">mi cuenta</a>
                            </li>



                            <?php
                            $artic = mysqli_query($con, "SELECT * FROM articulos WHERE empresa = '$emp_id'");
                            $hayPromo = false;

                            while ($art = mysqli_fetch_array($artic)) {
                                if ($art['art_promo_desc'] > 0) {
                                    $hayPromo = true;
                                    break; // Salir del bucle al encontrar la primera promoción
                                }
                            }

                            if ($hayPromo) {
                            ?>
                                <li class="menu-item-has-children">
                                    <a href="articulos_promociones.php"> Promociones</a>
                                </li>
                            <?php
                            }
                            ?>


                            <?php if ($negocio_neg_id == '5') { ?>
                                <li class="menu-item-has-children">
                                    <a href="barberia.php">Reserva</a>
                                </li>
                            <?php }   ?>


                            <li class="menu-item-has-children">
                                <a href="contacto.php"> Contactanos</a>
                            </li>






                            <!--<li class="menu-item-has-children">
                        
                                <a href="hoteles.php">RESERVA hotel</a>
                            </li>

                            <li class="menu-item-has-children"><a href="canchas.php">RESERVA cancha</a>  </li> -->
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function autocompletar2() {
        var minimo_letras = 0;
        var palabra = $('#buscando').val();
        if (palabra.length > minimo_letras) {
            $.ajax({
                url: 'php_tienda/buscar.php',
                type: 'POST',
                data: {
                    palabra
                },
                success: function(data) {
                    $('#mylista2').show();
                    $('#mylista2').html(data);

                }
            });
        } else {
            $('#mylista2').hide();
        }
    }

    function cerrar2() {
        $('#mylista2').hide();
    }
</script>

<script type="text/javascript">
    function consultar_carrito() {
        var parametros = {};
        $.ajax({
            data: parametros,
            type: 'POST',
            url: './php_tienda/modal_carrito.php',
            success: function(data) {
                document.getElementById("mi_carrito").innerHTML = data;
            }
        });
    }
</script>

</html>

<!--Offcanvas menu area end-->
<style type="text/css">
    #notification_count1 {
        padding: 1px 8px 1px 8px;
        background: #cc0000;
        color: #ffffff;
        font-weight: bold;
        margin-left: 9px;
        border-radius: 100px;
        position: absolute;
        margin-top: -12px;
        font-size: 10px;
    }

    #notification_count2 {
        padding: 1px 8px 1px 8px;
        background: #cc0000;
        color: #ffffff;
        font-weight: bold;
        margin-left: 9px;
        border-radius: 100px;
        position: absolute;
        margin-top: -12px;
        font-size: 10px;
    }
</style>