{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-module" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></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 %}
    <div id="newlink" class="default"></div>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_edit }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-module" class="form-horizontal">

          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
            <div class="col-sm-10">
              <select name="status" id="input-status" class="form-control">
                {% if status %}
                <option value="1" selected="selected">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
                {% else %}
                <option value="1">{{ text_enabled }}</option>
                <option value="0" selected="selected">{{ text_disabled }}</option>
                {% endif %}
              </select>
            </div>         
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-name">{{ entry_name }}</label>
            <div class="col-sm-10">
              <input type="text" name="name" value="{{ name }}" placeholder="{{ entry_name }}" id="input-name" class="form-control" />
              {% if error_name %}
              <div class="text-danger">{{ error_name }}</div>
              {% endif %}
            </div>
          </div>
            

            <div class="tab-content">
              <div class="tab-pane active" id="tab-general">
                  <ul class="nav nav-tabs" id="language">
                    {% for language in languages %}
                    <li><a href="#language{{ language.language_id }}" data-toggle="tab"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</a></li>
                    {% endfor %}
                  </ul>
                <div class="tab-content">{% for language in languages %}
                  <div class="tab-pane" id="language{{ language.language_id }}">
                    <div class="form-group">
                      <label class="col-sm-2 control-label" for="input-title{{ language.language_id }}">{{ parentsetting_title }}</label>
                      <div class="col-sm-10">
                        <input type="text" name="tntbrandlist_parent[{{ language.language_id }}][title]" value="{{ tntbrandlist_parent[language.language_id] ? tntbrandlist_parent[language.language_id].title }}" placeholder="{{ parentsetting_title }}" id="input-name{{ language.language_id }}" class="form-control" />
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label" for="input-subtitle{{ language.language_id }}">{{ childsetting_title }}</label>
                      <div class="col-sm-10">
                        <input type="text" name="tntbrandlist_parent[{{ language.language_id }}][subtitle]" value="{{ tntbrandlist_parent[language.language_id] ? tntbrandlist_parent[language.language_id].subtitle }}" placeholder="{{ childsetting_title }}" id="input-name{{ language.language_id }}" class="form-control" />
                      </div>
                    </div>
                  </div>
                  {% endfor %}
                </div>
              </div>
            </div>
          <div class="table-responsive">
            <table id="special" class="table table-bordered table-hover tntbrandlist">
              <thead>
                <tr>
                  <td class="text-left">{{ entry_title }}</td>
                  <td class="text-left">{{ entry_image }}</td>
                  <td class="text-left">{{ entry_link }}</td>
                  <td class="text-left">{{ entry_status }}</td>
                  <td class="text-left">Action</td>
                </tr>
              </thead>
               <tbody>
              {% set tntbrandlist_row = 0 %}
              {% for tntbrandlist in tntbrandlists %}             
              <tr id="dataarray_{{ tntbrandlist.tntbrandlist_id }}" class="special-row{{ tntbrandlist_row }}">
                 <td class="text-left">
                      {% for language in languages %}
                          <div class="input-group"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>
                            <input type="text" name="tntbrandlist[{{ tntbrandlist_row }}][tntbrandlist_text][{{ language.language_id }}][title]" value="{{ tntbrandlist.tntbrandlist_text[language.language_id].title }}" placeholder="{{ entry_title }}" class="form-control" />
                          </div>
                      {% endfor %}
                  </td>
                  <td class="text-center">
                        <a href="" id="thumb-image{{ tntbrandlist_row }}" data-toggle="image" class="img-thumbnail"><img src="{{ tntbrandlist.tntbrandlist_thumb }}" alt="" title="" data-placeholder="{{ placeholder }}" /></a>

                        <input type="hidden" name="tntbrandlist[{{ tntbrandlist_row }}][tntbrandlist_image]" value="{{ tntbrandlist.tntbrandlist_image }}" id="input-image{{ tntbrandlist_row }}" placeholder="{{ entry_image }}" />
                        {% if error_banner_image[language.language_id][tntbrandlist_row] %}
                        <div class="text-danger">{{ error_banner_image[language.language_id][tntbrandlist_row] }}</div>
                        {% endif %}
                      </td>
                  <td class="text-right"><input type="text" name="tntbrandlist[{{ tntbrandlist_row }}][tntbrandlist_link]" value="{{ tntbrandlist.tntbrandlist_link }}" placeholder="{{ entry_priority }}" class="form-control" /></td>
                   
                    <td class="text-left">                      
                      <label class="radio-inline"> {% if tntbrandlist.tntbrandlist_status %}
                      <input type="radio" name="tntbrandlist[{{ tntbrandlist_row }}][tntbrandlist_status]" value="1" checked="checked" />
                      {{ text_yes }}
                      {% else %}
                      <input type="radio" name="tntbrandlist[{{ tntbrandlist_row }}][tntbrandlist_status]" value="1" />
                      {{ text_yes }}
                      {% endif %} </label>
                      <label class="radio-inline"> {% if not tntbrandlist.tntbrandlist_status %}
                      <input type="radio" name="tntbrandlist[{{ tntbrandlist_row }}][tntbrandlist_status]" value="0" checked="checked" />
                      {{ text_no }}
                      {% else %}
                      <input type="radio" name="tntbrandlist[{{ tntbrandlist_row }}][tntbrandlist_status]" value="0" />
                      {{ text_no }}
                      {% endif %} </label>
                    </td>
                <td class="text-left"><button type="button" onclick="$('.special-row{{ tntbrandlist_row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
              </tr>
              {% set tntbrandlist_row = tntbrandlist_row + 1 %}
              {% endfor %}
                </tbody>
              
              <tfoot>
                <tr>
                  <td colspan="4"></td>
                  <td class="text-left"><button type="button" onclick="addrow();" data-toggle="tooltip" title="{{ button_special_add }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
                </tr>
              </tfoot>       
            </table>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
</div>
<script type="text/javascript" src="view/javascript/adminthemejs/jquery.ui.core.min.js"></script> 
<script type="text/javascript" src="view/javascript/adminthemejs/jquery.ui.widget.min.js"></script> 
<script type="text/javascript" src="view/javascript/adminthemejs/jquery.ui.mouse.min.js"></script> 
<script type="text/javascript" src="view/javascript/adminthemejs/jquery.sortable.js"></script> 
<script type="text/javascript" src="view/javascript/adminthemejs/jquery-ui.js"></script> 

<script type="text/javascript"><!--
  $('#language a:first').tab('show');

$(document).ready(function(){
  function removeTags(){
    setTimeout(function() {
        $(".tntbrandlist-position-update").remove();
      }, 2500);
  }

  var link = 'index.php?route=extension/module/tntbrandlist/sorting&user_token={{ user_token }}&action=edit&';

  var obj  = $(document).find('body');
      
  $(".tntbrandlist tbody").sortable({
      opacity: 0.5,
      cursor: 'move',
      update: function() {
          var order = $(this).sortable("serialize");
          var qq = link + '' + order;
          console.log(qq);
          $.post(qq, order, function(data) {
              var arr_data = data.split('##');

              var result = arr_data[0];

              var notic = 'Position is Updated.';
              if (result == 'right') {
                  var tags = '';

                  tags += '<div id="newlink" class="alert alert-success alert-dismissible default tntbrandlist-position-update"><i class="fa fa-check-circle"></i> '+ notic +'<button type="button" class="close" data-dismiss="alert">&times;</button>';
                  tags += '</div>';

                  obj.find('#newlink').html(tags);
                  removeTags();
              }
          });
      }
  });
});





var tntbrandlist_row = {{ tntbrandlist_row }};

function addrow() {
    html  = '<tr class="special-row' + tntbrandlist_row + '">';
    
      html += '  <td class="text-left">';
          {% for language in languages %}
          html += '       <div class="input-group"><span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /></span>\
                              <input type="text" name="tntbrandlist[' + tntbrandlist_row + '][tntbrandlist_text][{{ language.language_id }}][title]" value="" placeholder="{{ entry_title }}" class="form-control" />\
                            </div>';
          {% endfor %}
      html += ' </td>';
      
      html += '  <td class="text-center"><a href="" id="thumb-image' + tntbrandlist_row + '" data-toggle="image" class="img-thumbnail"><img src="{{ placeholder }}" alt="" title="" data-placeholder="{{ placeholder }}" /></a><input type="hidden" name="tntbrandlist[' + tntbrandlist_row + '][tntbrandlist_image]" value="" id="input-image' + tntbrandlist_row + '" /></td>';

      html += '  <td class="text-right"><input type="text" name="tntbrandlist[' + tntbrandlist_row + '][tntbrandlist_link]" value="" placeholder="{{ entry_link }}" class="form-control" /></td>';

  
      html += '  <td class="text-left"><label class="radio-inline"><input type="radio" name="tntbrandlist[' + tntbrandlist_row + '][tntbrandlist_status]" value="1" checked="checked" /> {{ text_yes }} </label><label class="radio-inline"><input type="radio" name="tntbrandlist[' + tntbrandlist_row + '][tntbrandlist_status]" value="1" /> {{ text_no }}</label></td>';

    html += '  <td class="text-left"><button type="button" onclick="$(\'.special-row' + tntbrandlist_row + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
    html += '</tr>';
    $('#special tbody').append(html);
    tntbrandlist_row++;
}

//--></script> 

{{ footer }}