<?php
session_start();
 include('conexion.php');
 $mar_id = $_GET['mar_id'];
?>
<!doctype html>
<html  lang="en" onclick="cerrar();cerrar2()"; >
<head>
    <?php
        include('./include/sesiones.php');
        include('include/head.php');
         ?>
        <div id="div_buscador"></div>
        <?php
        include('php_menu/menu_categorias.php');
        include('php_menu/menu_izquierdo.php');
    ?>
</head>
<body>   
<br>
<section class="home_product_area mb-50">
    <div class="container">
        <div class="row">
            <div class="col-12">
                <div class="section_title" id="marcas">
                    <div id="resultados_nombre"></div>
                </div>
                <div class="shop_area shop_sidebar  mb-50"></h2>
                    <div class="row">
                        <div class="col-lg-9 col-md-12">
                            <div class="shop_toolbar_wrapper">
                                <div class="shop_toolbar_btn">
                                    <button data-role="grid_3" type="button" class="active btn-grid-3" data-bs-toggle="tooltip" title="3"></button>
                                    <button data-role="grid_4" type="button"  class=" btn-grid-4" data-bs-toggle="tooltip" title="4"></button>
                                    <button data-role="grid_list" type="button"  class="btn-list" data-bs-toggle="tooltip" title="List"></button>
                                </div>
                            </div>
                            <div class='filter_data'></div>
                        </div>
                        <div class="col-lg-3 col-md-12">
                            <div class="widget_list widget_filter">
                                <aside class="sidebar_widget">
                                    <div class="widget_list widget_categories">
                                        <h2>marcas</h2>
                                        <ul>
                                            <?php
                                                $mar1=mysqli_query($con,"SELECT * from marca where empresa='$emp_id' ") or die(mysqli_error($con));
                                                while ($mar=mysqli_fetch_array($mar1))
                                                { 
                                                    $mar_id2=$mar['mar_id'];
                                                    if($mar_id==$mar_id2)
                                                    {
                                                        $checked='checked';
                                                    }
                                                    else
                                                    {
                                                        $checked='';
                                                    }
                                            ?>
                                                <div class="list-group-item "> 
                                                    <input type="checkbox" id="<?php echo $mar['mar_id']; ?>" class="common_selector mar_id checkbox" value="<?php echo $mar['mar_id']; ?>" <?php echo $checked; ?> >
                                                    <label onclick="consultar_nombre();" for="<?php echo $mar['mar_id']; ?>"> <?php echo $mar['mar_nombre']; ?>
                                                    </label>
                                                </div> 
                                            <?php  }  ?>
                                        </ul>
                                   </div>
                               </aside>
                           </div>
                       </div>
                   </div>
                </div>
            </div>
       </div>
    </div>
</section>
</body>
<div id="resultados"></div>
 <input type="hidden" id="mar_id" name="mar_id" value="<?php echo $mar_id; ?>">
<?php include('include/footer.php')?>
<script src="assets/js/plugins.js"></script>
<script src="assets/js/main.js"></script>
  <div id="resultados"></div>

<script>
function buscador(){
$.get("./php_menu/buscador.php","",function(data){
$("#div_buscador").html(data); })}
 buscador();

$(document).ready(function(){
    load(1);});

function load(page)
{
    $('.filter_data').html('');
    var mar_id = get_filter('mar_id');
    $.ajax({
    url:"./php_tienda/tabla_resultados_marcas.php",
    method:"GET",
    data:{mar_id:mar_id,page:page},
    success:function(data){
    $('.filter_data').html(data);
    buscador();
    consultar_nombre(); } }); }



function get_filter(class_name)
{
    var filter = [];
    $('.'+class_name+':checked').each(function(){
    filter.push($(this).val());
    });
    return filter;
    }
    $('.common_selector').click(function(){
    load(1);
    });


function consultar_nombre() {
    var mar_id = get_filter('mar_id');
    $.ajax({
    url:'./php_tienda/tabla_nombre_marcas.php',
     data:{mar_id:mar_id},
    beforeSend: function(){
    $('#resultados_nombre').html('');
    },
    success: function(datos){
    $("#resultados_nombre").html(datos);}
    }); }
    consultar_nombre();

</script>


</html>
