{% if product_datas  %}


    <center><h3 style="color: green">Ürün Önerisi</h3></center>

    <div class="panel-body well">

        <table style="height:100px; overflow-y:auto;" class="table">

            <thead>
            <tr>
                <th>Görsel</th>
                <th>Ürün Adı</th>
                <th>Model Kodu</th>
                <th>Eylem</th>
            </tr>
            </thead>
            {% for product in product_datas %}


                <tbody>
                <tr>
                    <td><img class="img thumbnail img-sm" src="{{  product.image}}" alt=""></td>
                    <td>{{ product.name }}</td>
                    <td>{{ product.model }}</td>
                    <td><a class="btn btn-primary btnMatched" primary_id="{{ primary_id }}" product_type="{{ product_type }}"  code="{{ code }}" market_product_id="{{ product.market_product_id }}">Eşleştir</a></td>
                </tr>

                </tbody>


            {% endfor %}
        </table>
    </div>


{% endif %}


<div class="input-group">
    <input type="text" class="form-control input-lg product_name"  placeholder="Ürün Ara.." name="search" aria-label="Ürün araması yapın">
    <span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>



<div class="search_page">



</div>




<script>

    /* $('.search_product').on('click',function () {

         var gelen =  jQuery.trim($('.product_name').val());
         var result = gelen.replaceAll(" ", "**");


         $('.search_page').load('index.php?route=entegrasyon/product/product_match_search&{{token_link }}&gelen='+result+'');



    })*/








    $('.product_name').keyup(delay(function (e) {
        console.log('Time elapsed!', this.value);
        var filter_name=  $('.product_name').val();


        if (filter_name.length > 3){
            $('.search_page').load('index.php?route=entegrasyon/sync/product_match_search&{{token_link }}&code={{ code }}&primary_id={{ primary_id }}&product_type={{ product_type }}&filter_name='+encodeURI(filter_name),function (event) {

            });

        }
    }, 800));

    /*   $(".product_name").keyup(function() {

       var filter_name=  $('.product_name').val();


       if (filter_name.length > 3){
       $('.search_page').load('index.php?route=entegrasyon/product/product_match_search&{{token_link }}&code={{ code }}&filter_name='+encodeURI(filter_name),function (event) {

            });

            }
        }); */



    function delay(callback, ms) {
        var timer = 0;
        return function() {
            var context = this, args = arguments;
            clearTimeout(timer);
            timer = setTimeout(function () {
                callback.apply(context, args);
            }, ms || 0);
        };
    }

</script>