{{ header }}{{ column_left }}
<div id="content">
    <div class="page-header">
        <div class="container-fluid">

            <ul class="breadcrumb">
                {% for breadcrumb in breadcrumbs %}
                    <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
                {% endfor %}
            </ul>
       
        </div>

    </div>
    <div class="container-fluid">
        {% if error_warning %}
            <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
                <button type="button" class="close" data-dismiss="alert">&times;</button>
            </div>
        {% endif %}
        {% if success %}
            <div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> {{ success }}
                <button type="button" class="close" data-dismiss="alert">&times;</button>
            </div>
        {% endif %}


        <div class="row well"  style="border-top: 2px solid #27ad5e;">
            
            <div class="col-sm-1">
                <img class="img-responsive" src="view/image/entegrasyon/bilgi.png"/>
            </div>
            <div class="col-sm-11">
                <h3 style="color:#27ad5e;font-weight: bolder ">Bilgilendirme</h3>
                <p style="font-size: larger" >Marka eşleştirme sadece <strong>Trendyol</strong> için zorunludur. Markaya yönelik komisyon oranı teslimat süresi gibi ayarlar yapabilirsiniz ancak eğer standart mağaza ayarlarında komisyon oranı vb özellikleri belirlediyseniz tüm marka ve pazaryerleri için bu ayarları yapmanız zorunlu değildir. Ürün gönderimi yada güncelleme işlemlerinde ürüne özel ayarlar yapılmadıysa marka için ayarlanmış özellikler işleme alınır.</p>

            </div>
        </div>

        <div class="well" style="border-top: 2px solid #27ad5e;">
            <div class="row">


                    <div class="col-sm-11">
                        <label class="control-label" for="input-model">Üreticiler</label>
                        <input type="text" name="manufacturer" value="{{ filter_manufacturer_name }}" placeholder="Otomatik Tamamlama" id="input-manufacturer" class="form-control"/>
                <input type="hidden" name="filter_manufacturer" value="{{ filter_manufacturer }}"/>

                    </div>
                    <div class="col-sm-1" style="margin-top: 20px">
                        <button type="button" id="button-filter" class="btn btn-primary pull-right"><i class="fa fa-search"></i> {{ button_filter }}</button>


                    </div>



            </div>
        </div>

        <div class="panel panel-default" style="border-top: 2px solid #27ad5e;">
            <div class="panel-heading">
                <h2 class="panel-title"><i class="fa fa-list"></i> {{ text_list }}</h2>
                <div style="margin-top: -10px" class="pull-right"><a href="{{ add }}" data-toggle="tooltip" title="{{ button_add }}" class="btn btn-primary"><i class="fa fa-plus"></i></a>
                    <button type="button" data-toggle="tooltip" title="{{ button_delete }}" class="btn btn-danger" onclick="confirm('{{ text_confirm }}') ? $('#form-manufacturer').submit() : false;"><i class="fa fa-trash-o"></i></button>
                </div>
            </div>
            <div class="panel-body">
                <form action="{{ delete }}" method="post" enctype="multipart/form-data" id="form-manufacturer">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);" /></td>
                                <td class="text-left">{% if sort == 'name' %}
                                        <a href="{{ sort_name }}" class="{{ order|lower }}">{{ column_name }}</a>
                                    {% else %}
                                        <a href="{{ sort_name }}">{{ column_name }}</a>
                                    {% endif %}</td>

                                {% for marketplace in marketplaces %}
                                    {% if marketplace.status %}
                                        <td class="text-center"> <img src="{{ marketplace.logo }}" />  <span class="hidden-xs">{{ marketplace.name }}</span></td>
                                    {% endif %}

                                {% endfor %}

                            </tr>
                            </thead>
                            <tbody>
                            {% if manufacturers %}
                                {% for manufacturer in manufacturers %}
                                    <tr>
                                        <td class="text-center">{% if manufacturer.manufacturer_id in selected %}
                                                <input type="checkbox" name="selected[]" value="{{ manufacturer.manufacturer_id }}" checked="checked" />
                                            {% else %}
                                                <input type="checkbox" name="selected[]" value="{{ manufacturer.manufacturer_id }}" />
                                            {% endif %}</td>
                                        <td class="text-left">{{ manufacturer.name }}</td>

                                        {% for marketplace in marketplaces %}

                                            {% if marketplace.status %}

                                                <td class="text-center">
                                                    <button manufacturer_id="{{manufacturer.manufacturer_id  }}" name="{{ marketplace.name }}" code="{{ marketplace.code }}" class="btn btnSetting {% if not  manufacturer[marketplace.code] %} btn-default {% else %} btn-primary {% endif %} ">{% if not manufacturer[marketplace.code]%} <i class="fa fa-wrench"></i> {% else %} <i class="fa fa-edit"></i> {% endif %}</button>
                                                </td>


                                            {% endif %}

                                        {% endfor %}


                                    </tr>
                                {% endfor %}
                            {% else %}
                                <tr>
                                    <td class="text-center" colspan="4">{{ text_no_results }}</td>
                                </tr>
                            {% endif %}
                            </tbody>
                        </table>
                    </div>
                </form>
                <div class="row">
                    <div class="col-sm-6 text-left">{{ pagination }}</div>
                    <div class="col-sm-6 text-right">{{ results }}</div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript"><!--
    $('#button-filter').on('click', function() {
        var url = 'index.php?route=entegrasyon/manufacturer&{{ token_link }}';


        var filter_manufacturer = $('input[name=\'filter_manufacturer\']').val();



        if (filter_manufacturer != '*') {
            url += '&filter_manufacturer=' + encodeURIComponent(filter_manufacturer);
        }

        location = url;
    });
    //--></script>

<script>


    $('input[name=\'manufacturer\']').autocomplete({
        'source': function(request, response) {
            $.ajax({
                url: 'index.php?route=catalog/manufacturer/autocomplete&{{ token_link }}&filter_name=' + encodeURIComponent(request),
                dataType: 'json',
                success: function(json) {
                    json.unshift({
                        manufacturer_id: 0,
                        name: '{{ text_none }}'
                    });

                    response($.map(json, function(item) {
                        return {
                            label: item['name'],
                            value: item['manufacturer_id']
                        }
                    }));
                }
            });
        },
        'select': function(item) {
            $('input[name=\'manufacturer\']').val(item['label']);
            $('input[name=\'filter_manufacturer\']').val(item['value']);
        }
    });



</script>

<script>
    $('.btnSetting').on('click',function (event) {

        event.preventDefault();
        var $thisBtn=$(this);
        var code=$thisBtn.attr('code');
        var name=$thisBtn.attr('name');
        var manufacturer_id=$thisBtn.attr('manufacturer_id')

        BootstrapDialog.show({
            title:name+' - Marka Ayarları',
            message: function(dialog) {
                var $message = $('<div></div>');
                var pageToLoad = dialog.getData('pageToLoad');
                $message.load(pageToLoad);
                return $message;
            },
            data: {
                'pageToLoad':'index.php?route=entegrasyon/manufacturer/setting&code='+code+'&manufacturer_id='+manufacturer_id+'&{{ token_link }}'
            }
        });


    })

</script>
<script>

    $(document).on('click','#btnComplate',function () {

        $.each(BootstrapDialog.dialogs, function(id, dialog){
            dialog.close();
        });
    })

</script>
{{ footer }}