{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-category" formaction="{{ copy }}" data-toggle="tooltip"  title="{{ button_copy }}" class="btn btn-default"><i class="fa fa-copy"></i></button>
        <button type="button" data-toggle="tooltip" title="{{ button_delete }}" class="btn btn-danger" onclick="confirm('{{ text_confirm }}') ? $('#form-category').submit() : false;"><i class="fa fa-trash-o"></i></button>
      </div>
      <h1>{{ heading_title }}</h1>
      <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="well" style="border-top: 2px solid #27ad5e;">
      <div class="row">


        <div class="col-sm-11">

          <label class="control-label" for="input-model">Kategori</label>
          <input type="text" value="{{ filter_category_name }}" placeholder="Otomatik Tamamlama" class="form-control" data-live-search="true" name="category" data-size="20" data-title="Kategori Seçiniz">
          <input type="hidden" value="{{ filter_category }}" name="filter_category">

        </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>

    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-list"></i> {{ text_list }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ delete }}" method="post" enctype="multipart/form-data" id="form-category">
          <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 %}
                    <a href="{{ sort_name }}" class="{{ order|lower }}">{{ column_name }}</a>
                    {% else %}
                    <a href="{{ sort_name }}">{{ column_name }}</a>
                    {% endif %}</td>


                  <td>N11</td>
                  <td>Hepsiburada</td>
                  <td>Çiçeksepeti</td>
                  <td>Eptt</td>
                  <td>Pazarama</td>
                  <td>Amazon</td>
                  <td>Etsy</td>
                  <td>Aliexpress</td>
                </tr>
              </thead>
              <tbody>
                {% if categories %}
                {% for category in categories %}
                <tr>
                  <td class="text-center">{% if category.category_id in selected %}
                    <input type="checkbox" name="selected[]" value="{{ category.category_id }}" checked="checked" />
                    {% else %}
                    <input type="checkbox" name="selected[]" value="{{ category.category_id }}" />
                    {% endif %}</td>

                  <td class="text-left"><a  href="#" id="name" class="editable"  data-type="textarea" data-pk="{{ category.id }}"
                                                               data-value="{{ category.name }}" style="    color: black;
    font-weight: 700;" data-emptytext="Kategori Adı"
                                                               data-url="index.php?route=catalog/category/edit_category&user_token={{  user_token }}"
                                                               data-title="Kategori Giriniz."></a></td>
                  <td class="text-left"> <a href="#" id="n11" class="eslestirn11" data-type="typeaheadjs" data-pk="{{ category.id }}" data-value="{{ category.n11_name }}" data-emptytext="Kategori Eşleştirin" data-url="index.php?route=catalog/category/match_category&user_token={{  user_token }}" data-title="Lütfen Kategori Arayın">{{ category.n11_name }}</a></td>
                  </td>
                  <td class="text-left">
                    <a href="#" id="hb" class="eslestirhb" data-type="typeaheadjs" data-pk="{{ category.id }}" data-value="{{ category.hb_name }}" data-emptytext="Kategori Eşleştirin" data-url="index.php?route=catalog/category/match_category&user_token={{  user_token }}" data-title="Lütfen Kategori Arayın">{{ category.hb_name }}</a></td>

                  </td>
                  <td class="text-left">
                    <a href="#" id="cs" class="eslestircs" data-type="typeaheadjs" data-pk="{{ category.id }}" data-value="{{ category.cs_name }}" data-emptytext="Kategori Eşleştirin" data-url="index.php?route=catalog/category/match_category&user_token={{  user_token }}" data-title="Lütfen Kategori Arayın">{{ category.cs_name }}</a></td>
                  </td>
                  <td class="text-left">  <a href="#" id="eptt" class="eslestireptt" data-type="typeaheadjs" data-pk="{{ category.id }}" data-value="{{ category.eptt_name }}" data-emptytext="Kategori Eşleştirin" data-url="index.php?route=catalog/category/match_category&user_token={{  user_token }}" data-title="Lütfen Kategori Arayın">{{ category.eptt_name }}</a></td>
                  </td>    <td class="text-left">  <a href="#" id="pz" class="eslestirpz" data-type="typeaheadjs" data-pk="{{ category.id }}" data-value="{{ category.pz_name }}" data-emptytext="Kategori Eşleştirin" data-url="index.php?route=catalog/category/match_category&user_token={{  user_token }}" data-title="Lütfen Kategori Arayın">{{ category.pz_name }}</a></td>
                  </td>
                  <td class="text-left">{{ category.amz }}</td>
                  <td class="text-left">{{ category.etsy }}</td>
                  <td class="text-left">{{ category.ali }}</td>
                </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=catalog/category&user_token={{ user_token }}';


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

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

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


  $('.editable').editable({ inputclass: 'intclass input-sm',success:function (json,newValue) {


      if(json['status']){

        $.toast({heading: 'Başarılı',text: json['message'], position: 'top-right',loader: true,allowToastClose: false,showHideTransition: 'slide',icon: 'success'});



      }else {


        Swal.fire('Hata',json['message'],'warning');



      }

    }});


  $('.eslestireptt').editable({
    typeahead: {
      limit: 200,
      remote:"index.php?route=catalog/category/search&code=eptt&filter_name=%QUERY&{{ token_link }}&user_token={{ user_token }}",
      displayKey: 'category_id',
      valueKey : 'name',
      display: function(item){ return item.name },

    }, success:function (json,newValue) {


      if(!json['status']){
        if(json['alert_type']==2){

          Swal.fire('Hata',json['message'],'danger');
        }else {

          $.toast({heading: 'Hata',text: json['message'], position: 'top-right',loader: true,allowToastClose: false,showHideTransition: 'slide',icon: 'warning'});

        }


      }else {
        if(newValue){
          $('.default_category_attributes').removeClass('hidden')
          $('.category_attribute_cont').removeClass('hidden')
        }else {
          $('.default_category_attributes').addClass('hidden')
          $('.category_attribute_cont').addClass('hidden')
          $('.option-container').empty();
        }

      }

    }
  });
  $('.eslestircs').editable({
    typeahead: {
      limit: 200,
      remote:"index.php?route=catalog/category/search&code=cs&filter_name=%QUERY&{{ token_link }}&user_token={{ user_token }}",
      displayKey: 'category_id',
      valueKey : 'name',
      display: function(item){ return item.name },

    }, success:function (json,newValue) {


      if(!json['status']){
        if(json['alert_type']==2){

          Swal.fire('Hata',json['message'],'danger');
        }else {

          $.toast({heading: 'Hata',text: json['message'], position: 'top-right',loader: true,allowToastClose: false,showHideTransition: 'slide',icon: 'warning'});

        }


      }else {
        if(newValue){
          $('.default_category_attributes').removeClass('hidden')
          $('.category_attribute_cont').removeClass('hidden')
        }else {
          $('.default_category_attributes').addClass('hidden')
          $('.category_attribute_cont').addClass('hidden')
          $('.option-container').empty();
        }

      }

    }
  });
  $('.eslestirhb').editable({
    typeahead: {
      limit: 200,
      remote:"index.php?route=catalog/category/search&code=hb&filter_name=%QUERY&{{ token_link }}&user_token={{ user_token }}",
      displayKey: 'category_id',
      valueKey : 'name',
      display: function(item){ return item.name },

    }, success:function (json,newValue) {


      if(!json['status']){
        if(json['alert_type']==2){

          Swal.fire('Hata',json['message'],'danger');
        }else {

          $.toast({heading: 'Hata',text: json['message'], position: 'top-right',loader: true,allowToastClose: false,showHideTransition: 'slide',icon: 'warning'});

        }


      }else {
        if(newValue){
          $('.default_category_attributes').removeClass('hidden')
          $('.category_attribute_cont').removeClass('hidden')
        }else {
          $('.default_category_attributes').addClass('hidden')
          $('.category_attribute_cont').addClass('hidden')
          $('.option-container').empty();
        }

      }

    }
  });
  $('.eslestirn11').editable({
    typeahead: {
      limit: 200,
      remote:"index.php?route=catalog/category/search&code=n11&filter_name=%QUERY&{{ token_link }}&user_token={{ user_token }}",
      displayKey: 'category_id',
      valueKey : 'name',
      display: function(item){ return item.name },

    }, success:function (json,newValue) {


      if(!json['status']){
        if(json['alert_type']==2){

          Swal.fire('Hata',json['message'],'danger');
        }else {

          $.toast({heading: 'Hata',text: json['message'], position: 'top-right',loader: true,allowToastClose: false,showHideTransition: 'slide',icon: 'warning'});

        }


      }else {
        if(newValue){
          $('.default_category_attributes').removeClass('hidden')
          $('.category_attribute_cont').removeClass('hidden')
        }else {
          $('.default_category_attributes').addClass('hidden')
          $('.category_attribute_cont').addClass('hidden')
          $('.option-container').empty();
        }

      }

    }
  });

  $('.eslestirpz').editable({
    typeahead: {
      limit: 200,
      remote:"index.php?route=catalog/category/search&code=pz&filter_name=%QUERY&{{ token_link }}&user_token={{ user_token }}",
      displayKey: 'id',
      valueKey : 'name',
      display: function(item){ return item.name },

    }, success:function (json,newValue) {


      if(!json['status']){
        if(json['alert_type']==2){

          Swal.fire('Hata',json['message'],'danger');
        }else {

          $.toast({heading: 'Hata',text: json['message'], position: 'top-right',loader: true,allowToastClose: false,showHideTransition: 'slide',icon: 'warning'});

        }


      }else {
        if(newValue){
          $('.default_category_attributes').removeClass('hidden')
          $('.category_attribute_cont').removeClass('hidden')
        }else {
          $('.default_category_attributes').addClass('hidden')
          $('.category_attribute_cont').addClass('hidden')
          $('.option-container').empty();
        }

      }

    }
  });

  $.fn.editableform.buttons =
          '<button type="submit" class="btn btn-primary btn-sm editable-submit">' +
          '<i class="fa fa-check"></i>' +
          '</button>' +
          '<button type="button" class="btn btn-danger btn-sm editable-cancel">' +
          '<i class="fa fa-times"></i>' +
          '</button>';

</script>

<script>

  $('input[name=\'category\']').autocomplete2({
    'source': function(request, response) {
      $.ajax({
        url: 'index.php?route=catalog/category/autocomplete&{{ token_link }}&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request),
        dataType: 'json',
        success: function(json) {
          response($.map(json, function(item) {
            return {
              label: item['name'],
              value: item['category_id']
            }
          }));
        }
      });
    },
    'select': function(item) {


      $('input[name=\'category\']').val(item['label']);
      $('input[name=\'filter_category\']').val(item['value']);


    }
  });


</script>


{{ footer }}