<?php 
    $com=mysqli_query($con," SELECT count(*) as filascom from combos") or die (mysqli_error($con));
    $resulcom=mysqli_fetch_array($com);
    $filascom=$resulcom['filascom'];
    if ($filascom>0) { 
?>
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
    <a href="#" onclick="buscar_combos()" style="text-decoration:none">  
        <div class="panel panel-info ">
            <div class="panel-footer">
                <center><strong>COMBOS</strong></center>
            </div>
        </div>
    </a>
</div>
<?php } ?>


<?php 
    $pro=mysqli_query($con," SELECT count(*) as filaspro from articulos where art_tipo='producto' ") or die (mysqli_error($con));
    $resulpro=mysqli_fetch_array($pro);
    $filaspro=$resulpro['filaspro'];
    if ($filaspro>0) { 
?>
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
    <a href="#" onclick="buscar_productos()" style="text-decoration:none">  
        <div class="panel panel-info ">
            <div class="panel-footer">
                <center><strong>PRODUCTOS</strong></center>
            </div>
        </div>
    </a>
</div>
<?php } ?>


<?php 
    $ser=mysqli_query($con," SELECT count(*) as filas from articulos where art_tipo='servicio' ") or die (mysqli_error($con));
    $resul=mysqli_fetch_array($ser);
    $filas=$resul['filas'];
    if ($filas>0) { 
?>
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
    <a href="#" onclick="buscar_servicios()" style="text-decoration:none">  
        <div class="panel panel-info ">
            <div class="panel-footer" >
                <center><strong>SERVICIOS</strong></center>
            </div>
        </div>
    </a>
</div>
<?php } ?>



<?php
    $fami=mysqli_query($con,"SELECT *,LEFT(fam_nombre,18) as fam_nombre FROM familias WHERE empresa='$empresa' order by fam_nombre asc")or die(mysqli_error($con));
    while($filaf = mysqli_fetch_array($fami))
    { 
        $fam_id=$filaf['fam_id'];
        $ser1=mysqli_query($con," SELECT count(*) as filas from articulos where (art_tipo='articulo' or art_tipo='producto') and art_estado='Activo' and familias_fam_id='$fam_id' ") or die (mysqli_error($con));
        $resul1=mysqli_fetch_array($ser1);
        $filas=$resul1['filas'];

        $com=mysqli_query($con," SELECT count(*) as filascom from combos where  com_estado='Activo' and familias_fam_id='$fam_id' ") or die (mysqli_error($con));
        $resulcom=mysqli_fetch_array($com);
        $filascom=$resulcom['filascom'];
      
        $suma=$filascom+$filas;
        if ($suma>0) 
        {
    ?>
            <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
                <a href="#" title="<?php echo $filaf['fam_nombre'];?>" onclick="buscar_articulos('<?php echo $fam_id ?>')" style="text-decoration:none">  
                    <input type="hidden" id="fam_id<?php echo $fam_id;?>" value="<?php echo $fam_id; ?>" >
                    <div class="panel panel-info ">
                        <div class="panel-footer" style="padding-left:1px;padding-right:1px">
                            <center><strong> <?php echo $filaf['fam_nombre'];?></strong></center>
                        </div>
                    </div>
                </a>
            </div>
<?php  } } ?>

<script type="text/javascript">
function buscar_combos ()
{
    var pen_id=$("#pen_id").val();
    var tipo='combo';
    $.ajax({
    type: "GET",
    url: "./php_buscador/articulos_menu.php",
    data: "&pen_id="+pen_id+"&tipo="+tipo,
    beforeSend: function(objeto){
     $('#div_menu').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
    },
    success: function(datos){
    $('html, body').animate({
    scrollTop: $("#scroll").offset().top
    }, 500);
    $("#div_menu").html(datos);
    }
    });
}

function buscar_productos ()
{
    var pen_id=$("#pen_id").val();
    var tipo='productos';
    $.ajax({
    type: "GET",
    url: "./php_buscador/articulos_menu.php",
    data: "&pen_id="+pen_id+"&tipo="+tipo,
    beforeSend: function(objeto){
     $('#div_menu').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
    },
    success: function(datos){
    $('html, body').animate({
    scrollTop: $("#scroll").offset().top
    }, 500);
    $("#div_menu").html(datos);
    }
    });
}

function buscar_servicios ()
{
    var pen_id=$("#pen_id").val();
    var tipo='servicio';
    $.ajax({
    type: "GET",
    url: "./php_buscador/articulos_menu.php",
    data: "&pen_id="+pen_id+"&tipo="+tipo,
    beforeSend: function(objeto){
     $('#div_menu').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
    },
    success: function(datos){
    $('html, body').animate({
    scrollTop: $("#scroll").offset().top
    }, 500);
    $("#div_menu").html(datos);
    }
    });
}

function buscar_articulos (fam_id)
{
    var fam_id=document.getElementById('fam_id'+fam_id).value;
    var pen_id=$("#pen_id").val();
    var tipo='categorias';

    $.ajax({
    type: "GET",
    url: "./php_buscador/articulos_menu.php",
    data: "fam_id="+fam_id+"&pen_id="+pen_id+"&tipo="+tipo,
    beforeSend: function(objeto){
     $('#div_menu').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
    },
    success: function(datos){
    $('html, body').animate({
    scrollTop: $("#scroll").offset().top
    }, 500);    
    $("#div_menu").html(datos);
    }
    });
}

</script>

<style>
#notification_menu {
padding: 3px 8px 2px 8px;
background: #cc0000;
color: #ffffff;
font-weight: bold;
margin-left: 0px;
border-radius: 5px;
position: absolute;
margin-top: 0px;
font-size: 11px;
}


#notification_cantidad {
padding: 0px 4px 0px 4px; 
    background: green; 
    color: #ffffff;
    font-weight: bold;
    border-radius: 5px;
    font-size: 11px;

    position: absolute;   /* relativo al padre */
    bottom: 17px;          /* lo manda abajo */
    right:-3%;            /* centro horizontal */
    transform: translateX(-50%); /* ajusta el centro */
}
</style>
